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