1
From: Thomas Schwinge <thomas@schwinge.name>
2
Subject: [PATCH] extern_inline
4
Fix some ``extern inline'' stuff.
6
glibc-2.8/debian/patches/hurd-i386/submitted-extern_inline.diff 3057
8
Probably all done by Samuel Thibault.
12
hurd/hurd/fd.h | 20 ++++++++++++++++++++
13
hurd/hurd/port.h | 31 +++++++++++++++++++++++++++++++
14
hurd/hurd/signal.h | 16 +++++++++++++---
15
hurd/hurd/threadvar.h | 5 +++++
16
hurd/hurd/userlink.h | 14 ++++++++++++++
17
mach/lock-intern.h | 20 ++++++++++++++++++++
18
mach/mach/mig_support.h | 3 +++
19
mach/spin-lock.c | 1 +
20
sysdeps/generic/machine-lock.h | 12 ++++++++++++
21
sysdeps/generic/machine-sp.h | 4 ++++
22
sysdeps/mach/i386/machine-lock.h | 12 ++++++++++++
23
sysdeps/mach/powerpc/machine-lock.h | 12 ++++++++++++
24
sysdeps/mach/powerpc/machine-sp.h | 4 ++++
25
14 files changed, 155 insertions(+), 3 deletions(-)
27
diff --git a/hurd/hurd.h b/hurd/hurd.h
28
index 642ea43..2ce1da0 100644
32
#define _HURD_H_EXTERN_INLINE __extern_inline
35
+int __hurd_fail (error_t err);
37
+#ifdef __USE_EXTERN_INLINES
38
_HURD_H_EXTERN_INLINE int
39
__hurd_fail (error_t err)
41
@@ -77,6 +80,7 @@ __hurd_fail (error_t err)
47
/* Basic ports and info, initialized by startup. */
49
diff --git a/hurd/hurd/fd.h b/hurd/hurd/fd.h
50
index 2473476..034e7ca 100644
53
@@ -60,6 +60,9 @@ extern struct mutex _hurd_dtable_lock; /* Locks those two variables. */
54
NULL. The cell is unlocked; when ready to use it, lock it and check for
57
+struct hurd_fd *_hurd_fd_get (int fd);
59
+#ifdef __USE_EXTERN_INLINES
60
_HURD_FD_H_EXTERN_INLINE struct hurd_fd *
63
@@ -90,6 +93,7 @@ _hurd_fd_get (int fd)
70
/* Evaluate EXPR with the variable `descriptor' bound to a pointer to the
71
@@ -137,6 +141,9 @@ _hurd_fd_get (int fd)
72
/* Check if ERR should generate a signal.
73
Returns the signal to take, or zero if none. */
75
+int _hurd_fd_error_signal (error_t err);
77
+#ifdef __USE_EXTERN_INLINES
78
_HURD_FD_H_EXTERN_INLINE int
79
_hurd_fd_error_signal (error_t err)
81
@@ -153,11 +160,15 @@ _hurd_fd_error_signal (error_t err)
87
/* Handle an error from an RPC on a file descriptor's port. You should
88
always use this function to handle errors from RPCs made on file
89
descriptor ports. Some errors are translated into signals. */
91
+error_t _hurd_fd_error (int fd, error_t err);
93
+#ifdef __USE_EXTERN_INLINES
94
_HURD_FD_H_EXTERN_INLINE error_t
95
_hurd_fd_error (int fd, error_t err)
97
@@ -170,20 +181,28 @@ _hurd_fd_error (int fd, error_t err)
103
/* Handle error code ERR from an RPC on file descriptor FD's port.
104
Set `errno' to the appropriate error code, and always return -1. */
106
+int __hurd_dfail (int fd, error_t err);
108
+#ifdef __USE_EXTERN_INLINES
109
_HURD_FD_H_EXTERN_INLINE int
110
__hurd_dfail (int fd, error_t err)
112
errno = _hurd_fd_error (fd, err);
117
/* Likewise, but do not raise SIGPIPE on EPIPE if flags contain
120
+int __hurd_sockfail (int fd, int flags, error_t err);
122
+#ifdef __USE_EXTERN_INLINES
123
_HURD_FD_H_EXTERN_INLINE int
124
__hurd_sockfail (int fd, int flags, error_t err)
126
@@ -192,6 +211,7 @@ __hurd_sockfail (int fd, int flags, error_t err)
132
/* Set up *FD to have PORT its server port, doing appropriate ctty magic.
133
Does no locking or unlocking. */
134
diff --git a/hurd/hurd/port.h b/hurd/hurd/port.h
135
index a1803c3..30769c9 100644
136
--- a/hurd/hurd/port.h
137
+++ b/hurd/hurd/port.h
138
@@ -62,6 +62,9 @@ struct hurd_port
140
/* Initialize *PORT to INIT. */
142
+void _hurd_port_init (struct hurd_port *port, mach_port_t init);
144
+#ifdef __USE_EXTERN_INLINES
145
_HURD_PORT_H_EXTERN_INLINE void
146
_hurd_port_init (struct hurd_port *port, mach_port_t init)
148
@@ -69,6 +72,7 @@ _hurd_port_init (struct hurd_port *port, mach_port_t init)
155
/* Cleanup function for non-local exits. */
156
@@ -77,6 +81,11 @@ extern void _hurd_port_cleanup (void *, jmp_buf, int);
157
/* Get a reference to *PORT, which is locked.
158
Pass return value and LINK to _hurd_port_free when done. */
161
+_hurd_port_locked_get (struct hurd_port *port,
162
+ struct hurd_userlink *link);
164
+#ifdef __USE_EXTERN_INLINES
165
_HURD_PORT_H_EXTERN_INLINE mach_port_t
166
_hurd_port_locked_get (struct hurd_port *port,
167
struct hurd_userlink *link)
168
@@ -92,9 +101,15 @@ _hurd_port_locked_get (struct hurd_port *port,
169
__spin_unlock (&port->lock);
174
/* Same, but locks PORT first. */
177
+_hurd_port_get (struct hurd_port *port,
178
+ struct hurd_userlink *link);
180
+#ifdef __USE_EXTERN_INLINES
181
_HURD_PORT_H_EXTERN_INLINE mach_port_t
182
_hurd_port_get (struct hurd_port *port,
183
struct hurd_userlink *link)
184
@@ -106,10 +121,17 @@ _hurd_port_get (struct hurd_port *port,
191
/* Free a reference gotten with `USED_PORT = _hurd_port_get (PORT, LINK);' */
194
+_hurd_port_free (struct hurd_port *port,
195
+ struct hurd_userlink *link,
196
+ mach_port_t used_port);
198
+#ifdef __USE_EXTERN_INLINES
199
_HURD_PORT_H_EXTERN_INLINE void
200
_hurd_port_free (struct hurd_port *port,
201
struct hurd_userlink *link,
202
@@ -129,11 +151,15 @@ _hurd_port_free (struct hurd_port *port,
204
__mach_port_deallocate (__mach_task_self (), used_port);
209
/* Set *PORT's port to NEWPORT. NEWPORT's reference is consumed by PORT->port.
210
PORT->lock is locked. */
212
+void _hurd_port_locked_set (struct hurd_port *port, mach_port_t newport);
214
+#ifdef __USE_EXTERN_INLINES
215
_HURD_PORT_H_EXTERN_INLINE void
216
_hurd_port_locked_set (struct hurd_port *port, mach_port_t newport)
218
@@ -144,9 +170,13 @@ _hurd_port_locked_set (struct hurd_port *port, mach_port_t newport)
219
if (old != MACH_PORT_NULL)
220
__mach_port_deallocate (__mach_task_self (), old);
224
/* Same, but locks PORT first. */
226
+void _hurd_port_set (struct hurd_port *port, mach_port_t newport);
228
+#ifdef __USE_EXTERN_INLINES
229
_HURD_PORT_H_EXTERN_INLINE void
230
_hurd_port_set (struct hurd_port *port, mach_port_t newport)
232
@@ -155,6 +185,7 @@ _hurd_port_set (struct hurd_port *port, mach_port_t newport)
233
_hurd_port_locked_set (port, newport);
239
#endif /* hurd/port.h */
240
diff --git a/hurd/hurd/signal.h b/hurd/hurd/signal.h
241
index 21e30c5..46c1fe1 100644
242
--- a/hurd/hurd/signal.h
243
+++ b/hurd/hurd/signal.h
244
@@ -131,15 +131,17 @@ extern struct hurd_sigstate *_hurd_self_sigstate (void)
245
#define _HURD_SIGNAL_H_EXTERN_INLINE __extern_inline
248
+#ifdef __USE_EXTERN_INLINES
249
_HURD_SIGNAL_H_EXTERN_INLINE struct hurd_sigstate *
250
_hurd_self_sigstate (void)
252
- struct hurd_sigstate **location =
253
+ struct hurd_sigstate **location = (struct hurd_sigstate **)
254
(void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE);
255
if (*location == NULL)
256
*location = _hurd_thread_sigstate (__mach_thread_self ());
261
/* Thread listening on our message port; also called the "signal thread". */
263
@@ -166,10 +168,13 @@ extern int _hurd_core_limit;
264
interrupted lest the signal handler try to take the same lock and
267
+void *_hurd_critical_section_lock (void);
269
+#ifdef __USE_EXTERN_INLINES
270
_HURD_SIGNAL_H_EXTERN_INLINE void *
271
_hurd_critical_section_lock (void)
273
- struct hurd_sigstate **location =
274
+ struct hurd_sigstate **location = (struct hurd_sigstate **)
275
(void *) __hurd_threadvar_location (_HURD_THREADVAR_SIGSTATE);
276
struct hurd_sigstate *ss = *location;
278
@@ -191,7 +196,11 @@ _hurd_critical_section_lock (void)
279
_hurd_critical_section_unlock to unlock it. */
284
+void _hurd_critical_section_unlock (void *our_lock);
286
+#ifdef __USE_EXTERN_INLINES
287
_HURD_SIGNAL_H_EXTERN_INLINE void
288
_hurd_critical_section_unlock (void *our_lock)
290
@@ -201,7 +210,7 @@ _hurd_critical_section_unlock (void *our_lock)
293
/* It was us who acquired the critical section lock. Unlock it. */
294
- struct hurd_sigstate *ss = our_lock;
295
+ struct hurd_sigstate *ss = (struct hurd_sigstate *) our_lock;
297
__spin_lock (&ss->lock);
298
__spin_unlock (&ss->critical_section_lock);
299
@@ -214,6 +223,7 @@ _hurd_critical_section_unlock (void *our_lock)
300
__msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
305
/* Convenient macros for simple uses of critical sections.
306
These two must be used as a pair at the same C scoping level. */
307
diff --git a/hurd/hurd/threadvar.h b/hurd/hurd/threadvar.h
308
index a0535f7..dd4a59c 100644
309
--- a/hurd/hurd/threadvar.h
310
+++ b/hurd/hurd/threadvar.h
311
@@ -82,6 +82,8 @@ enum __hurd_threadvar_index
313
extern unsigned long int *__hurd_threadvar_location_from_sp
314
(enum __hurd_threadvar_index __index, void *__sp);
316
+#ifdef __USE_EXTERN_INLINES
317
_HURD_THREADVAR_H_EXTERN_INLINE unsigned long int *
318
__hurd_threadvar_location_from_sp (enum __hurd_threadvar_index __index,
320
@@ -93,6 +95,7 @@ __hurd_threadvar_location_from_sp (enum __hurd_threadvar_index __index,
321
: (unsigned long int *) ((__stack & __hurd_threadvar_stack_mask) +
322
__hurd_threadvar_stack_offset))[__index];
326
#include <machine-sp.h> /* Define __thread_stack_pointer. */
328
@@ -106,12 +109,14 @@ __hurd_threadvar_location (enum __hurd_threadvar_index __index) __THROW
329
the same stack frame by different threads. */
330
__attribute__ ((__const__));
332
+#ifdef __USE_EXTERN_INLINES
333
_HURD_THREADVAR_H_EXTERN_INLINE unsigned long int *
334
__hurd_threadvar_location (enum __hurd_threadvar_index __index)
336
return __hurd_threadvar_location_from_sp (__index,
337
__thread_stack_pointer ());
342
#endif /* hurd/threadvar.h */
343
diff --git a/hurd/hurd/userlink.h b/hurd/hurd/userlink.h
344
index 34457e7..90045a9 100644
345
--- a/hurd/hurd/userlink.h
346
+++ b/hurd/hurd/userlink.h
347
@@ -77,6 +77,11 @@ struct hurd_userlink
349
/* Attach LINK to the chain of users at *CHAINP. */
352
+_hurd_userlink_link (struct hurd_userlink **chainp,
353
+ struct hurd_userlink *link);
355
+#ifdef __USE_EXTERN_INLINES
356
_HURD_USERLINK_H_EXTERN_INLINE void
357
_hurd_userlink_link (struct hurd_userlink **chainp,
358
struct hurd_userlink *link)
359
@@ -97,11 +102,15 @@ _hurd_userlink_link (struct hurd_userlink **chainp,
360
link->thread.prevp = thread_chainp;
361
*thread_chainp = link;
366
/* Detach LINK from its chain. Returns nonzero iff this was the
367
last user of the resource and it should be deallocated. */
369
+int _hurd_userlink_unlink (struct hurd_userlink *link);
371
+#ifdef __USE_EXTERN_INLINES
372
_HURD_USERLINK_H_EXTERN_INLINE int
373
_hurd_userlink_unlink (struct hurd_userlink *link)
375
@@ -124,6 +133,7 @@ _hurd_userlink_unlink (struct hurd_userlink *link)
382
/* Clear all users from *CHAINP. Call this when the resource *CHAINP
383
@@ -132,6 +142,9 @@ _hurd_userlink_unlink (struct hurd_userlink *link)
384
value is zero, someone is still using the resource and they will
385
deallocate it when they are finished. */
387
+int _hurd_userlink_clear (struct hurd_userlink **chainp);
389
+#ifdef __USE_EXTERN_INLINES
390
_HURD_USERLINK_H_EXTERN_INLINE int
391
_hurd_userlink_clear (struct hurd_userlink **chainp)
393
@@ -144,5 +157,6 @@ _hurd_userlink_clear (struct hurd_userlink **chainp)
399
#endif /* hurd/userlink.h */
400
diff --git a/mach/lock-intern.h b/mach/lock-intern.h
401
index 4aaaedc..a854ddc 100644
402
--- a/mach/lock-intern.h
403
+++ b/mach/lock-intern.h
406
/* Initialize LOCK. */
408
+void __spin_lock_init (__spin_lock_t *__lock);
410
+#ifdef __USE_EXTERN_INLINES
412
__spin_lock_init (__spin_lock_t *__lock)
414
*__lock = __SPIN_LOCK_INITIALIZER;
419
/* Lock LOCK, blocking if we can't get it. */
420
@@ -41,12 +45,16 @@ extern void __spin_lock_solid (__spin_lock_t *__lock);
422
/* Lock the spin lock LOCK. */
424
+void __spin_lock (__spin_lock_t *__lock);
426
+#ifdef __USE_EXTERN_INLINES
428
__spin_lock (__spin_lock_t *__lock)
430
if (! __spin_try_lock (__lock))
431
__spin_lock_solid (__lock);
435
/* Name space-clean internal interface to mutex locks.
437
@@ -71,27 +79,39 @@ extern void __mutex_unlock_solid (void *__lock);
439
/* Lock the mutex lock LOCK. */
441
+void __mutex_lock (void *__lock);
443
+#ifdef __USE_EXTERN_INLINES
445
__mutex_lock (void *__lock)
447
if (! __spin_try_lock ((__spin_lock_t *) __lock))
448
__mutex_lock_solid (__lock);
452
/* Unlock the mutex lock LOCK. */
454
+void __mutex_unlock (void *__lock);
456
+#ifdef __USE_EXTERN_INLINES
458
__mutex_unlock (void *__lock)
460
__spin_unlock ((__spin_lock_t *) __lock);
461
__mutex_unlock_solid (__lock);
466
+int __mutex_trylock (void *__lock);
468
+#ifdef __USE_EXTERN_INLINES
470
__mutex_trylock (void *__lock)
472
return __spin_try_lock ((__spin_lock_t *) __lock);
476
#endif /* lock-intern.h */
477
diff --git a/mach/mach/mig_support.h b/mach/mach/mig_support.h
478
index f02e8d4..fdd43a6 100644
479
--- a/mach/mach/mig_support.h
480
+++ b/mach/mach/mig_support.h
481
@@ -67,6 +67,8 @@ extern void mig_reply_setup (const mach_msg_header_t *__request,
482
/* Idiocy support function. */
483
extern vm_size_t mig_strncpy (char *__dst, const char *__src, vm_size_t __len);
484
extern vm_size_t __mig_strncpy (char *__dst, const char *__src, vm_size_t);
486
+#ifdef __USE_EXTERN_INLINES
487
__extern_inline vm_size_t
488
__mig_strncpy (char *__dst, const char *__src, vm_size_t __len)
490
@@ -77,6 +79,7 @@ mig_strncpy (char *__dst, const char *__src, vm_size_t __len)
492
return __mig_strncpy (__dst, __src, __len);
498
diff --git a/mach/spin-lock.c b/mach/spin-lock.c
499
index aaebc55..1b1e69c 100644
500
--- a/mach/spin-lock.c
501
+++ b/mach/spin-lock.c
503
+#define __USE_EXTERN_INLINES 1
504
#define _EXTERN_INLINE /* Empty to define the real functions. */
505
#include "spin-lock.h"
507
diff --git a/sysdeps/generic/machine-lock.h b/sysdeps/generic/machine-lock.h
508
index db9f444..5ecb265 100644
509
--- a/sysdeps/generic/machine-lock.h
510
+++ b/sysdeps/generic/machine-lock.h
511
@@ -35,14 +35,21 @@ typedef volatile int __spin_lock_t;
515
+void __spin_unlock (__spin_lock_t *__lock);
517
+#ifdef __USE_EXTERN_INLINES
519
__spin_unlock (__spin_lock_t *__lock)
525
/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
527
+int __spin_try_lock (__spin_lock_t *__lock);
529
+#ifdef __USE_EXTERN_INLINES
531
__spin_try_lock (__spin_lock_t *__lock)
533
@@ -51,14 +58,19 @@ __spin_try_lock (__spin_lock_t *__lock)
539
/* Return nonzero if LOCK is locked. */
541
+int __spin_lock_locked (__spin_lock_t *__lock);
543
+#ifdef __USE_EXTERN_INLINES
545
__spin_lock_locked (__spin_lock_t *__lock)
552
#endif /* machine-lock.h */
553
diff --git a/sysdeps/generic/machine-sp.h b/sysdeps/generic/machine-sp.h
554
index 25e423e..4769bc5 100644
555
--- a/sysdeps/generic/machine-sp.h
556
+++ b/sysdeps/generic/machine-sp.h
558
#define _EXTERN_INLINE __extern_inline
561
+void * __thread_stack_pointer (void);
563
+#ifdef __USE_EXTERN_INLINES
564
_EXTERN_INLINE void *
565
__thread_stack_pointer (void)
567
register void *__sp__ ("{STACK-POINTER}");
572
#endif /* machine-sp.h */
573
diff --git a/sysdeps/mach/i386/machine-lock.h b/sysdeps/mach/i386/machine-lock.h
574
index 33602f4..b0700d9 100644
575
--- a/sysdeps/mach/i386/machine-lock.h
576
+++ b/sysdeps/mach/i386/machine-lock.h
577
@@ -35,6 +35,9 @@ typedef __volatile int __spin_lock_t;
581
+void __spin_unlock (__spin_lock_t *__lock);
583
+#ifdef __USE_EXTERN_INLINES
585
__spin_unlock (__spin_lock_t *__lock)
587
@@ -43,9 +46,13 @@ __spin_unlock (__spin_lock_t *__lock)
588
: "=&r" (__unlocked), "=m" (*__lock) : "0" (0)
593
/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
595
+int __spin_try_lock (__spin_lock_t *__lock);
597
+#ifdef __USE_EXTERN_INLINES
599
__spin_try_lock (__spin_lock_t *__lock)
601
@@ -55,14 +62,19 @@ __spin_try_lock (__spin_lock_t *__lock)
607
/* Return nonzero if LOCK is locked. */
609
+int __spin_lock_locked (__spin_lock_t *__lock);
611
+#ifdef __USE_EXTERN_INLINES
613
__spin_lock_locked (__spin_lock_t *__lock)
620
#endif /* machine-lock.h */
621
diff --git a/sysdeps/mach/powerpc/machine-lock.h b/sysdeps/mach/powerpc/machine-lock.h
622
index 96af221..b0e228b 100644
623
--- a/sysdeps/mach/powerpc/machine-lock.h
624
+++ b/sysdeps/mach/powerpc/machine-lock.h
625
@@ -35,6 +35,9 @@ typedef __volatile long int __spin_lock_t;
629
+void __spin_unlock (__spin_lock_t *__lock);
631
+#ifdef __USE_EXTERN_INLINES
633
__spin_unlock (__spin_lock_t *__lock)
635
@@ -45,9 +48,13 @@ __spin_unlock (__spin_lock_t *__lock)
637
" : "=&r" (__locked) : "r" (__lock), "r" (0) : "cr0");
641
/* Try to lock LOCK; return nonzero if we locked it, zero if another has. */
643
+int __spin_try_lock (register __spin_lock_t *__lock);
645
+#ifdef __USE_EXTERN_INLINES
647
__spin_try_lock (register __spin_lock_t *__lock)
649
@@ -59,9 +66,13 @@ __spin_try_lock (register __spin_lock_t *__lock)
650
" : "=&r" (__rtn) : "r" (__lock), "r" (1) : "cr0");
655
/* Return nonzero if LOCK is locked. */
657
+int __spin_lock_locked (__spin_lock_t *__lock);
659
+#ifdef __USE_EXTERN_INLINES
661
__spin_lock_locked (__spin_lock_t *__lock)
663
@@ -73,6 +84,7 @@ __spin_lock_locked (__spin_lock_t *__lock)
664
" : "=&r" (__rtn) : "r" (__lock) : "cr0");
670
#endif /* machine-lock.h */
671
diff --git a/sysdeps/mach/powerpc/machine-sp.h b/sysdeps/mach/powerpc/machine-sp.h
672
index 267707b..5885b2a 100644
673
--- a/sysdeps/mach/powerpc/machine-sp.h
674
+++ b/sysdeps/mach/powerpc/machine-sp.h
679
+void * __thread_stack_pointer (void);
681
+#ifdef __USE_EXTERN_INLINES
682
_EXTERN_INLINE void *
683
__thread_stack_pointer (void)
685
@@ -38,5 +41,6 @@ __thread_stack_pointer (void)
686
__asm__ ("mr %0, 1" : "=r" (__sp__));
691
#endif /* machine-sp.h */
692
tg: (0234227..) t/extern_inline (depends on: baseline)