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