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