Test of setvbuf with wide streams.
[glibc/history.git] / nptl / pthreadP.h
blobf9634ab0ffac97210688164b7e6acab347d66c96
1 /* Copyright (C) 2002, 2003, 2004, 2005, 2006 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
100 /* Ceiling in __data.__lock. __data.__lock is signed, so don't
101 use the MSB bit in there, but in the mask also include that bit,
102 so that the compiler can optimize & PTHREAD_MUTEX_PRIO_CEILING_MASK
103 masking if the value is then shifted down by
104 PTHREAD_MUTEX_PRIO_CEILING_SHIFT. */
105 #define PTHREAD_MUTEX_PRIO_CEILING_SHIFT 19
106 #define PTHREAD_MUTEX_PRIO_CEILING_MASK 0xfff80000
109 /* Flags in mutex attr. */
110 #define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT 28
111 #define PTHREAD_MUTEXATTR_PROTOCOL_MASK 0x30000000
112 #define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT 12
113 #define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK 0x00fff000
114 #define PTHREAD_MUTEXATTR_FLAG_ROBUST 0x40000000
115 #define PTHREAD_MUTEXATTR_FLAG_PSHARED 0x80000000
116 #define PTHREAD_MUTEXATTR_FLAG_BITS \
117 (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \
118 | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
121 /* Bits used in robust mutex implementation. */
122 #define FUTEX_WAITERS 0x80000000
123 #define FUTEX_OWNER_DIED 0x40000000
124 #define FUTEX_TID_MASK 0x3fffffff
127 /* Internal variables. */
130 /* Default stack size. */
131 extern size_t __default_stacksize attribute_hidden;
133 /* Size and alignment of static TLS block. */
134 extern size_t __static_tls_size attribute_hidden;
135 extern size_t __static_tls_align_m1 attribute_hidden;
137 /* Flag whether the machine is SMP or not. */
138 extern int __is_smp attribute_hidden;
140 /* Thread descriptor handling. */
141 extern list_t __stack_user;
142 hidden_proto (__stack_user)
144 /* Attribute handling. */
145 extern struct pthread_attr *__attr_list attribute_hidden;
146 extern lll_lock_t __attr_list_lock attribute_hidden;
148 /* First available RT signal. */
149 extern int __current_sigrtmin attribute_hidden;
150 /* Last available RT signal. */
151 extern int __current_sigrtmax attribute_hidden;
153 /* Concurrency handling. */
154 extern int __concurrency_level attribute_hidden;
156 /* Thread-local data key handling. */
157 extern struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX];
158 hidden_proto (__pthread_keys)
160 /* Number of threads running. */
161 extern unsigned int __nptl_nthreads attribute_hidden;
163 #ifndef __ASSUME_SET_ROBUST_LIST
164 /* Negative if we do not have the system call and we can use it. */
165 extern int __set_robust_list_avail attribute_hidden;
166 #endif
168 /* Thread Priority Protection. */
169 extern int __sched_fifo_min_prio attribute_hidden;
170 extern int __sched_fifo_max_prio attribute_hidden;
171 extern void __init_sched_fifo_prio (void) attribute_hidden;
172 extern int __pthread_tpp_change_priority (int prev_prio, int new_prio)
173 attribute_hidden;
174 extern int __pthread_current_priority (void) attribute_hidden;
176 /* The library can run in debugging mode where it performs a lot more
177 tests. */
178 extern int __pthread_debug attribute_hidden;
179 /** For now disable debugging support. */
180 #if 0
181 # define DEBUGGING_P __builtin_expect (__pthread_debug, 0)
182 # define INVALID_TD_P(pd) (DEBUGGING_P && __find_in_stack_list (pd) == NULL)
183 # define INVALID_NOT_TERMINATED_TD_P(pd) INVALID_TD_P (pd)
184 #else
185 # define DEBUGGING_P 0
186 /* Simplified test. This will not catch all invalid descriptors but
187 is better than nothing. And if the test triggers the thread
188 descriptor is guaranteed to be invalid. */
189 # define INVALID_TD_P(pd) __builtin_expect ((pd)->tid <= 0, 0)
190 # define INVALID_NOT_TERMINATED_TD_P(pd) __builtin_expect ((pd)->tid < 0, 0)
191 #endif
194 /* Cancellation test. */
195 #define CANCELLATION_P(self) \
196 do { \
197 int cancelhandling = THREAD_GETMEM (self, cancelhandling); \
198 if (CANCEL_ENABLED_AND_CANCELED (cancelhandling)) \
200 THREAD_SETMEM (self, result, PTHREAD_CANCELED); \
201 __do_cancel (); \
203 } while (0)
206 extern void __pthread_unwind (__pthread_unwind_buf_t *__buf)
207 __cleanup_fct_attribute __attribute ((__noreturn__))
208 #if !defined SHARED && !defined IS_IN_libpthread
209 weak_function
210 #endif
212 extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
213 __cleanup_fct_attribute __attribute ((__noreturn__))
214 #ifndef SHARED
215 weak_function
216 #endif
218 extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
219 __cleanup_fct_attribute;
220 extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
221 __cleanup_fct_attribute;
222 #if defined NOT_IN_libc && defined IS_IN_libpthread
223 hidden_proto (__pthread_unwind)
224 hidden_proto (__pthread_unwind_next)
225 hidden_proto (__pthread_register_cancel)
226 hidden_proto (__pthread_unregister_cancel)
227 # ifdef SHARED
228 extern void attribute_hidden pthread_cancel_init (void);
229 # endif
230 #endif
233 /* Called when a thread reacts on a cancellation request. */
234 static inline void
235 __attribute ((noreturn, always_inline))
236 __do_cancel (void)
238 struct pthread *self = THREAD_SELF;
240 /* Make sure we get no more cancellations. */
241 THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT);
243 __pthread_unwind ((__pthread_unwind_buf_t *)
244 THREAD_GETMEM (self, cleanup_jmp_buf));
248 /* Set cancellation mode to asynchronous. */
249 #define CANCEL_ASYNC() \
250 __pthread_enable_asynccancel ()
251 /* Reset to previous cancellation mode. */
252 #define CANCEL_RESET(oldtype) \
253 __pthread_disable_asynccancel (oldtype)
255 #if !defined NOT_IN_libc
256 /* Same as CANCEL_ASYNC, but for use in libc.so. */
257 # define LIBC_CANCEL_ASYNC() \
258 __libc_enable_asynccancel ()
259 /* Same as CANCEL_RESET, but for use in libc.so. */
260 # define LIBC_CANCEL_RESET(oldtype) \
261 __libc_disable_asynccancel (oldtype)
262 # define LIBC_CANCEL_HANDLED() \
263 __asm (".globl " __SYMBOL_PREFIX "__libc_enable_asynccancel"); \
264 __asm (".globl " __SYMBOL_PREFIX "__libc_disable_asynccancel")
265 #elif defined NOT_IN_libc && defined IS_IN_libpthread
266 # define LIBC_CANCEL_ASYNC() CANCEL_ASYNC ()
267 # define LIBC_CANCEL_RESET(val) CANCEL_RESET (val)
268 # define LIBC_CANCEL_HANDLED() \
269 __asm (".globl " __SYMBOL_PREFIX "__pthread_enable_asynccancel"); \
270 __asm (".globl " __SYMBOL_PREFIX "__pthread_disable_asynccancel")
271 #elif defined NOT_IN_libc && defined IS_IN_librt
272 # define LIBC_CANCEL_ASYNC() \
273 __librt_enable_asynccancel ()
274 # define LIBC_CANCEL_RESET(val) \
275 __librt_disable_asynccancel (val)
276 # define LIBC_CANCEL_HANDLED() \
277 __asm (".globl " __SYMBOL_PREFIX "__librt_enable_asynccancel"); \
278 __asm (".globl " __SYMBOL_PREFIX "__librt_disable_asynccancel")
279 #else
280 # define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
281 # define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
282 # define LIBC_CANCEL_HANDLED() /* Nothing. */
283 #endif
285 /* The signal used for asynchronous cancelation. */
286 #define SIGCANCEL __SIGRTMIN
289 /* Signal needed for the kernel-supported POSIX timer implementation.
290 We can reuse the cancellation signal since we can distinguish
291 cancellation from timer expirations. */
292 #define SIGTIMER SIGCANCEL
295 /* Signal used to implement the setuid et.al. functions. */
296 #define SIGSETXID (__SIGRTMIN + 1)
298 /* Used to communicate with signal handler. */
299 extern struct xid_command *__xidcmd attribute_hidden;
302 /* Internal prototypes. */
304 /* Thread list handling. */
305 extern struct pthread *__find_in_stack_list (struct pthread *pd)
306 attribute_hidden internal_function;
308 /* Deallocate a thread's stack after optionally making sure the thread
309 descriptor is still valid. */
310 extern void __free_tcb (struct pthread *pd) attribute_hidden internal_function;
312 /* Free allocated stack. */
313 extern void __deallocate_stack (struct pthread *pd)
314 attribute_hidden internal_function;
316 /* Mark all the stacks except for the current one as available. This
317 function also re-initializes the lock for the stack cache. */
318 extern void __reclaim_stacks (void) attribute_hidden;
320 /* Make all threads's stacks executable. */
321 extern int __make_stacks_executable (void **stack_endp)
322 internal_function attribute_hidden;
324 /* longjmp handling. */
325 extern void __pthread_cleanup_upto (__jmp_buf target, char *targetframe);
326 #if defined NOT_IN_libc && defined IS_IN_libpthread
327 hidden_proto (__pthread_cleanup_upto)
328 #endif
331 /* Functions with versioned interfaces. */
332 extern int __pthread_create_2_1 (pthread_t *newthread,
333 const pthread_attr_t *attr,
334 void *(*start_routine) (void *), void *arg);
335 extern int __pthread_create_2_0 (pthread_t *newthread,
336 const pthread_attr_t *attr,
337 void *(*start_routine) (void *), void *arg);
338 extern int __pthread_attr_init_2_1 (pthread_attr_t *attr);
339 extern int __pthread_attr_init_2_0 (pthread_attr_t *attr);
342 /* Event handlers for libthread_db interface. */
343 extern void __nptl_create_event (void);
344 extern void __nptl_death_event (void);
345 hidden_proto (__nptl_create_event)
346 hidden_proto (__nptl_death_event)
348 /* Register the generation counter in the libpthread with the libc. */
349 #ifdef TLS_MULTIPLE_THREADS_IN_TCB
350 extern void __libc_pthread_init (unsigned long int *ptr,
351 void (*reclaim) (void),
352 const struct pthread_functions *functions)
353 internal_function;
354 #else
355 extern int *__libc_pthread_init (unsigned long int *ptr,
356 void (*reclaim) (void),
357 const struct pthread_functions *functions)
358 internal_function;
360 /* Variable set to a nonzero value if more than one thread runs or ran. */
361 extern int __pthread_multiple_threads attribute_hidden;
362 /* Pointer to the corresponding variable in libc. */
363 extern int *__libc_multiple_threads_ptr attribute_hidden;
364 #endif
366 /* Find a thread given its TID. */
367 extern struct pthread *__find_thread_by_id (pid_t tid) attribute_hidden
368 #ifdef SHARED
370 #else
371 weak_function;
372 #define __find_thread_by_id(tid) \
373 (__find_thread_by_id ? (__find_thread_by_id) (tid) : (struct pthread *) NULL)
374 #endif
376 extern void __pthread_init_static_tls (struct link_map *) attribute_hidden;
379 /* Namespace save aliases. */
380 extern int __pthread_getschedparam (pthread_t thread_id, int *policy,
381 struct sched_param *param);
382 extern int __pthread_setschedparam (pthread_t thread_id, int policy,
383 const struct sched_param *param);
384 extern int __pthread_setcancelstate (int state, int *oldstate);
385 extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
386 __const pthread_mutexattr_t *__mutexattr);
387 extern int __pthread_mutex_init_internal (pthread_mutex_t *__mutex,
388 __const pthread_mutexattr_t *__mutexattr)
389 attribute_hidden;
390 extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
391 extern int __pthread_mutex_destroy_internal (pthread_mutex_t *__mutex)
392 attribute_hidden;
393 extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex);
394 extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
395 extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex)
396 attribute_hidden;
397 extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex)
398 attribute_hidden internal_function;
399 extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
400 extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex)
401 attribute_hidden;
402 extern int __pthread_mutex_unlock_usercnt (pthread_mutex_t *__mutex,
403 int __decr)
404 attribute_hidden internal_function;
405 extern int __pthread_mutexattr_init (pthread_mutexattr_t *attr);
406 extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *attr);
407 extern int __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind);
408 extern int __pthread_attr_destroy (pthread_attr_t *attr);
409 extern int __pthread_attr_getdetachstate (const pthread_attr_t *attr,
410 int *detachstate);
411 extern int __pthread_attr_setdetachstate (pthread_attr_t *attr,
412 int detachstate);
413 extern int __pthread_attr_getinheritsched (const pthread_attr_t *attr,
414 int *inherit);
415 extern int __pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit);
416 extern int __pthread_attr_getschedparam (const pthread_attr_t *attr,
417 struct sched_param *param);
418 extern int __pthread_attr_setschedparam (pthread_attr_t *attr,
419 const struct sched_param *param);
420 extern int __pthread_attr_getschedpolicy (const pthread_attr_t *attr,
421 int *policy);
422 extern int __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy);
423 extern int __pthread_attr_getscope (const pthread_attr_t *attr, int *scope);
424 extern int __pthread_attr_setscope (pthread_attr_t *attr, int scope);
425 extern int __pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
426 __attr, void **__restrict __stackaddr);
427 extern int __pthread_attr_setstackaddr (pthread_attr_t *__attr,
428 void *__stackaddr);
429 extern int __pthread_attr_getstacksize (__const pthread_attr_t *__restrict
430 __attr,
431 size_t *__restrict __stacksize);
432 extern int __pthread_attr_setstacksize (pthread_attr_t *__attr,
433 size_t __stacksize);
434 extern int __pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
435 void **__restrict __stackaddr,
436 size_t *__restrict __stacksize);
437 extern int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
438 size_t __stacksize);
439 extern int __pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
440 __const pthread_rwlockattr_t *__restrict
441 __attr);
442 extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
443 extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
444 extern int __pthread_rwlock_rdlock_internal (pthread_rwlock_t *__rwlock);
445 extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
446 extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
447 extern int __pthread_rwlock_wrlock_internal (pthread_rwlock_t *__rwlock);
448 extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
449 extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
450 extern int __pthread_rwlock_unlock_internal (pthread_rwlock_t *__rwlock);
451 extern int __pthread_cond_broadcast (pthread_cond_t *cond);
452 extern int __pthread_cond_destroy (pthread_cond_t *cond);
453 extern int __pthread_cond_init (pthread_cond_t *cond,
454 const pthread_condattr_t *cond_attr);
455 extern int __pthread_cond_signal (pthread_cond_t *cond);
456 extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex);
457 extern int __pthread_cond_timedwait (pthread_cond_t *cond,
458 pthread_mutex_t *mutex,
459 const struct timespec *abstime);
460 extern int __pthread_condattr_destroy (pthread_condattr_t *attr);
461 extern int __pthread_condattr_init (pthread_condattr_t *attr);
462 extern int __pthread_key_create (pthread_key_t *key, void (*destr) (void *));
463 extern int __pthread_key_create_internal (pthread_key_t *key,
464 void (*destr) (void *));
465 extern void *__pthread_getspecific (pthread_key_t key);
466 extern void *__pthread_getspecific_internal (pthread_key_t key);
467 extern int __pthread_setspecific (pthread_key_t key, const void *value);
468 extern int __pthread_setspecific_internal (pthread_key_t key,
469 const void *value);
470 extern int __pthread_once (pthread_once_t *once_control,
471 void (*init_routine) (void));
472 extern int __pthread_once_internal (pthread_once_t *once_control,
473 void (*init_routine) (void));
474 extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
475 void (*child) (void));
476 extern pthread_t __pthread_self (void);
477 extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
478 extern int __pthread_kill (pthread_t threadid, int signo);
479 extern void __pthread_exit (void *value);
480 extern int __pthread_setcanceltype (int type, int *oldtype);
481 extern int __pthread_enable_asynccancel (void) attribute_hidden;
482 extern void __pthread_disable_asynccancel (int oldtype)
483 internal_function attribute_hidden;
485 extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
486 extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond);
487 extern int __pthread_cond_init_2_0 (pthread_cond_2_0_t *cond,
488 const pthread_condattr_t *cond_attr);
489 extern int __pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond);
490 extern int __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond,
491 pthread_mutex_t *mutex,
492 const struct timespec *abstime);
493 extern int __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond,
494 pthread_mutex_t *mutex);
496 extern int __pthread_getaffinity_np (pthread_t th, size_t cpusetsize,
497 cpu_set_t *cpuset);
499 /* The two functions are in libc.so and not exported. */
500 extern int __libc_enable_asynccancel (void) attribute_hidden;
501 extern void __libc_disable_asynccancel (int oldtype)
502 internal_function attribute_hidden;
505 /* The two functions are in librt.so and not exported. */
506 extern int __librt_enable_asynccancel (void) attribute_hidden;
507 extern void __librt_disable_asynccancel (int oldtype)
508 internal_function attribute_hidden;
510 #ifdef IS_IN_libpthread
511 /* Special versions which use non-exported functions. */
512 extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
513 void (*routine) (void *), void *arg)
514 attribute_hidden;
515 # undef pthread_cleanup_push
516 # define pthread_cleanup_push(routine,arg) \
517 { struct _pthread_cleanup_buffer _buffer; \
518 __pthread_cleanup_push (&_buffer, (routine), (arg));
520 extern void __pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
521 int execute) attribute_hidden;
522 # undef pthread_cleanup_pop
523 # define pthread_cleanup_pop(execute) \
524 __pthread_cleanup_pop (&_buffer, (execute)); }
525 #endif
527 extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
528 void (*routine) (void *), void *arg);
529 extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
530 int execute);
532 /* Old cleanup interfaces, still used in libc.so. */
533 extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
534 void (*routine) (void *), void *arg);
535 extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
536 int execute);
537 extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
538 void (*routine) (void *), void *arg);
539 extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
540 int execute);
542 extern void __nptl_deallocate_tsd (void) attribute_hidden;
544 extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden;
546 extern void __free_stack_cache (void) attribute_hidden;
548 #ifdef SHARED
549 # define PTHREAD_STATIC_FN_REQUIRE(name)
550 #else
551 # define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " #name);
552 #endif
555 #ifndef __NR_set_robust_list
556 /* XXX For the time being... Once we can rely on the kernel headers
557 having the definition remove these lines. */
558 # if defined __i386__
559 # define __NR_set_robust_list 311
560 # elif defined __x86_64__
561 # define __NR_set_robust_list 273
562 # endif
563 #endif
565 #endif /* pthreadP.h */