OSDN Git Service

drop support for pre ISO-C compilers
[uclinux-h8/uClibc.git] / libpthread / nptl / pthreadP.h
1 /* Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <http://www.gnu.org/licenses/>.  */
18
19 #ifndef _PTHREADP_H
20 #define _PTHREADP_H     1
21
22 #include <pthread.h>
23 #include <setjmp.h>
24 #include <stdbool.h>
25 #include <sys/syscall.h>
26 #include "descr.h"
27 #include <tls.h>
28 #include <lowlevellock.h>
29 #include <bits/stackinfo.h>
30 #include <internaltypes.h>
31 #include <pthread-functions.h>
32 #include <atomic.h>
33 #include <bits/kernel-features.h>
34
35
36 /* Atomic operations on TLS memory.  */
37 #ifndef THREAD_ATOMIC_CMPXCHG_VAL
38 # define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, new, old) \
39   atomic_compare_and_exchange_val_acq (&(descr)->member, new, old)
40 #endif
41
42 #ifndef THREAD_ATOMIC_BIT_SET
43 # define THREAD_ATOMIC_BIT_SET(descr, member, bit) \
44   atomic_bit_set (&(descr)->member, bit)
45 #endif
46
47
48 /* Adaptive mutex definitions.  */
49 #ifndef MAX_ADAPTIVE_COUNT
50 # define MAX_ADAPTIVE_COUNT 100
51 #endif
52
53
54 /* Magic cookie representing robust mutex with dead owner.  */
55 #define PTHREAD_MUTEX_INCONSISTENT      INT_MAX
56 /* Magic cookie representing not recoverable robust mutex.  */
57 #define PTHREAD_MUTEX_NOTRECOVERABLE    (INT_MAX - 1)
58
59
60 /* Internal mutex type value.  */
61 enum
62 {
63   PTHREAD_MUTEX_KIND_MASK_NP = 3,
64   PTHREAD_MUTEX_ROBUST_NORMAL_NP = 16,
65   PTHREAD_MUTEX_ROBUST_RECURSIVE_NP
66   = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_RECURSIVE_NP,
67   PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP
68   = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
69   PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP
70   = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ADAPTIVE_NP,
71   PTHREAD_MUTEX_PRIO_INHERIT_NP = 32,
72   PTHREAD_MUTEX_PI_NORMAL_NP
73   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_NORMAL,
74   PTHREAD_MUTEX_PI_RECURSIVE_NP
75   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_RECURSIVE_NP,
76   PTHREAD_MUTEX_PI_ERRORCHECK_NP
77   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
78   PTHREAD_MUTEX_PI_ADAPTIVE_NP
79   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ADAPTIVE_NP,
80   PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP
81   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NORMAL_NP,
82   PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP
83   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_RECURSIVE_NP,
84   PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP
85   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP,
86   PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP
87   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP,
88   PTHREAD_MUTEX_PRIO_PROTECT_NP = 64,
89   PTHREAD_MUTEX_PP_NORMAL_NP
90   = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_NORMAL,
91   PTHREAD_MUTEX_PP_RECURSIVE_NP
92   = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_RECURSIVE_NP,
93   PTHREAD_MUTEX_PP_ERRORCHECK_NP
94   = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
95   PTHREAD_MUTEX_PP_ADAPTIVE_NP
96   = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ADAPTIVE_NP
97 };
98 #define PTHREAD_MUTEX_PSHARED_BIT 128
99
100 #define PTHREAD_MUTEX_TYPE(m) \
101   ((m)->__data.__kind & 127)
102
103 #if LLL_PRIVATE == 0 && LLL_SHARED == 128
104 # define PTHREAD_MUTEX_PSHARED(m) \
105   ((m)->__data.__kind & 128)
106 #else
107 # define PTHREAD_MUTEX_PSHARED(m) \
108   (((m)->__data.__kind & 128) ? LLL_SHARED : LLL_PRIVATE)
109 #endif
110
111 /* The kernel when waking robust mutexes on exit never uses
112    FUTEX_PRIVATE_FLAG FUTEX_WAKE.  */
113 #define PTHREAD_ROBUST_MUTEX_PSHARED(m) LLL_SHARED
114
115 /* Ceiling in __data.__lock.  __data.__lock is signed, so don't
116    use the MSB bit in there, but in the mask also include that bit,
117    so that the compiler can optimize & PTHREAD_MUTEX_PRIO_CEILING_MASK
118    masking if the value is then shifted down by
119    PTHREAD_MUTEX_PRIO_CEILING_SHIFT.  */
120 #define PTHREAD_MUTEX_PRIO_CEILING_SHIFT        19
121 #define PTHREAD_MUTEX_PRIO_CEILING_MASK         0xfff80000
122
123
124 /* Flags in mutex attr.  */
125 #define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT        28
126 #define PTHREAD_MUTEXATTR_PROTOCOL_MASK         0x30000000
127 #define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT    12
128 #define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK     0x00fff000
129 #define PTHREAD_MUTEXATTR_FLAG_ROBUST           0x40000000
130 #define PTHREAD_MUTEXATTR_FLAG_PSHARED          0x80000000
131 #define PTHREAD_MUTEXATTR_FLAG_BITS \
132   (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \
133    | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
134
135
136 /* Check whether rwlock prefers readers.   */
137 #define PTHREAD_RWLOCK_PREFER_READER_P(rwlock) \
138   ((rwlock)->__data.__flags == 0)
139
140
141 /* Bits used in robust mutex implementation.  */
142 #define FUTEX_WAITERS           0x80000000
143 #define FUTEX_OWNER_DIED        0x40000000
144 #define FUTEX_TID_MASK          0x3fffffff
145
146
147 /* Internal variables.  */
148
149
150 /* Default stack size.  */
151 extern size_t __default_stacksize attribute_hidden;
152
153 /* Size and alignment of static TLS block.  */
154 extern size_t __static_tls_size attribute_hidden;
155 extern size_t __static_tls_align_m1 attribute_hidden;
156
157 /* Flag whether the machine is SMP or not.  */
158 extern int __is_smp attribute_hidden;
159
160 /* Thread descriptor handling.  */
161 extern list_t __stack_user;
162 hidden_proto (__stack_user)
163
164 /* Attribute handling.  */
165 extern struct pthread_attr *__attr_list attribute_hidden;
166 extern int __attr_list_lock attribute_hidden;
167
168 /* First available RT signal.  */
169 extern int __current_sigrtmin attribute_hidden;
170 /* Last available RT signal.  */
171 extern int __current_sigrtmax attribute_hidden;
172
173 /* Concurrency handling.  */
174 extern int __concurrency_level attribute_hidden;
175
176 /* Thread-local data key handling.  */
177 extern struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX];
178 hidden_proto (__pthread_keys)
179
180 /* Number of threads running.  */
181 extern unsigned int __nptl_nthreads
182 #ifdef SHARED
183         attribute_hidden
184 #else
185         __attribute ((weak))
186 #endif
187         ;
188
189 #ifndef __ASSUME_SET_ROBUST_LIST
190 /* Negative if we do not have the system call and we can use it.  */
191 extern int __set_robust_list_avail attribute_hidden;
192 #endif
193
194 /* Thread Priority Protection.  */
195 extern int __sched_fifo_min_prio attribute_hidden;
196 extern int __sched_fifo_max_prio attribute_hidden;
197 extern void __init_sched_fifo_prio (void) attribute_hidden;
198 extern int __pthread_tpp_change_priority (int prev_prio, int new_prio)
199      attribute_hidden;
200 extern int __pthread_current_priority (void) attribute_hidden;
201
202 /* The library can run in debugging mode where it performs a lot more
203    tests.  */
204 extern int __pthread_debug attribute_hidden;
205 /** For now disable debugging support.  */
206 #if 0
207 # define DEBUGGING_P __builtin_expect (__pthread_debug, 0)
208 # define INVALID_TD_P(pd) (DEBUGGING_P && __find_in_stack_list (pd) == NULL)
209 # define INVALID_NOT_TERMINATED_TD_P(pd) INVALID_TD_P (pd)
210 #else
211 # define DEBUGGING_P 0
212 /* Simplified test.  This will not catch all invalid descriptors but
213    is better than nothing.  And if the test triggers the thread
214    descriptor is guaranteed to be invalid.  */
215 # define INVALID_TD_P(pd) __builtin_expect ((pd)->tid <= 0, 0)
216 # define INVALID_NOT_TERMINATED_TD_P(pd) __builtin_expect ((pd)->tid < 0, 0)
217 #endif
218
219
220 /* Cancellation test.  */
221 #define CANCELLATION_P(self) \
222   do {                                                                        \
223     cancelhandling = THREAD_GETMEM (self, cancelhandling);                    \
224     if (CANCEL_ENABLED_AND_CANCELED (cancelhandling))                         \
225       {                                                                       \
226         THREAD_SETMEM (self, result, PTHREAD_CANCELED);                       \
227         __do_cancel ();                                                       \
228       }                                                                       \
229   } while (0)
230
231
232 extern void __pthread_unwind (__pthread_unwind_buf_t *__buf)
233      __cleanup_fct_attribute __attribute ((__noreturn__))
234 #if !defined SHARED && !defined IS_IN_libpthread
235      weak_function
236 #endif
237      ;
238 extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
239      __cleanup_fct_attribute __attribute ((__noreturn__))
240 #ifndef SHARED
241      weak_function
242 #endif
243      ;
244 extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
245      __cleanup_fct_attribute;
246 extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
247      __cleanup_fct_attribute;
248 #if defined NOT_IN_libc && defined IS_IN_libpthread
249 hidden_proto (__pthread_unwind)
250 hidden_proto (__pthread_unwind_next)
251 hidden_proto (__pthread_register_cancel)
252 hidden_proto (__pthread_unregister_cancel)
253 # ifdef SHARED
254 extern void attribute_hidden pthread_cancel_init (void);
255 extern void __unwind_freeres (void);
256 # endif
257 #endif
258
259
260 /* Called when a thread reacts on a cancellation request.  */
261 static inline void
262 __attribute ((noreturn, always_inline))
263 __do_cancel (void)
264 {
265   struct pthread *self = THREAD_SELF;
266
267   /* Make sure we get no more cancellations.  */
268   THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT);
269
270   __pthread_unwind ((__pthread_unwind_buf_t *)
271                     THREAD_GETMEM (self, cleanup_jmp_buf));
272 }
273
274
275 /* Set cancellation mode to asynchronous.  */
276 #define CANCEL_ASYNC() \
277   __pthread_enable_asynccancel ()
278 /* Reset to previous cancellation mode.  */
279 #define CANCEL_RESET(oldtype) \
280   __pthread_disable_asynccancel (oldtype)
281
282 #define __LABEL_PREFIX__ __stringify(__USER_LABEL_PREFIX__)
283
284 #if !defined NOT_IN_libc
285 /* Same as CANCEL_ASYNC, but for use in libc.so.  */
286 # define LIBC_CANCEL_ASYNC() \
287   __libc_enable_asynccancel ()
288 /* Same as CANCEL_RESET, but for use in libc.so.  */
289 # define LIBC_CANCEL_RESET(oldtype) \
290   __libc_disable_asynccancel (oldtype)
291 # define LIBC_CANCEL_HANDLED() \
292   __asm__ (".globl " __LABEL_PREFIX__ "__libc_enable_asynccancel"); \
293   __asm__ (".globl " __LABEL_PREFIX__ "__libc_disable_asynccancel")
294 #elif defined NOT_IN_libc && defined IS_IN_libpthread
295 # define LIBC_CANCEL_ASYNC() CANCEL_ASYNC ()
296 # define LIBC_CANCEL_RESET(val) CANCEL_RESET (val)
297 # define LIBC_CANCEL_HANDLED() \
298   __asm__ (".globl " __LABEL_PREFIX__ "__pthread_enable_asynccancel"); \
299   __asm__ (".globl " __LABEL_PREFIX__ "__pthread_disable_asynccancel")
300 #elif defined NOT_IN_libc && defined IS_IN_librt
301 # define LIBC_CANCEL_ASYNC() \
302   __librt_enable_asynccancel ()
303 # define LIBC_CANCEL_RESET(val) \
304   __librt_disable_asynccancel (val)
305 # define LIBC_CANCEL_HANDLED() \
306   __asm__ (".globl " __LABEL_PREFIX__ "__librt_enable_asynccancel"); \
307   __asm__ (".globl " __LABEL_PREFIX__ "__librt_disable_asynccancel")
308 #else
309 # define LIBC_CANCEL_ASYNC()    0 /* Just a dummy value.  */
310 # define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it.  */
311 # define LIBC_CANCEL_HANDLED()  /* Nothing.  */
312 #endif
313
314 /* The signal used for asynchronous cancellation.  */
315 #define SIGCANCEL       __SIGRTMIN
316
317
318 /* Signal needed for the kernel-supported POSIX timer implementation.
319    We can reuse the cancellation signal since we can distinguish
320    cancellation from timer expirations.  */
321 #define SIGTIMER        SIGCANCEL
322
323
324 /* Signal used to implement the setuid et.al. functions.  */
325 #define SIGSETXID       (__SIGRTMIN + 1)
326
327 /* Used to communicate with signal handler.  */
328 extern struct xid_command *__xidcmd attribute_hidden;
329
330
331 /* Internal prototypes.  */
332
333 /* Thread list handling.  */
334 extern struct pthread *__find_in_stack_list (struct pthread *pd)
335      attribute_hidden internal_function;
336
337 /* Deallocate a thread's stack after optionally making sure the thread
338    descriptor is still valid.  */
339 extern void __free_tcb (struct pthread *pd) attribute_hidden internal_function;
340
341 /* Free allocated stack.  */
342 extern void __deallocate_stack (struct pthread *pd)
343      attribute_hidden internal_function;
344
345 /* Mark all the stacks except for the current one as available.  This
346    function also re-initializes the lock for the stack cache.  */
347 extern void __reclaim_stacks (void) attribute_hidden;
348
349 /* Make all threads's stacks executable.  */
350 extern int __make_stacks_executable (void **stack_endp)
351      internal_function attribute_hidden;
352
353 /* longjmp handling.  */
354 extern void __pthread_cleanup_upto (__jmp_buf target, char *targetframe);
355 #if defined NOT_IN_libc && defined IS_IN_libpthread
356 hidden_proto (__pthread_cleanup_upto)
357 #endif
358
359
360 /* Functions with versioned interfaces.  */
361 extern int __pthread_create_2_1 (pthread_t *newthread,
362                                  const pthread_attr_t *attr,
363                                  void *(*start_routine) (void *), void *arg);
364 extern int __pthread_create_2_0 (pthread_t *newthread,
365                                  const pthread_attr_t *attr,
366                                  void *(*start_routine) (void *), void *arg);
367 extern int __pthread_attr_init_2_1 (pthread_attr_t *attr);
368 extern int __pthread_attr_init_2_0 (pthread_attr_t *attr);
369
370
371 /* Event handlers for libthread_db interface.  */
372 extern void __nptl_create_event (void);
373 extern void __nptl_death_event (void);
374 hidden_proto (__nptl_create_event)
375 hidden_proto (__nptl_death_event)
376
377 /* Register the generation counter in the libpthread with the libc.  */
378 #ifdef TLS_MULTIPLE_THREADS_IN_TCB
379 extern void __libc_pthread_init (unsigned long int *ptr,
380                                  void (*reclaim) (void),
381                                  const struct pthread_functions *functions);
382 #else
383 extern int *__libc_pthread_init (unsigned long int *ptr,
384                                  void (*reclaim) (void),
385                                  const struct pthread_functions *functions);
386
387 /* Variable set to a nonzero value if more than one thread runs or ran.  */
388 extern int __pthread_multiple_threads attribute_hidden;
389 /* Pointer to the corresponding variable in libc.  */
390 extern int *__libc_multiple_threads_ptr attribute_hidden;
391 #endif
392
393 /* Find a thread given its TID.  */
394 extern struct pthread *__find_thread_by_id (pid_t tid) attribute_hidden
395 #ifdef SHARED
396 ;
397 #else
398 weak_function;
399 #define __find_thread_by_id(tid) \
400   (__find_thread_by_id ? (__find_thread_by_id) (tid) : (struct pthread *) NULL)
401 #endif
402
403 extern void __pthread_init_static_tls (struct link_map *) attribute_hidden;
404
405
406 /* Namespace save aliases.  */
407 extern int __pthread_getschedparam (pthread_t thread_id, int *policy,
408                                     struct sched_param *param);
409 extern int __pthread_setschedparam (pthread_t thread_id, int policy,
410                                     const struct sched_param *param);
411 extern int __pthread_setcancelstate (int state, int *oldstate);
412 extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
413                                  const pthread_mutexattr_t *__mutexattr);
414 extern int __pthread_mutex_init_internal (pthread_mutex_t *__mutex,
415                                           const pthread_mutexattr_t *__mutexattr)
416      attribute_hidden;
417 extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
418 extern int __pthread_mutex_destroy_internal (pthread_mutex_t *__mutex)
419      attribute_hidden;
420 extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex);
421 extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
422 extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex)
423      attribute_hidden;
424 extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex)
425      attribute_hidden internal_function;
426 extern void __pthread_mutex_cond_lock_adjust (pthread_mutex_t *__mutex)
427      attribute_hidden internal_function;
428 extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
429 extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex)
430      attribute_hidden;
431 extern int __pthread_mutex_unlock_usercnt (pthread_mutex_t *__mutex,
432                                            int __decr)
433      attribute_hidden internal_function;
434 extern int __pthread_mutexattr_init (pthread_mutexattr_t *attr);
435 extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *attr);
436 extern int __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind);
437 extern int __pthread_attr_destroy (pthread_attr_t *attr);
438 extern int __pthread_attr_getdetachstate (const pthread_attr_t *attr,
439                                           int *detachstate);
440 extern int __pthread_attr_setdetachstate (pthread_attr_t *attr,
441                                           int detachstate);
442 extern int __pthread_attr_getinheritsched (const pthread_attr_t *attr,
443                                            int *inherit);
444 extern int __pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit);
445 extern int __pthread_attr_getschedparam (const pthread_attr_t *attr,
446                                          struct sched_param *param);
447 extern int __pthread_attr_setschedparam (pthread_attr_t *attr,
448                                          const struct sched_param *param);
449 extern int __pthread_attr_getschedpolicy (const pthread_attr_t *attr,
450                                           int *policy);
451 extern int __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy);
452 extern int __pthread_attr_getscope (const pthread_attr_t *attr, int *scope);
453 extern int __pthread_attr_setscope (pthread_attr_t *attr, int scope);
454 extern int __pthread_attr_getstackaddr (const pthread_attr_t *__restrict
455                                         __attr, void **__restrict __stackaddr);
456 extern int __pthread_attr_setstackaddr (pthread_attr_t *__attr,
457                                         void *__stackaddr);
458 extern int __pthread_attr_getstacksize (const pthread_attr_t *__restrict
459                                         __attr,
460                                         size_t *__restrict __stacksize);
461 extern int __pthread_attr_setstacksize (pthread_attr_t *__attr,
462                                         size_t __stacksize);
463 extern int __pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
464                                     void **__restrict __stackaddr,
465                                     size_t *__restrict __stacksize);
466 extern int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
467                                     size_t __stacksize);
468 extern int __pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
469                                   const pthread_rwlockattr_t *__restrict
470                                   __attr);
471 extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
472 extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
473 extern int __pthread_rwlock_rdlock_internal (pthread_rwlock_t *__rwlock);
474 extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
475 extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
476 extern int __pthread_rwlock_wrlock_internal (pthread_rwlock_t *__rwlock);
477 extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
478 extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
479 extern int __pthread_rwlock_unlock_internal (pthread_rwlock_t *__rwlock);
480 extern int __pthread_cond_broadcast (pthread_cond_t *cond);
481 extern int __pthread_cond_destroy (pthread_cond_t *cond);
482 extern int __pthread_cond_init (pthread_cond_t *cond,
483                                 const pthread_condattr_t *cond_attr);
484 extern int __pthread_cond_signal (pthread_cond_t *cond);
485 extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex);
486 extern int __pthread_cond_timedwait (pthread_cond_t *cond,
487                                      pthread_mutex_t *mutex,
488                                      const struct timespec *abstime);
489 extern int __pthread_condattr_destroy (pthread_condattr_t *attr);
490 extern int __pthread_condattr_init (pthread_condattr_t *attr);
491 extern int __pthread_key_create (pthread_key_t *key, void (*destr) (void *));
492 extern int __pthread_key_create_internal (pthread_key_t *key,
493                                           void (*destr) (void *));
494 extern void *__pthread_getspecific (pthread_key_t key);
495 extern void *__pthread_getspecific_internal (pthread_key_t key);
496 extern int __pthread_setspecific (pthread_key_t key, const void *value);
497 extern int __pthread_setspecific_internal (pthread_key_t key,
498                                            const void *value);
499 extern int __pthread_once (pthread_once_t *once_control,
500                            void (*init_routine) (void));
501 extern int __pthread_once_internal (pthread_once_t *once_control,
502                                     void (*init_routine) (void));
503 extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
504                              void (*child) (void));
505 extern pthread_t __pthread_self (void);
506 extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
507 extern int __pthread_kill (pthread_t threadid, int signo);
508 extern void __pthread_exit (void *value);
509 extern int __pthread_setcanceltype (int type, int *oldtype);
510 extern int __pthread_enable_asynccancel (void) attribute_hidden;
511 extern void __pthread_disable_asynccancel (int oldtype)
512      internal_function attribute_hidden;
513
514 extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
515 extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond);
516 extern int __pthread_cond_init_2_0 (pthread_cond_2_0_t *cond,
517                                     const pthread_condattr_t *cond_attr);
518 extern int __pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond);
519 extern int __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond,
520                                          pthread_mutex_t *mutex,
521                                          const struct timespec *abstime);
522 extern int __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond,
523                                     pthread_mutex_t *mutex);
524
525 extern int __pthread_getaffinity_np (pthread_t th, size_t cpusetsize,
526                                      cpu_set_t *cpuset);
527
528 /* The two functions are in libc.so and not exported.  */
529 extern int __libc_enable_asynccancel (void) attribute_hidden;
530 extern void __libc_disable_asynccancel (int oldtype)
531      internal_function attribute_hidden;
532
533
534 /* The two functions are in librt.so and not exported.  */
535 extern int __librt_enable_asynccancel (void) attribute_hidden;
536 extern void __librt_disable_asynccancel (int oldtype)
537      internal_function attribute_hidden;
538
539 #ifdef IS_IN_libpthread
540 /* Special versions which use non-exported functions.  */
541 extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
542                                     void (*routine) (void *), void *arg)
543      attribute_hidden;
544 # undef pthread_cleanup_push
545 # define pthread_cleanup_push(routine,arg) \
546   { struct _pthread_cleanup_buffer _buffer;                                   \
547     __pthread_cleanup_push (&_buffer, (routine), (arg));
548
549 extern void __pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
550                                    int execute) attribute_hidden;
551 # undef pthread_cleanup_pop
552 # define pthread_cleanup_pop(execute) \
553     __pthread_cleanup_pop (&_buffer, (execute)); }
554 #endif
555
556 extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
557                                           void (*routine) (void *), void *arg);
558 extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
559                                            int execute);
560
561 /* Old cleanup interfaces, still used in libc.so.  */
562 extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
563                                    void (*routine) (void *), void *arg);
564 extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
565                                   int execute);
566 extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
567                                          void (*routine) (void *), void *arg);
568 extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
569                                           int execute);
570
571 extern void __nptl_deallocate_tsd (void)
572 #ifdef SHARED
573         attribute_hidden
574 #else
575         __attribute ((weak))
576 #endif
577         ;
578
579 extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden;
580
581 extern void __free_stacks (size_t limit) attribute_hidden;
582
583 extern void __wait_lookup_done (void) attribute_hidden;
584
585 #ifdef SHARED
586 # define PTHREAD_STATIC_FN_REQUIRE(name)
587 #else
588 # define PTHREAD_STATIC_FN_REQUIRE(name) __asm__ (".globl " #name);
589 #endif
590
591
592 #ifndef __NR_set_robust_list
593 /* XXX For the time being...  Once we can rely on the kernel headers
594    having the definition remove these lines.  */
595 # if defined __i386__
596 #  define __NR_set_robust_list  311
597 # elif defined __x86_64__
598 #  define __NR_set_robust_list  273
599 # endif
600 #endif
601
602 #endif  /* pthreadP.h */