]> git.ipfire.org Git - thirdparty/glibc.git/blame - nptl/pthreadP.h
Make sure RES_USE_INET6 is always restored
[thirdparty/glibc.git] / nptl / pthreadP.h
CommitLineData
cca50323 1/* Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
76a50749
UD
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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20#ifndef _PTHREADP_H
21#define _PTHREADP_H 1
22
23#include <pthread.h>
24#include <setjmp.h>
b758b9cb 25#include <stdbool.h>
76a50749
UD
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>
73e9ae88 32#include <pthread-functions.h>
86246935 33#include <atomic.h>
0f6699ea 34#include <kernel-features.h>
76a50749
UD
35
36
a1b5424f
UD
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
42
43#ifndef THREAD_ATOMIC_BIT_SET
44# define THREAD_ATOMIC_BIT_SET(descr, member, bit) \
45 atomic_bit_set (&(descr)->member, bit)
46#endif
47
48
2c0b891a
UD
49/* Adaptive mutex definitions. */
50#ifndef MAX_ADAPTIVE_COUNT
51# define MAX_ADAPTIVE_COUNT 100
52#endif
53
54
1bcfb5a5 55/* Magic cookie representing robust mutex with dead owner. */
683040c3 56#define PTHREAD_MUTEX_INCONSISTENT INT_MAX
1bcfb5a5
UD
57/* Magic cookie representing not recoverable robust mutex. */
58#define PTHREAD_MUTEX_NOTRECOVERABLE (INT_MAX - 1)
59
60
61/* Internal mutex type value. */
62enum
63{
df47504c 64 PTHREAD_MUTEX_KIND_MASK_NP = 3,
0f6699ea
UD
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,
df47504c
UD
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,
f17efcb4
UD
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
1bcfb5a5 98};
5bd8a249 99#define PTHREAD_MUTEX_PSHARED_BIT 128
f17efcb4 100
ae1ad3ae 101#define PTHREAD_MUTEX_TYPE(m) \
5bd8a249
UD
102 ((m)->__data.__kind & 127)
103
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
111
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
ae1ad3ae 115
f17efcb4
UD
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
1bcfb5a5
UD
123
124
125/* Flags in mutex attr. */
a5f2bd86
RM
126#define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT 28
127#define PTHREAD_MUTEXATTR_PROTOCOL_MASK 0x30000000
f17efcb4
UD
128#define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT 12
129#define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK 0x00fff000
a5f2bd86
RM
130#define PTHREAD_MUTEXATTR_FLAG_ROBUST 0x40000000
131#define PTHREAD_MUTEXATTR_FLAG_PSHARED 0x80000000
1bcfb5a5 132#define PTHREAD_MUTEXATTR_FLAG_BITS \
a5f2bd86
RM
133 (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \
134 | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
1bcfb5a5
UD
135
136
546346b6
UD
137/* Check whether rwlock prefers readers. */
138#define PTHREAD_RWLOCK_PREFER_READER_P(rwlock) \
139 ((rwlock)->__data.__flags == 0)
140
141
683040c3
UD
142/* Bits used in robust mutex implementation. */
143#define FUTEX_WAITERS 0x80000000
144#define FUTEX_OWNER_DIED 0x40000000
2035d91c 145#define FUTEX_TID_MASK 0x3fffffff
683040c3
UD
146
147
76a50749
UD
148/* Internal variables. */
149
150
151/* Default stack size. */
152extern size_t __default_stacksize attribute_hidden;
153
154/* Size and alignment of static TLS block. */
155extern size_t __static_tls_size attribute_hidden;
bc6389ad 156extern size_t __static_tls_align_m1 attribute_hidden;
76a50749 157
2c0b891a
UD
158/* Flag whether the machine is SMP or not. */
159extern int __is_smp attribute_hidden;
160
76a50749 161/* Thread descriptor handling. */
fa9a4ff0
RM
162extern list_t __stack_user;
163hidden_proto (__stack_user)
76a50749
UD
164
165/* Attribute handling. */
166extern struct pthread_attr *__attr_list attribute_hidden;
e51deae7 167extern int __attr_list_lock attribute_hidden;
76a50749
UD
168
169/* First available RT signal. */
170extern int __current_sigrtmin attribute_hidden;
171/* Last available RT signal. */
172extern int __current_sigrtmax attribute_hidden;
173
174/* Concurrency handling. */
175extern int __concurrency_level attribute_hidden;
176
177/* Thread-local data key handling. */
fa9a4ff0
RM
178extern struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX];
179hidden_proto (__pthread_keys)
76a50749 180
47202270
UD
181/* Number of threads running. */
182extern unsigned int __nptl_nthreads attribute_hidden;
183
0f6699ea
UD
184#ifndef __ASSUME_SET_ROBUST_LIST
185/* Negative if we do not have the system call and we can use it. */
186extern int __set_robust_list_avail attribute_hidden;
187#endif
188
f17efcb4
UD
189/* Thread Priority Protection. */
190extern int __sched_fifo_min_prio attribute_hidden;
191extern int __sched_fifo_max_prio attribute_hidden;
192extern void __init_sched_fifo_prio (void) attribute_hidden;
193extern int __pthread_tpp_change_priority (int prev_prio, int new_prio)
194 attribute_hidden;
195extern int __pthread_current_priority (void) attribute_hidden;
196
76a50749
UD
197/* The library can run in debugging mode where it performs a lot more
198 tests. */
199extern int __pthread_debug attribute_hidden;
729924a0
UD
200/** For now disable debugging support. */
201#if 0
202# define DEBUGGING_P __builtin_expect (__pthread_debug, 0)
8c2e9a29
UD
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)
729924a0
UD
205#else
206# define DEBUGGING_P 0
8c2e9a29
UD
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)
729924a0 212#endif
76a50749
UD
213
214
215/* Cancellation test. */
216#define CANCELLATION_P(self) \
217 do { \
218 int cancelhandling = THREAD_GETMEM (self, cancelhandling); \
219 if (CANCEL_ENABLED_AND_CANCELED (cancelhandling)) \
220 { \
221 THREAD_SETMEM (self, result, PTHREAD_CANCELED); \
9ae0909b 222 __do_cancel (); \
76a50749
UD
223 } \
224 } while (0)
225
6efd4814
UD
226
227extern void __pthread_unwind (__pthread_unwind_buf_t *__buf)
228 __cleanup_fct_attribute __attribute ((__noreturn__))
8b965f3d 229#if !defined SHARED && !defined IS_IN_libpthread
6efd4814
UD
230 weak_function
231#endif
232 ;
da0c02ee
UD
233extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
234 __cleanup_fct_attribute __attribute ((__noreturn__))
235#ifndef SHARED
236 weak_function
237#endif
238 ;
239extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
240 __cleanup_fct_attribute;
241extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
242 __cleanup_fct_attribute;
56421b23
UD
243#if defined NOT_IN_libc && defined IS_IN_libpthread
244hidden_proto (__pthread_unwind)
da0c02ee
UD
245hidden_proto (__pthread_unwind_next)
246hidden_proto (__pthread_register_cancel)
247hidden_proto (__pthread_unregister_cancel)
9d79e037
UD
248# ifdef SHARED
249extern void attribute_hidden pthread_cancel_init (void);
cca50323 250extern void __unwind_freeres (void);
9d79e037 251# endif
56421b23
UD
252#endif
253
6efd4814
UD
254
255/* Called when a thread reacts on a cancellation request. */
256static inline void
dd9423a6 257__attribute ((noreturn, always_inline))
6efd4814
UD
258__do_cancel (void)
259{
260 struct pthread *self = THREAD_SELF;
261
262 /* Make sure we get no more cancellations. */
263 THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT);
264
265 __pthread_unwind ((__pthread_unwind_buf_t *)
266 THREAD_GETMEM (self, cleanup_jmp_buf));
267}
268
269
76a50749 270/* Set cancellation mode to asynchronous. */
bdb04f92
UD
271#define CANCEL_ASYNC() \
272 __pthread_enable_asynccancel ()
76a50749
UD
273/* Reset to previous cancellation mode. */
274#define CANCEL_RESET(oldtype) \
bdb04f92 275 __pthread_disable_asynccancel (oldtype)
76a50749 276
9634cf9d 277#if !defined NOT_IN_libc
9ae0909b 278/* Same as CANCEL_ASYNC, but for use in libc.so. */
9634cf9d 279# define LIBC_CANCEL_ASYNC() \
9ae0909b
UD
280 __libc_enable_asynccancel ()
281/* Same as CANCEL_RESET, but for use in libc.so. */
9634cf9d 282# define LIBC_CANCEL_RESET(oldtype) \
9ae0909b 283 __libc_disable_asynccancel (oldtype)
52f3d213
UD
284# define LIBC_CANCEL_HANDLED() \
285 __asm (".globl " __SYMBOL_PREFIX "__libc_enable_asynccancel"); \
286 __asm (".globl " __SYMBOL_PREFIX "__libc_disable_asynccancel")
9634cf9d
UD
287#elif defined NOT_IN_libc && defined IS_IN_libpthread
288# define LIBC_CANCEL_ASYNC() CANCEL_ASYNC ()
289# define LIBC_CANCEL_RESET(val) CANCEL_RESET (val)
52f3d213
UD
290# define LIBC_CANCEL_HANDLED() \
291 __asm (".globl " __SYMBOL_PREFIX "__pthread_enable_asynccancel"); \
292 __asm (".globl " __SYMBOL_PREFIX "__pthread_disable_asynccancel")
1fde494e
UD
293#elif defined NOT_IN_libc && defined IS_IN_librt
294# define LIBC_CANCEL_ASYNC() \
295 __librt_enable_asynccancel ()
296# define LIBC_CANCEL_RESET(val) \
297 __librt_disable_asynccancel (val)
298# define LIBC_CANCEL_HANDLED() \
299 __asm (".globl " __SYMBOL_PREFIX "__librt_enable_asynccancel"); \
300 __asm (".globl " __SYMBOL_PREFIX "__librt_disable_asynccancel")
9634cf9d
UD
301#else
302# define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
303# define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
52f3d213 304# define LIBC_CANCEL_HANDLED() /* Nothing. */
9634cf9d 305#endif
9ae0909b 306
2a9ae45c
UD
307/* The signal used for asynchronous cancelation. */
308#define SIGCANCEL __SIGRTMIN
309
310
e7608d77
UD
311/* Signal needed for the kernel-supported POSIX timer implementation.
312 We can reuse the cancellation signal since we can distinguish
313 cancellation from timer expirations. */
314#define SIGTIMER SIGCANCEL
2a9ae45c 315
9ae0909b 316
2edb61e3
UD
317/* Signal used to implement the setuid et.al. functions. */
318#define SIGSETXID (__SIGRTMIN + 1)
319
320/* Used to communicate with signal handler. */
321extern struct xid_command *__xidcmd attribute_hidden;
322
323
76a50749
UD
324/* Internal prototypes. */
325
326/* Thread list handling. */
327extern struct pthread *__find_in_stack_list (struct pthread *pd)
90491dc4 328 attribute_hidden internal_function;
76a50749
UD
329
330/* Deallocate a thread's stack after optionally making sure the thread
331 descriptor is still valid. */
90491dc4 332extern void __free_tcb (struct pthread *pd) attribute_hidden internal_function;
76a50749
UD
333
334/* Free allocated stack. */
90491dc4
UD
335extern void __deallocate_stack (struct pthread *pd)
336 attribute_hidden internal_function;
76a50749
UD
337
338/* Mark all the stacks except for the current one as available. This
339 function also re-initializes the lock for the stack cache. */
340extern void __reclaim_stacks (void) attribute_hidden;
341
54ee14b3 342/* Make all threads's stacks executable. */
d1fc817e
UD
343extern int __make_stacks_executable (void **stack_endp)
344 internal_function attribute_hidden;
54ee14b3 345
76a50749
UD
346/* longjmp handling. */
347extern void __pthread_cleanup_upto (__jmp_buf target, char *targetframe);
334fcf2a
UD
348#if defined NOT_IN_libc && defined IS_IN_libpthread
349hidden_proto (__pthread_cleanup_upto)
350#endif
76a50749
UD
351
352
353/* Functions with versioned interfaces. */
354extern int __pthread_create_2_1 (pthread_t *newthread,
355 const pthread_attr_t *attr,
356 void *(*start_routine) (void *), void *arg);
357extern int __pthread_create_2_0 (pthread_t *newthread,
358 const pthread_attr_t *attr,
359 void *(*start_routine) (void *), void *arg);
360extern int __pthread_attr_init_2_1 (pthread_attr_t *attr);
361extern int __pthread_attr_init_2_0 (pthread_attr_t *attr);
362
363
364/* Event handlers for libthread_db interface. */
fa9a4ff0
RM
365extern void __nptl_create_event (void);
366extern void __nptl_death_event (void);
367hidden_proto (__nptl_create_event)
368hidden_proto (__nptl_death_event)
76a50749 369
8454830b 370/* Register the generation counter in the libpthread with the libc. */
5a03acfe 371#ifdef TLS_MULTIPLE_THREADS_IN_TCB
8454830b
UD
372extern void __libc_pthread_init (unsigned long int *ptr,
373 void (*reclaim) (void),
5a03acfe
UD
374 const struct pthread_functions *functions)
375 internal_function;
376#else
377extern int *__libc_pthread_init (unsigned long int *ptr,
378 void (*reclaim) (void),
379 const struct pthread_functions *functions)
380 internal_function;
381
382/* Variable set to a nonzero value if more than one thread runs or ran. */
383extern int __pthread_multiple_threads attribute_hidden;
384/* Pointer to the corresponding variable in libc. */
385extern int *__libc_multiple_threads_ptr attribute_hidden;
386#endif
8454830b 387
4165d44d 388/* Find a thread given its TID. */
b639d0c9
UD
389extern struct pthread *__find_thread_by_id (pid_t tid) attribute_hidden
390#ifdef SHARED
391;
392#else
393weak_function;
394#define __find_thread_by_id(tid) \
395 (__find_thread_by_id ? (__find_thread_by_id) (tid) : (struct pthread *) NULL)
396#endif
4165d44d 397
adc12574
UD
398extern void __pthread_init_static_tls (struct link_map *) attribute_hidden;
399
76a50749
UD
400
401/* Namespace save aliases. */
8454830b
UD
402extern int __pthread_getschedparam (pthread_t thread_id, int *policy,
403 struct sched_param *param);
404extern int __pthread_setschedparam (pthread_t thread_id, int policy,
405 const struct sched_param *param);
406extern int __pthread_setcancelstate (int state, int *oldstate);
76a50749
UD
407extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
408 __const pthread_mutexattr_t *__mutexattr);
8454830b 409extern int __pthread_mutex_init_internal (pthread_mutex_t *__mutex,
b758b9cb
UD
410 __const pthread_mutexattr_t *__mutexattr)
411 attribute_hidden;
76a50749 412extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
b758b9cb
UD
413extern int __pthread_mutex_destroy_internal (pthread_mutex_t *__mutex)
414 attribute_hidden;
76a50749
UD
415extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex);
416extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
b758b9cb
UD
417extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex)
418 attribute_hidden;
69431c9a 419extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex)
67b78ef9 420 attribute_hidden internal_function;
b0948ffd
UD
421extern void __pthread_mutex_cond_lock_adjust (pthread_mutex_t *__mutex)
422 attribute_hidden internal_function;
76a50749 423extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
b758b9cb
UD
424extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex)
425 attribute_hidden;
426extern int __pthread_mutex_unlock_usercnt (pthread_mutex_t *__mutex,
8f31c0ef 427 int __decr)
3a4f2043 428 attribute_hidden internal_function;
76a50749
UD
429extern int __pthread_mutexattr_init (pthread_mutexattr_t *attr);
430extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *attr);
431extern int __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind);
8454830b
UD
432extern int __pthread_attr_destroy (pthread_attr_t *attr);
433extern int __pthread_attr_getdetachstate (const pthread_attr_t *attr,
434 int *detachstate);
435extern int __pthread_attr_setdetachstate (pthread_attr_t *attr,
436 int detachstate);
437extern int __pthread_attr_getinheritsched (const pthread_attr_t *attr,
438 int *inherit);
439extern int __pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit);
440extern int __pthread_attr_getschedparam (const pthread_attr_t *attr,
441 struct sched_param *param);
442extern int __pthread_attr_setschedparam (pthread_attr_t *attr,
443 const struct sched_param *param);
444extern int __pthread_attr_getschedpolicy (const pthread_attr_t *attr,
445 int *policy);
446extern int __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy);
447extern int __pthread_attr_getscope (const pthread_attr_t *attr, int *scope);
448extern int __pthread_attr_setscope (pthread_attr_t *attr, int scope);
76a50749
UD
449extern int __pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
450 __attr, void **__restrict __stackaddr);
451extern int __pthread_attr_setstackaddr (pthread_attr_t *__attr,
452 void *__stackaddr);
453extern int __pthread_attr_getstacksize (__const pthread_attr_t *__restrict
454 __attr,
455 size_t *__restrict __stacksize);
456extern int __pthread_attr_setstacksize (pthread_attr_t *__attr,
457 size_t __stacksize);
458extern int __pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
459 void **__restrict __stackaddr,
460 size_t *__restrict __stacksize);
461extern int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
462 size_t __stacksize);
463extern int __pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
464 __const pthread_rwlockattr_t *__restrict
465 __attr);
466extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
467extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
73e9ae88 468extern int __pthread_rwlock_rdlock_internal (pthread_rwlock_t *__rwlock);
76a50749
UD
469extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
470extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
73e9ae88 471extern int __pthread_rwlock_wrlock_internal (pthread_rwlock_t *__rwlock);
76a50749
UD
472extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
473extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
73e9ae88 474extern int __pthread_rwlock_unlock_internal (pthread_rwlock_t *__rwlock);
8454830b
UD
475extern int __pthread_cond_broadcast (pthread_cond_t *cond);
476extern int __pthread_cond_destroy (pthread_cond_t *cond);
477extern int __pthread_cond_init (pthread_cond_t *cond,
478 const pthread_condattr_t *cond_attr);
479extern int __pthread_cond_signal (pthread_cond_t *cond);
480extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex);
b5facfda
UD
481extern int __pthread_cond_timedwait (pthread_cond_t *cond,
482 pthread_mutex_t *mutex,
483 const struct timespec *abstime);
8454830b
UD
484extern int __pthread_condattr_destroy (pthread_condattr_t *attr);
485extern int __pthread_condattr_init (pthread_condattr_t *attr);
76a50749 486extern int __pthread_key_create (pthread_key_t *key, void (*destr) (void *));
73e9ae88
UD
487extern int __pthread_key_create_internal (pthread_key_t *key,
488 void (*destr) (void *));
76a50749 489extern void *__pthread_getspecific (pthread_key_t key);
73e9ae88 490extern void *__pthread_getspecific_internal (pthread_key_t key);
76a50749 491extern int __pthread_setspecific (pthread_key_t key, const void *value);
73e9ae88
UD
492extern int __pthread_setspecific_internal (pthread_key_t key,
493 const void *value);
76a50749
UD
494extern int __pthread_once (pthread_once_t *once_control,
495 void (*init_routine) (void));
09efc3ba
UD
496extern int __pthread_once_internal (pthread_once_t *once_control,
497 void (*init_routine) (void));
76a50749
UD
498extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
499 void (*child) (void));
8454830b
UD
500extern pthread_t __pthread_self (void);
501extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
09efc3ba 502extern int __pthread_kill (pthread_t threadid, int signo);
8454830b 503extern void __pthread_exit (void *value);
09efc3ba 504extern int __pthread_setcanceltype (int type, int *oldtype);
bdb04f92 505extern int __pthread_enable_asynccancel (void) attribute_hidden;
9ae0909b
UD
506extern void __pthread_disable_asynccancel (int oldtype)
507 internal_function attribute_hidden;
508
997256dd
UD
509extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
510extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond);
511extern int __pthread_cond_init_2_0 (pthread_cond_2_0_t *cond,
05df18c3 512 const pthread_condattr_t *cond_attr);
997256dd
UD
513extern int __pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond);
514extern int __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond,
05df18c3
UD
515 pthread_mutex_t *mutex,
516 const struct timespec *abstime);
997256dd 517extern int __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond,
05df18c3
UD
518 pthread_mutex_t *mutex);
519
439ff07b
UD
520extern int __pthread_getaffinity_np (pthread_t th, size_t cpusetsize,
521 cpu_set_t *cpuset);
73e9ae88 522
9ae0909b
UD
523/* The two functions are in libc.so and not exported. */
524extern int __libc_enable_asynccancel (void) attribute_hidden;
525extern void __libc_disable_asynccancel (int oldtype)
526 internal_function attribute_hidden;
09efc3ba 527
1fde494e
UD
528
529/* The two functions are in librt.so and not exported. */
530extern int __librt_enable_asynccancel (void) attribute_hidden;
531extern void __librt_disable_asynccancel (int oldtype)
532 internal_function attribute_hidden;
533
1e506629 534#ifdef IS_IN_libpthread
09efc3ba 535/* Special versions which use non-exported functions. */
73e9ae88
UD
536extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
537 void (*routine) (void *), void *arg)
09efc3ba 538 attribute_hidden;
1e506629
UD
539# undef pthread_cleanup_push
540# define pthread_cleanup_push(routine,arg) \
09efc3ba 541 { struct _pthread_cleanup_buffer _buffer; \
73e9ae88 542 __pthread_cleanup_push (&_buffer, (routine), (arg));
09efc3ba 543
73e9ae88
UD
544extern void __pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
545 int execute) attribute_hidden;
1e506629
UD
546# undef pthread_cleanup_pop
547# define pthread_cleanup_pop(execute) \
73e9ae88 548 __pthread_cleanup_pop (&_buffer, (execute)); }
1e506629 549#endif
76a50749 550
73e9ae88
UD
551extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
552 void (*routine) (void *), void *arg);
553extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
554 int execute);
555
6efd4814
UD
556/* Old cleanup interfaces, still used in libc.so. */
557extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
558 void (*routine) (void *), void *arg);
559extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
560 int execute);
561extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
562 void (*routine) (void *), void *arg);
563extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
564 int execute);
565
3fa21fd8
UD
566extern void __nptl_deallocate_tsd (void) attribute_hidden;
567
ccd8de9a 568extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden;
2edb61e3 569
cca50323 570extern void __free_stacks (size_t limit) attribute_hidden;
ba408f84 571
df94b641
UD
572extern void __wait_lookup_done (void) attribute_hidden;
573
b639d0c9
UD
574#ifdef SHARED
575# define PTHREAD_STATIC_FN_REQUIRE(name)
576#else
577# define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " #name);
578#endif
579
0f6699ea
UD
580
581#ifndef __NR_set_robust_list
582/* XXX For the time being... Once we can rely on the kernel headers
583 having the definition remove these lines. */
584# if defined __i386__
585# define __NR_set_robust_list 311
586# elif defined __x86_64__
587# define __NR_set_robust_list 273
588# endif
589#endif
590
76a50749 591#endif /* pthreadP.h */