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