Back to index

glibc  2.9
pthreadP.h
Go to the documentation of this file.
00001 /* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _PTHREADP_H
00021 #define _PTHREADP_H  1
00022 
00023 #include <pthread.h>
00024 #include <setjmp.h>
00025 #include <stdbool.h>
00026 #include <sys/syscall.h>
00027 #include "descr.h"
00028 #include <tls.h>
00029 #include <lowlevellock.h>
00030 #include <stackinfo.h>
00031 #include <internaltypes.h>
00032 #include <pthread-functions.h>
00033 #include <atomic.h>
00034 #include <kernel-features.h>
00035 
00036 
00037 /* Atomic operations on TLS memory.  */
00038 #ifndef THREAD_ATOMIC_CMPXCHG_VAL
00039 # define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, new, old) \
00040   atomic_compare_and_exchange_val_acq (&(descr)->member, new, old)
00041 #endif
00042 
00043 #ifndef THREAD_ATOMIC_BIT_SET
00044 # define THREAD_ATOMIC_BIT_SET(descr, member, bit) \
00045   atomic_bit_set (&(descr)->member, bit)
00046 #endif
00047 
00048 
00049 /* Adaptive mutex definitions.  */
00050 #ifndef MAX_ADAPTIVE_COUNT
00051 # define MAX_ADAPTIVE_COUNT 100
00052 #endif
00053 
00054 
00055 /* Magic cookie representing robust mutex with dead owner.  */
00056 #define PTHREAD_MUTEX_INCONSISTENT INT_MAX
00057 /* Magic cookie representing not recoverable robust mutex.  */
00058 #define PTHREAD_MUTEX_NOTRECOVERABLE      (INT_MAX - 1)
00059 
00060 
00061 /* Internal mutex type value.  */
00062 enum
00063 {
00064   PTHREAD_MUTEX_KIND_MASK_NP = 3,
00065   PTHREAD_MUTEX_ROBUST_NORMAL_NP = 16,
00066   PTHREAD_MUTEX_ROBUST_RECURSIVE_NP
00067   = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_RECURSIVE_NP,
00068   PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP
00069   = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
00070   PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP
00071   = PTHREAD_MUTEX_ROBUST_NORMAL_NP | PTHREAD_MUTEX_ADAPTIVE_NP,
00072   PTHREAD_MUTEX_PRIO_INHERIT_NP = 32,
00073   PTHREAD_MUTEX_PI_NORMAL_NP
00074   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_NORMAL,
00075   PTHREAD_MUTEX_PI_RECURSIVE_NP
00076   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_RECURSIVE_NP,
00077   PTHREAD_MUTEX_PI_ERRORCHECK_NP
00078   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
00079   PTHREAD_MUTEX_PI_ADAPTIVE_NP
00080   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ADAPTIVE_NP,
00081   PTHREAD_MUTEX_PI_ROBUST_NORMAL_NP
00082   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_NORMAL_NP,
00083   PTHREAD_MUTEX_PI_ROBUST_RECURSIVE_NP
00084   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_RECURSIVE_NP,
00085   PTHREAD_MUTEX_PI_ROBUST_ERRORCHECK_NP
00086   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ERRORCHECK_NP,
00087   PTHREAD_MUTEX_PI_ROBUST_ADAPTIVE_NP
00088   = PTHREAD_MUTEX_PRIO_INHERIT_NP | PTHREAD_MUTEX_ROBUST_ADAPTIVE_NP,
00089   PTHREAD_MUTEX_PRIO_PROTECT_NP = 64,
00090   PTHREAD_MUTEX_PP_NORMAL_NP
00091   = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_NORMAL,
00092   PTHREAD_MUTEX_PP_RECURSIVE_NP
00093   = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_RECURSIVE_NP,
00094   PTHREAD_MUTEX_PP_ERRORCHECK_NP
00095   = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ERRORCHECK_NP,
00096   PTHREAD_MUTEX_PP_ADAPTIVE_NP
00097   = PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ADAPTIVE_NP
00098 };
00099 #define PTHREAD_MUTEX_PSHARED_BIT 128
00100 
00101 #define PTHREAD_MUTEX_TYPE(m) \
00102   ((m)->__data.__kind & 127)
00103 
00104 #if LLL_PRIVATE == 0 && LLL_SHARED == 128
00105 # define PTHREAD_MUTEX_PSHARED(m) \
00106   ((m)->__data.__kind & 128)
00107 #else
00108 # define PTHREAD_MUTEX_PSHARED(m) \
00109   (((m)->__data.__kind & 128) ? LLL_SHARED : LLL_PRIVATE)
00110 #endif
00111 
00112 /* The kernel when waking robust mutexes on exit never uses
00113    FUTEX_PRIVATE_FLAG FUTEX_WAKE.  */
00114 #define PTHREAD_ROBUST_MUTEX_PSHARED(m) LLL_SHARED
00115 
00116 /* Ceiling in __data.__lock.  __data.__lock is signed, so don't
00117    use the MSB bit in there, but in the mask also include that bit,
00118    so that the compiler can optimize & PTHREAD_MUTEX_PRIO_CEILING_MASK
00119    masking if the value is then shifted down by
00120    PTHREAD_MUTEX_PRIO_CEILING_SHIFT.  */
00121 #define PTHREAD_MUTEX_PRIO_CEILING_SHIFT  19
00122 #define PTHREAD_MUTEX_PRIO_CEILING_MASK          0xfff80000
00123 
00124 
00125 /* Flags in mutex attr.  */
00126 #define PTHREAD_MUTEXATTR_PROTOCOL_SHIFT  28
00127 #define PTHREAD_MUTEXATTR_PROTOCOL_MASK          0x30000000
00128 #define PTHREAD_MUTEXATTR_PRIO_CEILING_SHIFT     12
00129 #define PTHREAD_MUTEXATTR_PRIO_CEILING_MASK      0x00fff000
00130 #define PTHREAD_MUTEXATTR_FLAG_ROBUST            0x40000000
00131 #define PTHREAD_MUTEXATTR_FLAG_PSHARED           0x80000000
00132 #define PTHREAD_MUTEXATTR_FLAG_BITS \
00133   (PTHREAD_MUTEXATTR_FLAG_ROBUST | PTHREAD_MUTEXATTR_FLAG_PSHARED \
00134    | PTHREAD_MUTEXATTR_PROTOCOL_MASK | PTHREAD_MUTEXATTR_PRIO_CEILING_MASK)
00135 
00136 
00137 /* Check whether rwlock prefers readers.   */
00138 #define PTHREAD_RWLOCK_PREFER_READER_P(rwlock) \
00139   ((rwlock)->__data.__flags == 0)
00140 
00141 
00142 /* Bits used in robust mutex implementation.  */
00143 #define FUTEX_WAITERS              0x80000000
00144 #define FUTEX_OWNER_DIED    0x40000000
00145 #define FUTEX_TID_MASK             0x3fffffff
00146 
00147 
00148 /* Internal variables.  */
00149 
00150 
00151 /* Default stack size.  */
00152 extern size_t __default_stacksize attribute_hidden;
00153 
00154 /* Size and alignment of static TLS block.  */
00155 extern size_t __static_tls_size attribute_hidden;
00156 extern size_t __static_tls_align_m1 attribute_hidden;
00157 
00158 /* Flag whether the machine is SMP or not.  */
00159 extern int __is_smp attribute_hidden;
00160 
00161 /* Thread descriptor handling.  */
00162 extern list_t __stack_user;
00163 hidden_proto (__stack_user)
00164 
00165 /* Attribute handling.  */
00166 extern struct pthread_attr *__attr_list attribute_hidden;
00167 extern int __attr_list_lock attribute_hidden;
00168 
00169 /* First available RT signal.  */
00170 extern int __current_sigrtmin attribute_hidden;
00171 /* Last available RT signal.  */
00172 extern int __current_sigrtmax attribute_hidden;
00173 
00174 /* Concurrency handling.  */
00175 extern int __concurrency_level attribute_hidden;
00176 
00177 /* Thread-local data key handling.  */
00178 extern struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX];
00179 hidden_proto (__pthread_keys)
00180 
00181 /* Number of threads running.  */
00182 extern unsigned int __nptl_nthreads attribute_hidden;
00183 
00184 #ifndef __ASSUME_SET_ROBUST_LIST
00185 /* Negative if we do not have the system call and we can use it.  */
00186 extern int __set_robust_list_avail attribute_hidden;
00187 #endif
00188 
00189 /* Thread Priority Protection.  */
00190 extern int __sched_fifo_min_prio attribute_hidden;
00191 extern int __sched_fifo_max_prio attribute_hidden;
00192 extern void __init_sched_fifo_prio (void) attribute_hidden;
00193 extern int __pthread_tpp_change_priority (int prev_prio, int new_prio)
00194      attribute_hidden;
00195 extern int __pthread_current_priority (void) attribute_hidden;
00196 
00197 /* The library can run in debugging mode where it performs a lot more
00198    tests.  */
00199 extern int __pthread_debug attribute_hidden;
00201 #if 0
00202 # define DEBUGGING_P __builtin_expect (__pthread_debug, 0)
00203 # define INVALID_TD_P(pd) (DEBUGGING_P && __find_in_stack_list (pd) == NULL)
00204 # define INVALID_NOT_TERMINATED_TD_P(pd) INVALID_TD_P (pd)
00205 #else
00206 # define DEBUGGING_P 0
00207 /* Simplified test.  This will not catch all invalid descriptors but
00208    is better than nothing.  And if the test triggers the thread
00209    descriptor is guaranteed to be invalid.  */
00210 # define INVALID_TD_P(pd) __builtin_expect ((pd)->tid <= 0, 0)
00211 # define INVALID_NOT_TERMINATED_TD_P(pd) __builtin_expect ((pd)->tid < 0, 0)
00212 #endif
00213 
00214 
00215 /* Cancellation test.  */
00216 #define CANCELLATION_P(self) \
00217   do {                                                               \
00218     int cancelhandling = THREAD_GETMEM (self, cancelhandling);              \
00219     if (CANCEL_ENABLED_AND_CANCELED (cancelhandling))                       \
00220       {                                                                     \
00221        THREAD_SETMEM (self, result, PTHREAD_CANCELED);                      \
00222        __do_cancel ();                                                      \
00223       }                                                                     \
00224   } while (0)
00225 
00226 
00227 extern void __pthread_unwind (__pthread_unwind_buf_t *__buf)
00228      __cleanup_fct_attribute __attribute ((__noreturn__))
00229 #if !defined SHARED && !defined IS_IN_libpthread
00230      weak_function
00231 #endif
00232      ;
00233 extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
00234      __cleanup_fct_attribute __attribute ((__noreturn__))
00235 #ifndef SHARED
00236      weak_function
00237 #endif
00238      ;
00239 extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
00240      __cleanup_fct_attribute;
00241 extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
00242      __cleanup_fct_attribute;
00243 #if defined NOT_IN_libc && defined IS_IN_libpthread
00244 hidden_proto (__pthread_unwind)
00245 hidden_proto (__pthread_unwind_next)
00246 hidden_proto (__pthread_register_cancel)
00247 hidden_proto (__pthread_unregister_cancel)
00248 # ifdef SHARED
00249 extern void attribute_hidden pthread_cancel_init (void);
00250 # endif
00251 #endif
00252 
00253 
00254 /* Called when a thread reacts on a cancellation request.  */
00255 static inline void
00256 __attribute ((noreturn, always_inline))
00257 __do_cancel (void)
00258 {
00259   struct pthread *self = THREAD_SELF;
00260 
00261   /* Make sure we get no more cancellations.  */
00262   THREAD_ATOMIC_BIT_SET (self, cancelhandling, EXITING_BIT);
00263 
00264   __pthread_unwind ((__pthread_unwind_buf_t *)
00265                   THREAD_GETMEM (self, cleanup_jmp_buf));
00266 }
00267 
00268 
00269 /* Set cancellation mode to asynchronous.  */
00270 #define CANCEL_ASYNC() \
00271   __pthread_enable_asynccancel ()
00272 /* Reset to previous cancellation mode.  */
00273 #define CANCEL_RESET(oldtype) \
00274   __pthread_disable_asynccancel (oldtype)
00275 
00276 #if !defined NOT_IN_libc
00277 /* Same as CANCEL_ASYNC, but for use in libc.so.  */
00278 # define LIBC_CANCEL_ASYNC() \
00279   __libc_enable_asynccancel ()
00280 /* Same as CANCEL_RESET, but for use in libc.so.  */
00281 # define LIBC_CANCEL_RESET(oldtype) \
00282   __libc_disable_asynccancel (oldtype)
00283 # define LIBC_CANCEL_HANDLED() \
00284   __asm (".globl " __SYMBOL_PREFIX "__libc_enable_asynccancel"); \
00285   __asm (".globl " __SYMBOL_PREFIX "__libc_disable_asynccancel")
00286 #elif defined NOT_IN_libc && defined IS_IN_libpthread
00287 # define LIBC_CANCEL_ASYNC() CANCEL_ASYNC ()
00288 # define LIBC_CANCEL_RESET(val) CANCEL_RESET (val)
00289 # define LIBC_CANCEL_HANDLED() \
00290   __asm (".globl " __SYMBOL_PREFIX "__pthread_enable_asynccancel"); \
00291   __asm (".globl " __SYMBOL_PREFIX "__pthread_disable_asynccancel")
00292 #elif defined NOT_IN_libc && defined IS_IN_librt
00293 # define LIBC_CANCEL_ASYNC() \
00294   __librt_enable_asynccancel ()
00295 # define LIBC_CANCEL_RESET(val) \
00296   __librt_disable_asynccancel (val)
00297 # define LIBC_CANCEL_HANDLED() \
00298   __asm (".globl " __SYMBOL_PREFIX "__librt_enable_asynccancel"); \
00299   __asm (".globl " __SYMBOL_PREFIX "__librt_disable_asynccancel")
00300 #else
00301 # define LIBC_CANCEL_ASYNC()       0 /* Just a dummy value.  */
00302 # define LIBC_CANCEL_RESET(val)    ((void)(val)) /* Nothing, but evaluate it.  */
00303 # define LIBC_CANCEL_HANDLED()     /* Nothing.  */
00304 #endif
00305 
00306 /* The signal used for asynchronous cancelation.  */
00307 #define SIGCANCEL    __SIGRTMIN
00308 
00309 
00310 /* Signal needed for the kernel-supported POSIX timer implementation.
00311    We can reuse the cancellation signal since we can distinguish
00312    cancellation from timer expirations.  */
00313 #define SIGTIMER     SIGCANCEL
00314 
00315 
00316 /* Signal used to implement the setuid et.al. functions.  */
00317 #define SIGSETXID    (__SIGRTMIN + 1)
00318 
00319 /* Used to communicate with signal handler.  */
00320 extern struct xid_command *__xidcmd attribute_hidden;
00321 
00322 
00323 /* Internal prototypes.  */
00324 
00325 /* Thread list handling.  */
00326 extern struct pthread *__find_in_stack_list (struct pthread *pd)
00327      attribute_hidden internal_function;
00328 
00329 /* Deallocate a thread's stack after optionally making sure the thread
00330    descriptor is still valid.  */
00331 extern void __free_tcb (struct pthread *pd) attribute_hidden internal_function;
00332 
00333 /* Free allocated stack.  */
00334 extern void __deallocate_stack (struct pthread *pd)
00335      attribute_hidden internal_function;
00336 
00337 /* Mark all the stacks except for the current one as available.  This
00338    function also re-initializes the lock for the stack cache.  */
00339 extern void __reclaim_stacks (void) attribute_hidden;
00340 
00341 /* Make all threads's stacks executable.  */
00342 extern int __make_stacks_executable (void **stack_endp)
00343      internal_function attribute_hidden;
00344 
00345 /* longjmp handling.  */
00346 extern void __pthread_cleanup_upto (__jmp_buf target, char *targetframe);
00347 #if defined NOT_IN_libc && defined IS_IN_libpthread
00348 hidden_proto (__pthread_cleanup_upto)
00349 #endif
00350 
00351 
00352 /* Functions with versioned interfaces.  */
00353 extern int __pthread_create_2_1 (pthread_t *newthread,
00354                              const pthread_attr_t *attr,
00355                              void *(*start_routine) (void *), void *arg);
00356 extern int __pthread_create_2_0 (pthread_t *newthread,
00357                              const pthread_attr_t *attr,
00358                              void *(*start_routine) (void *), void *arg);
00359 extern int __pthread_attr_init_2_1 (pthread_attr_t *attr);
00360 extern int __pthread_attr_init_2_0 (pthread_attr_t *attr);
00361 
00362 
00363 /* Event handlers for libthread_db interface.  */
00364 extern void __nptl_create_event (void);
00365 extern void __nptl_death_event (void);
00366 hidden_proto (__nptl_create_event)
00367 hidden_proto (__nptl_death_event)
00368 
00369 /* Register the generation counter in the libpthread with the libc.  */
00370 #ifdef TLS_MULTIPLE_THREADS_IN_TCB
00371 extern void __libc_pthread_init (unsigned long int *ptr,
00372                              void (*reclaim) (void),
00373                              const struct pthread_functions *functions)
00374      internal_function;
00375 #else
00376 extern int *__libc_pthread_init (unsigned long int *ptr,
00377                              void (*reclaim) (void),
00378                              const struct pthread_functions *functions)
00379      internal_function;
00380 
00381 /* Variable set to a nonzero value if more than one thread runs or ran.  */
00382 extern int __pthread_multiple_threads attribute_hidden;
00383 /* Pointer to the corresponding variable in libc.  */
00384 extern int *__libc_multiple_threads_ptr attribute_hidden;
00385 #endif
00386 
00387 /* Find a thread given its TID.  */
00388 extern struct pthread *__find_thread_by_id (pid_t tid) attribute_hidden
00389 #ifdef SHARED
00390 ;
00391 #else
00392 weak_function;
00393 #define __find_thread_by_id(tid) \
00394   (__find_thread_by_id ? (__find_thread_by_id) (tid) : (struct pthread *) NULL)
00395 #endif
00396 
00397 extern void __pthread_init_static_tls (struct link_map *) attribute_hidden;
00398 
00399 
00400 /* Namespace save aliases.  */
00401 extern int __pthread_getschedparam (pthread_t thread_id, int *policy,
00402                                 struct sched_param *param);
00403 extern int __pthread_setschedparam (pthread_t thread_id, int policy,
00404                                 const struct sched_param *param);
00405 extern int __pthread_setcancelstate (int state, int *oldstate);
00406 extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
00407                              __const pthread_mutexattr_t *__mutexattr);
00408 extern int __pthread_mutex_init_internal (pthread_mutex_t *__mutex,
00409                                      __const pthread_mutexattr_t *__mutexattr)
00410      attribute_hidden;
00411 extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
00412 extern int __pthread_mutex_destroy_internal (pthread_mutex_t *__mutex)
00413      attribute_hidden;
00414 extern int __pthread_mutex_trylock (pthread_mutex_t *_mutex);
00415 extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
00416 extern int __pthread_mutex_lock_internal (pthread_mutex_t *__mutex)
00417      attribute_hidden;
00418 extern int __pthread_mutex_cond_lock (pthread_mutex_t *__mutex)
00419      attribute_hidden internal_function;
00420 extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
00421 extern int __pthread_mutex_unlock_internal (pthread_mutex_t *__mutex)
00422      attribute_hidden;
00423 extern int __pthread_mutex_unlock_usercnt (pthread_mutex_t *__mutex,
00424                                       int __decr)
00425      attribute_hidden internal_function;
00426 extern int __pthread_mutexattr_init (pthread_mutexattr_t *attr);
00427 extern int __pthread_mutexattr_destroy (pthread_mutexattr_t *attr);
00428 extern int __pthread_mutexattr_settype (pthread_mutexattr_t *attr, int kind);
00429 extern int __pthread_attr_destroy (pthread_attr_t *attr);
00430 extern int __pthread_attr_getdetachstate (const pthread_attr_t *attr,
00431                                      int *detachstate);
00432 extern int __pthread_attr_setdetachstate (pthread_attr_t *attr,
00433                                      int detachstate);
00434 extern int __pthread_attr_getinheritsched (const pthread_attr_t *attr,
00435                                       int *inherit);
00436 extern int __pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit);
00437 extern int __pthread_attr_getschedparam (const pthread_attr_t *attr,
00438                                     struct sched_param *param);
00439 extern int __pthread_attr_setschedparam (pthread_attr_t *attr,
00440                                     const struct sched_param *param);
00441 extern int __pthread_attr_getschedpolicy (const pthread_attr_t *attr,
00442                                      int *policy);
00443 extern int __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy);
00444 extern int __pthread_attr_getscope (const pthread_attr_t *attr, int *scope);
00445 extern int __pthread_attr_setscope (pthread_attr_t *attr, int scope);
00446 extern int __pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
00447                                    __attr, void **__restrict __stackaddr);
00448 extern int __pthread_attr_setstackaddr (pthread_attr_t *__attr,
00449                                    void *__stackaddr);
00450 extern int __pthread_attr_getstacksize (__const pthread_attr_t *__restrict
00451                                    __attr,
00452                                    size_t *__restrict __stacksize);
00453 extern int __pthread_attr_setstacksize (pthread_attr_t *__attr,
00454                                    size_t __stacksize);
00455 extern int __pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
00456                                 void **__restrict __stackaddr,
00457                                 size_t *__restrict __stacksize);
00458 extern int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
00459                                 size_t __stacksize);
00460 extern int __pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
00461                               __const pthread_rwlockattr_t *__restrict
00462                               __attr);
00463 extern int __pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
00464 extern int __pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
00465 extern int __pthread_rwlock_rdlock_internal (pthread_rwlock_t *__rwlock);
00466 extern int __pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
00467 extern int __pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
00468 extern int __pthread_rwlock_wrlock_internal (pthread_rwlock_t *__rwlock);
00469 extern int __pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
00470 extern int __pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
00471 extern int __pthread_rwlock_unlock_internal (pthread_rwlock_t *__rwlock);
00472 extern int __pthread_cond_broadcast (pthread_cond_t *cond);
00473 extern int __pthread_cond_destroy (pthread_cond_t *cond);
00474 extern int __pthread_cond_init (pthread_cond_t *cond,
00475                             const pthread_condattr_t *cond_attr);
00476 extern int __pthread_cond_signal (pthread_cond_t *cond);
00477 extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex);
00478 extern int __pthread_cond_timedwait (pthread_cond_t *cond,
00479                                  pthread_mutex_t *mutex,
00480                                  const struct timespec *abstime);
00481 extern int __pthread_condattr_destroy (pthread_condattr_t *attr);
00482 extern int __pthread_condattr_init (pthread_condattr_t *attr);
00483 extern int __pthread_key_create (pthread_key_t *key, void (*destr) (void *));
00484 extern int __pthread_key_create_internal (pthread_key_t *key,
00485                                      void (*destr) (void *));
00486 extern void *__pthread_getspecific (pthread_key_t key);
00487 extern void *__pthread_getspecific_internal (pthread_key_t key);
00488 extern int __pthread_setspecific (pthread_key_t key, const void *value);
00489 extern int __pthread_setspecific_internal (pthread_key_t key,
00490                                       const void *value);
00491 extern int __pthread_once (pthread_once_t *once_control,
00492                         void (*init_routine) (void));
00493 extern int __pthread_once_internal (pthread_once_t *once_control,
00494                                 void (*init_routine) (void));
00495 extern int __pthread_atfork (void (*prepare) (void), void (*parent) (void),
00496                           void (*child) (void));
00497 extern pthread_t __pthread_self (void);
00498 extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
00499 extern int __pthread_kill (pthread_t threadid, int signo);
00500 extern void __pthread_exit (void *value);
00501 extern int __pthread_setcanceltype (int type, int *oldtype);
00502 extern int __pthread_enable_asynccancel (void) attribute_hidden;
00503 extern void __pthread_disable_asynccancel (int oldtype)
00504      internal_function attribute_hidden;
00505 
00506 extern int __pthread_cond_broadcast_2_0 (pthread_cond_2_0_t *cond);
00507 extern int __pthread_cond_destroy_2_0 (pthread_cond_2_0_t *cond);
00508 extern int __pthread_cond_init_2_0 (pthread_cond_2_0_t *cond,
00509                                 const pthread_condattr_t *cond_attr);
00510 extern int __pthread_cond_signal_2_0 (pthread_cond_2_0_t *cond);
00511 extern int __pthread_cond_timedwait_2_0 (pthread_cond_2_0_t *cond,
00512                                     pthread_mutex_t *mutex,
00513                                     const struct timespec *abstime);
00514 extern int __pthread_cond_wait_2_0 (pthread_cond_2_0_t *cond,
00515                                 pthread_mutex_t *mutex);
00516 
00517 extern int __pthread_getaffinity_np (pthread_t th, size_t cpusetsize,
00518                                  cpu_set_t *cpuset);
00519 
00520 /* The two functions are in libc.so and not exported.  */
00521 extern int __libc_enable_asynccancel (void) attribute_hidden;
00522 extern void __libc_disable_asynccancel (int oldtype)
00523      internal_function attribute_hidden;
00524 
00525 
00526 /* The two functions are in librt.so and not exported.  */
00527 extern int __librt_enable_asynccancel (void) attribute_hidden;
00528 extern void __librt_disable_asynccancel (int oldtype)
00529      internal_function attribute_hidden;
00530 
00531 #ifdef IS_IN_libpthread
00532 /* Special versions which use non-exported functions.  */
00533 extern void __pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
00534                                 void (*routine) (void *), void *arg)
00535      attribute_hidden;
00536 # undef pthread_cleanup_push
00537 # define pthread_cleanup_push(routine,arg) \
00538   { struct _pthread_cleanup_buffer _buffer;                                 \
00539     __pthread_cleanup_push (&_buffer, (routine), (arg));
00540 
00541 extern void __pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
00542                                int execute) attribute_hidden;
00543 # undef pthread_cleanup_pop
00544 # define pthread_cleanup_pop(execute) \
00545     __pthread_cleanup_pop (&_buffer, (execute)); }
00546 #endif
00547 
00548 extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
00549                                      void (*routine) (void *), void *arg);
00550 extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
00551                                       int execute);
00552 
00553 /* Old cleanup interfaces, still used in libc.so.  */
00554 extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *buffer,
00555                                    void (*routine) (void *), void *arg);
00556 extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *buffer,
00557                                   int execute);
00558 extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer,
00559                                          void (*routine) (void *), void *arg);
00560 extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer,
00561                                           int execute);
00562 
00563 extern void __nptl_deallocate_tsd (void) attribute_hidden;
00564 
00565 extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden;
00566 
00567 extern void __free_stack_cache (void) attribute_hidden;
00568 
00569 extern void __wait_lookup_done (void) attribute_hidden;
00570 
00571 #ifdef SHARED
00572 # define PTHREAD_STATIC_FN_REQUIRE(name)
00573 #else
00574 # define PTHREAD_STATIC_FN_REQUIRE(name) __asm (".globl " #name);
00575 #endif
00576 
00577 
00578 #ifndef __NR_set_robust_list
00579 /* XXX For the time being...  Once we can rely on the kernel headers
00580    having the definition remove these lines.  */
00581 # if defined __i386__
00582 #  define __NR_set_robust_list  311
00583 # elif defined __x86_64__
00584 #  define __NR_set_robust_list  273
00585 # endif
00586 #endif
00587 
00588 #endif /* pthreadP.h */