modernc.org/cc@v1.0.1/v2/headers/linux_arm/usr/include/pthread.h (about)

     1  /* Copyright (C) 2002-2016 Free Software Foundation, Inc.
     2     This file is part of the GNU C Library.
     3  
     4     The GNU C Library is free software; you can redistribute it and/or
     5     modify it under the terms of the GNU Lesser General Public
     6     License as published by the Free Software Foundation; either
     7     version 2.1 of the License, or (at your option) any later version.
     8  
     9     The GNU C Library is distributed in the hope that it will be useful,
    10     but WITHOUT ANY WARRANTY; without even the implied warranty of
    11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    12     Lesser General Public License for more details.
    13  
    14     You should have received a copy of the GNU Lesser General Public
    15     License along with the GNU C Library; if not, see
    16     <http://www.gnu.org/licenses/>.  */
    17  
    18  #ifndef _PTHREAD_H
    19  #define _PTHREAD_H	1
    20  
    21  #include <features.h>
    22  #include <endian.h>
    23  #include <sched.h>
    24  #include <time.h>
    25  
    26  #include <bits/pthreadtypes.h>
    27  #include <bits/setjmp.h>
    28  #include <bits/wordsize.h>
    29  
    30  /* Detach state.  */
    31  enum {
    32  	PTHREAD_CREATE_JOINABLE,
    33  #define PTHREAD_CREATE_JOINABLE	PTHREAD_CREATE_JOINABLE
    34  	PTHREAD_CREATE_DETACHED
    35  #define PTHREAD_CREATE_DETACHED	PTHREAD_CREATE_DETACHED
    36  };
    37  
    38  /* Mutex types.  */
    39  enum {
    40  	PTHREAD_MUTEX_TIMED_NP,
    41  	PTHREAD_MUTEX_RECURSIVE_NP,
    42  	PTHREAD_MUTEX_ERRORCHECK_NP,
    43  	PTHREAD_MUTEX_ADAPTIVE_NP
    44  #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
    45  	    ,
    46  	PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
    47  	PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
    48  	PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
    49  	PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
    50  #endif
    51  #ifdef __USE_GNU
    52  	    /* For compatibility.  */
    53  	    , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
    54  #endif
    55  };
    56  
    57  #ifdef __USE_XOPEN2K
    58  /* Robust mutex or not flags.  */
    59  enum {
    60  	PTHREAD_MUTEX_STALLED,
    61  	PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
    62  	PTHREAD_MUTEX_ROBUST,
    63  	PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
    64  };
    65  #endif
    66  
    67  #if defined __USE_POSIX199506 || defined __USE_UNIX98
    68  /* Mutex protocols.  */
    69  enum {
    70  	PTHREAD_PRIO_NONE,
    71  	PTHREAD_PRIO_INHERIT,
    72  	PTHREAD_PRIO_PROTECT
    73  };
    74  #endif
    75  
    76  #ifdef __PTHREAD_MUTEX_HAVE_PREV
    77  #define PTHREAD_MUTEX_INITIALIZER \
    78    { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } }
    79  #ifdef __USE_GNU
    80  #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
    81    { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
    82  #define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
    83    { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __PTHREAD_SPINS, { 0, 0 } } }
    84  #define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
    85    { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
    86  
    87  #endif
    88  #else
    89  #define PTHREAD_MUTEX_INITIALIZER \
    90    { { 0, 0, 0, 0, 0, { __PTHREAD_SPINS } } }
    91  #ifdef __USE_GNU
    92  #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
    93    { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { __PTHREAD_SPINS } } }
    94  #define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
    95    { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { __PTHREAD_SPINS } } }
    96  #define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
    97    { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { __PTHREAD_SPINS } } }
    98  
    99  #endif
   100  #endif
   101  
   102  /* Read-write lock types.  */
   103  #if defined __USE_UNIX98 || defined __USE_XOPEN2K
   104  enum {
   105  	PTHREAD_RWLOCK_PREFER_READER_NP,
   106  	PTHREAD_RWLOCK_PREFER_WRITER_NP,
   107  	PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
   108  	PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
   109  };
   110  
   111  /* Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t
   112     has the shared field.  All 64-bit architectures have the shared field
   113     in pthread_rwlock_t.  */
   114  #ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED
   115  #if __WORDSIZE == 64
   116  #define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1
   117  #endif
   118  #endif
   119  
   120  /* Read-write lock initializers.  */
   121  #define PTHREAD_RWLOCK_INITIALIZER \
   122    { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }
   123  #ifdef __USE_GNU
   124  #ifdef __PTHREAD_RWLOCK_INT_FLAGS_SHARED
   125  #define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
   126    { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0,					      \
   127  	PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
   128  #else
   129  #if __BYTE_ORDER == __LITTLE_ENDIAN
   130  #define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
   131    { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \
   132        0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }
   133  #else
   134  #define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
   135    { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\
   136        0 } }
   137  #endif
   138  #endif
   139  #endif
   140  #endif				/* Unix98 or XOpen2K */
   141  
   142  /* Scheduler inheritance.  */
   143  enum {
   144  	PTHREAD_INHERIT_SCHED,
   145  #define PTHREAD_INHERIT_SCHED   PTHREAD_INHERIT_SCHED
   146  	PTHREAD_EXPLICIT_SCHED
   147  #define PTHREAD_EXPLICIT_SCHED  PTHREAD_EXPLICIT_SCHED
   148  };
   149  
   150  /* Scope handling.  */
   151  enum {
   152  	PTHREAD_SCOPE_SYSTEM,
   153  #define PTHREAD_SCOPE_SYSTEM    PTHREAD_SCOPE_SYSTEM
   154  	PTHREAD_SCOPE_PROCESS
   155  #define PTHREAD_SCOPE_PROCESS   PTHREAD_SCOPE_PROCESS
   156  };
   157  
   158  /* Process shared or private flag.  */
   159  enum {
   160  	PTHREAD_PROCESS_PRIVATE,
   161  #define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
   162  	PTHREAD_PROCESS_SHARED
   163  #define PTHREAD_PROCESS_SHARED  PTHREAD_PROCESS_SHARED
   164  };
   165  
   166  /* Conditional variable handling.  */
   167  #define PTHREAD_COND_INITIALIZER { { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }
   168  
   169  /* Cleanup buffers */
   170  struct _pthread_cleanup_buffer {
   171  	void (*__routine) (void *);	/* Function to call.  */
   172  	void *__arg;		/* Its argument.  */
   173  	int __canceltype;	/* Saved cancellation type. */
   174  	struct _pthread_cleanup_buffer *__prev;	/* Chaining of cleanup functions.  */
   175  };
   176  
   177  /* Cancellation */
   178  enum {
   179  	PTHREAD_CANCEL_ENABLE,
   180  #define PTHREAD_CANCEL_ENABLE   PTHREAD_CANCEL_ENABLE
   181  	PTHREAD_CANCEL_DISABLE
   182  #define PTHREAD_CANCEL_DISABLE  PTHREAD_CANCEL_DISABLE
   183  };
   184  enum {
   185  	PTHREAD_CANCEL_DEFERRED,
   186  #define PTHREAD_CANCEL_DEFERRED	PTHREAD_CANCEL_DEFERRED
   187  	PTHREAD_CANCEL_ASYNCHRONOUS
   188  #define PTHREAD_CANCEL_ASYNCHRONOUS	PTHREAD_CANCEL_ASYNCHRONOUS
   189  };
   190  #define PTHREAD_CANCELED ((void *) -1)
   191  
   192  /* Single execution handling.  */
   193  #define PTHREAD_ONCE_INIT 0
   194  
   195  #ifdef __USE_XOPEN2K
   196  /* Value returned by 'pthread_barrier_wait' for one of the threads after
   197     the required number of threads have called this function.
   198     -1 is distinct from 0 and all errno constants */
   199  #define PTHREAD_BARRIER_SERIAL_THREAD -1
   200  #endif
   201  
   202  __BEGIN_DECLS
   203  /* Create a new thread, starting with execution of START-ROUTINE
   204     getting passed ARG.  Creation attributed come from ATTR.  The new
   205     handle is stored in *NEWTHREAD.  */
   206  extern int pthread_create(pthread_t * __restrict __newthread, const pthread_attr_t * __restrict __attr, void *(*__start_routine) (void *), void *__restrict __arg)
   207  __THROWNL __nonnull((1, 3));
   208  
   209  /* Terminate calling thread.
   210  
   211     The registered cleanup handlers are called via exception handling
   212     so we cannot mark this function with __THROW.*/
   213  extern void pthread_exit(void *__retval) __attribute__ ((__noreturn__));
   214  
   215  /* Make calling thread wait for termination of the thread TH.  The
   216     exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
   217     is not NULL.
   218  
   219     This function is a cancellation point and therefore not marked with
   220     __THROW.  */
   221  extern int pthread_join(pthread_t __th, void **__thread_return);
   222  
   223  #ifdef __USE_GNU
   224  /* Check whether thread TH has terminated.  If yes return the status of
   225     the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL.  */
   226  extern int pthread_tryjoin_np(pthread_t __th, void **__thread_return) __THROW;
   227  
   228  /* Make calling thread wait for termination of the thread TH, but only
   229     until TIMEOUT.  The exit status of the thread is stored in
   230     *THREAD_RETURN, if THREAD_RETURN is not NULL.
   231  
   232     This function is a cancellation point and therefore not marked with
   233     __THROW.  */
   234  extern int pthread_timedjoin_np(pthread_t __th, void **__thread_return, const struct timespec *__abstime);
   235  #endif
   236  
   237  /* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
   238     The resources of TH will therefore be freed immediately when it
   239     terminates, instead of waiting for another thread to perform PTHREAD_JOIN
   240     on it.  */
   241  extern int pthread_detach(pthread_t __th) __THROW;
   242  
   243  /* Obtain the identifier of the current thread.  */
   244  extern pthread_t pthread_self(void)
   245  __THROW __attribute__ ((__const__));
   246  
   247  /* Compare two thread identifiers.  */
   248  extern int pthread_equal(pthread_t __thread1, pthread_t __thread2)
   249  __THROW __attribute__ ((__const__));
   250  
   251  /* Thread attribute handling.  */
   252  
   253  /* Initialize thread attribute *ATTR with default attributes
   254     (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
   255      no user-provided stack).  */
   256  extern int pthread_attr_init(pthread_attr_t * __attr)
   257  __THROW __nonnull((1));
   258  
   259  /* Destroy thread attribute *ATTR.  */
   260  extern int pthread_attr_destroy(pthread_attr_t * __attr)
   261  __THROW __nonnull((1));
   262  
   263  /* Get detach state attribute.  */
   264  extern int pthread_attr_getdetachstate(const pthread_attr_t * __attr, int *__detachstate)
   265  __THROW __nonnull((1, 2));
   266  
   267  /* Set detach state attribute.  */
   268  extern int pthread_attr_setdetachstate(pthread_attr_t * __attr, int __detachstate)
   269  __THROW __nonnull((1));
   270  
   271  /* Get the size of the guard area created for stack overflow protection.  */
   272  extern int pthread_attr_getguardsize(const pthread_attr_t * __attr, size_t * __guardsize)
   273  __THROW __nonnull((1, 2));
   274  
   275  /* Set the size of the guard area created for stack overflow protection.  */
   276  extern int pthread_attr_setguardsize(pthread_attr_t * __attr, size_t __guardsize)
   277  __THROW __nonnull((1));
   278  
   279  /* Return in *PARAM the scheduling parameters of *ATTR.  */
   280  extern int pthread_attr_getschedparam(const pthread_attr_t * __restrict __attr, struct sched_param *__restrict __param)
   281  __THROW __nonnull((1, 2));
   282  
   283  /* Set scheduling parameters (priority, etc) in *ATTR according to PARAM.  */
   284  extern int pthread_attr_setschedparam(pthread_attr_t * __restrict __attr, const struct sched_param *__restrict __param)
   285  __THROW __nonnull((1, 2));
   286  
   287  /* Return in *POLICY the scheduling policy of *ATTR.  */
   288  extern int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict __attr, int *__restrict __policy)
   289  __THROW __nonnull((1, 2));
   290  
   291  /* Set scheduling policy in *ATTR according to POLICY.  */
   292  extern int pthread_attr_setschedpolicy(pthread_attr_t * __attr, int __policy)
   293  __THROW __nonnull((1));
   294  
   295  /* Return in *INHERIT the scheduling inheritance mode of *ATTR.  */
   296  extern int pthread_attr_getinheritsched(const pthread_attr_t * __restrict __attr, int *__restrict __inherit)
   297  __THROW __nonnull((1, 2));
   298  
   299  /* Set scheduling inheritance mode in *ATTR according to INHERIT.  */
   300  extern int pthread_attr_setinheritsched(pthread_attr_t * __attr, int __inherit)
   301  __THROW __nonnull((1));
   302  
   303  /* Return in *SCOPE the scheduling contention scope of *ATTR.  */
   304  extern int pthread_attr_getscope(const pthread_attr_t * __restrict __attr, int *__restrict __scope)
   305  __THROW __nonnull((1, 2));
   306  
   307  /* Set scheduling contention scope in *ATTR according to SCOPE.  */
   308  extern int pthread_attr_setscope(pthread_attr_t * __attr, int __scope)
   309  __THROW __nonnull((1));
   310  
   311  /* Return the previously set address for the stack.  */
   312  extern int pthread_attr_getstackaddr(const pthread_attr_t * __restrict __attr, void **__restrict __stackaddr)
   313  __THROW __nonnull((1, 2)) __attribute_deprecated__;
   314  
   315  /* Set the starting address of the stack of the thread to be created.
   316     Depending on whether the stack grows up or down the value must either
   317     be higher or lower than all the address in the memory block.  The
   318     minimal size of the block must be PTHREAD_STACK_MIN.  */
   319  extern int pthread_attr_setstackaddr(pthread_attr_t * __attr, void *__stackaddr)
   320  __THROW __nonnull((1)) __attribute_deprecated__;
   321  
   322  /* Return the currently used minimal stack size.  */
   323  extern int pthread_attr_getstacksize(const pthread_attr_t * __restrict __attr, size_t * __restrict __stacksize)
   324  __THROW __nonnull((1, 2));
   325  
   326  /* Add information about the minimum stack size needed for the thread
   327     to be started.  This size must never be less than PTHREAD_STACK_MIN
   328     and must also not exceed the system limits.  */
   329  extern int pthread_attr_setstacksize(pthread_attr_t * __attr, size_t __stacksize)
   330  __THROW __nonnull((1));
   331  
   332  #ifdef __USE_XOPEN2K
   333  /* Return the previously set address for the stack.  */
   334  extern int pthread_attr_getstack(const pthread_attr_t * __restrict __attr, void **__restrict __stackaddr, size_t * __restrict __stacksize)
   335  __THROW __nonnull((1, 2, 3));
   336  
   337  /* The following two interfaces are intended to replace the last two.  They
   338     require setting the address as well as the size since only setting the
   339     address will make the implementation on some architectures impossible.  */
   340  extern int pthread_attr_setstack(pthread_attr_t * __attr, void *__stackaddr, size_t __stacksize)
   341  __THROW __nonnull((1));
   342  #endif
   343  
   344  #ifdef __USE_GNU
   345  /* Thread created with attribute ATTR will be limited to run only on
   346     the processors represented in CPUSET.  */
   347  extern int pthread_attr_setaffinity_np(pthread_attr_t * __attr, size_t __cpusetsize, const cpu_set_t * __cpuset)
   348  __THROW __nonnull((1, 3));
   349  
   350  /* Get bit set in CPUSET representing the processors threads created with
   351     ATTR can run on.  */
   352  extern int pthread_attr_getaffinity_np(const pthread_attr_t * __attr, size_t __cpusetsize, cpu_set_t * __cpuset)
   353  __THROW __nonnull((1, 3));
   354  
   355  /* Get the default attributes used by pthread_create in this process.  */
   356  extern int pthread_getattr_default_np(pthread_attr_t * __attr)
   357  __THROW __nonnull((1));
   358  
   359  /* Set the default attributes to be used by pthread_create in this
   360     process.  */
   361  extern int pthread_setattr_default_np(const pthread_attr_t * __attr)
   362  __THROW __nonnull((1));
   363  
   364  /* Initialize thread attribute *ATTR with attributes corresponding to the
   365     already running thread TH.  It shall be called on uninitialized ATTR
   366     and destroyed with pthread_attr_destroy when no longer needed.  */
   367  extern int pthread_getattr_np(pthread_t __th, pthread_attr_t * __attr)
   368  __THROW __nonnull((2));
   369  #endif
   370  
   371  /* Functions for scheduling control.  */
   372  
   373  /* Set the scheduling parameters for TARGET_THREAD according to POLICY
   374     and *PARAM.  */
   375  extern int pthread_setschedparam(pthread_t __target_thread, int __policy, const struct sched_param *__param)
   376  __THROW __nonnull((3));
   377  
   378  /* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
   379  extern int pthread_getschedparam(pthread_t __target_thread, int *__restrict __policy, struct sched_param *__restrict __param)
   380  __THROW __nonnull((2, 3));
   381  
   382  /* Set the scheduling priority for TARGET_THREAD.  */
   383  extern int pthread_setschedprio(pthread_t __target_thread, int __prio) __THROW;
   384  
   385  #ifdef __USE_GNU
   386  /* Get thread name visible in the kernel and its interfaces.  */
   387  extern int pthread_getname_np(pthread_t __target_thread, char *__buf, size_t __buflen)
   388  __THROW __nonnull((2));
   389  
   390  /* Set thread name visible in the kernel and its interfaces.  */
   391  extern int pthread_setname_np(pthread_t __target_thread, const char *__name)
   392  __THROW __nonnull((2));
   393  #endif
   394  
   395  #ifdef __USE_UNIX98
   396  /* Determine level of concurrency.  */
   397  extern int pthread_getconcurrency(void) __THROW;
   398  
   399  /* Set new concurrency level to LEVEL.  */
   400  extern int pthread_setconcurrency(int __level) __THROW;
   401  #endif
   402  
   403  #ifdef __USE_GNU
   404  /* Yield the processor to another thread or process.
   405     This function is similar to the POSIX `sched_yield' function but
   406     might be differently implemented in the case of a m-on-n thread
   407     implementation.  */
   408  extern int pthread_yield(void) __THROW;
   409  
   410  /* Limit specified thread TH to run only on the processors represented
   411     in CPUSET.  */
   412  extern int pthread_setaffinity_np(pthread_t __th, size_t __cpusetsize, const cpu_set_t * __cpuset)
   413  __THROW __nonnull((3));
   414  
   415  /* Get bit set in CPUSET representing the processors TH can run on.  */
   416  extern int pthread_getaffinity_np(pthread_t __th, size_t __cpusetsize, cpu_set_t * __cpuset)
   417  __THROW __nonnull((3));
   418  #endif
   419  
   420  /* Functions for handling initialization.  */
   421  
   422  /* Guarantee that the initialization function INIT_ROUTINE will be called
   423     only once, even if pthread_once is executed several times with the
   424     same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
   425     extern variable initialized to PTHREAD_ONCE_INIT.
   426  
   427     The initialization functions might throw exception which is why
   428     this function is not marked with __THROW.  */
   429  extern int pthread_once(pthread_once_t * __once_control, void (*__init_routine) (void)) __nonnull((1, 2));
   430  
   431  /* Functions for handling cancellation.
   432  
   433     Note that these functions are explicitly not marked to not throw an
   434     exception in C++ code.  If cancellation is implemented by unwinding
   435     this is necessary to have the compiler generate the unwind information.  */
   436  
   437  /* Set cancelability state of current thread to STATE, returning old
   438     state in *OLDSTATE if OLDSTATE is not NULL.  */
   439  extern int pthread_setcancelstate(int __state, int *__oldstate);
   440  
   441  /* Set cancellation state of current thread to TYPE, returning the old
   442     type in *OLDTYPE if OLDTYPE is not NULL.  */
   443  extern int pthread_setcanceltype(int __type, int *__oldtype);
   444  
   445  /* Cancel THREAD immediately or at the next possibility.  */
   446  extern int pthread_cancel(pthread_t __th);
   447  
   448  /* Test for pending cancellation for the current thread and terminate
   449     the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
   450     cancelled.  */
   451  extern void pthread_testcancel(void);
   452  
   453  /* Cancellation handling with integration into exception handling.  */
   454  
   455  typedef struct {
   456  	struct {
   457  		__jmp_buf __cancel_jmp_buf;
   458  		int __mask_was_saved;
   459  	} __cancel_jmp_buf[1];
   460  	void *__pad[4];
   461  } __pthread_unwind_buf_t __attribute__ ((__aligned__));
   462  
   463  /* No special attributes by default.  */
   464  #ifndef __cleanup_fct_attribute
   465  #define __cleanup_fct_attribute
   466  #endif
   467  
   468  /* Structure to hold the cleanup handler information.  */
   469  struct __pthread_cleanup_frame {
   470  	void (*__cancel_routine) (void *);
   471  	void *__cancel_arg;
   472  	int __do_it;
   473  	int __cancel_type;
   474  };
   475  
   476  #if defined __GNUC__ && defined __EXCEPTIONS
   477  #ifdef __cplusplus
   478  /* Class to handle cancellation handler invocation.  */
   479  class __pthread_cleanup_class {
   480  	void (*__cancel_routine) (void *);
   481  	void *__cancel_arg;
   482  	int __do_it;
   483  	int __cancel_type;
   484  
   485   public:
   486  	__pthread_cleanup_class(void (*__fct) (void *), void *__arg)
   487  	:__cancel_routine(__fct), __cancel_arg(__arg), __do_it(1)
   488  {
   489  } ~__pthread_cleanup_class() {
   490  		if (__do_it)
   491  			__cancel_routine(__cancel_arg);
   492  }
   493  void __setdoit(int __newval) {
   494  	__do_it = __newval;
   495  }
   496  void __defer() {
   497  	pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &__cancel_type);
   498  }
   499  void __restore() const {
   500  	pthread_setcanceltype(__cancel_type, 0);
   501  }};
   502  
   503  /* Install a cleanup handler: ROUTINE will be called with arguments ARG
   504     when the thread is canceled or calls pthread_exit.  ROUTINE will also
   505     be called with arguments ARG when the matching pthread_cleanup_pop
   506     is executed with non-zero EXECUTE argument.
   507  
   508     pthread_cleanup_push and pthread_cleanup_pop are macros and must always
   509     be used in matching pairs at the same nesting level of braces.  */
   510  #define pthread_cleanup_push(routine, arg) \
   511    do {									      \
   512      __pthread_cleanup_class __clframe (routine, arg)
   513  
   514  /* Remove a cleanup handler installed by the matching pthread_cleanup_push.
   515     If EXECUTE is non-zero, the handler function is called. */
   516  #define pthread_cleanup_pop(execute) \
   517      __clframe.__setdoit (execute);					      \
   518    } while (0)
   519  
   520  #ifdef __USE_GNU
   521  /* Install a cleanup handler as pthread_cleanup_push does, but also
   522     saves the current cancellation type and sets it to deferred
   523     cancellation.  */
   524  #define pthread_cleanup_push_defer_np(routine, arg) \
   525    do {									      \
   526      __pthread_cleanup_class __clframe (routine, arg);			      \
   527      __clframe.__defer ()
   528  
   529  /* Remove a cleanup handler as pthread_cleanup_pop does, but also
   530     restores the cancellation type that was in effect when the matching
   531     pthread_cleanup_push_defer was called.  */
   532  #define pthread_cleanup_pop_restore_np(execute) \
   533      __clframe.__restore ();						      \
   534      __clframe.__setdoit (execute);					      \
   535    } while (0)
   536  #endif
   537  #else
   538  /* Function called to call the cleanup handler.  As an extern inline
   539     function the compiler is free to decide inlining the change when
   540     needed or fall back on the copy which must exist somewhere
   541     else.  */
   542  __extern_inline void __pthread_cleanup_routine(struct __pthread_cleanup_frame *__frame)
   543  {
   544  	if (__frame->__do_it)
   545  		__frame->__cancel_routine(__frame->__cancel_arg);
   546  }
   547  
   548  /* Install a cleanup handler: ROUTINE will be called with arguments ARG
   549     when the thread is canceled or calls pthread_exit.  ROUTINE will also
   550     be called with arguments ARG when the matching pthread_cleanup_pop
   551     is executed with non-zero EXECUTE argument.
   552  
   553     pthread_cleanup_push and pthread_cleanup_pop are macros and must always
   554     be used in matching pairs at the same nesting level of braces.  */
   555  #define pthread_cleanup_push(routine, arg) \
   556    do {									      \
   557      struct __pthread_cleanup_frame __clframe				      \
   558        __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))		      \
   559        = { .__cancel_routine = (routine), .__cancel_arg = (arg),	 	      \
   560  	  .__do_it = 1 };
   561  
   562  /* Remove a cleanup handler installed by the matching pthread_cleanup_push.
   563     If EXECUTE is non-zero, the handler function is called. */
   564  #define pthread_cleanup_pop(execute) \
   565      __clframe.__do_it = (execute);					      \
   566    } while (0)
   567  
   568  #ifdef __USE_GNU
   569  /* Install a cleanup handler as pthread_cleanup_push does, but also
   570     saves the current cancellation type and sets it to deferred
   571     cancellation.  */
   572  #define pthread_cleanup_push_defer_np(routine, arg) \
   573    do {									      \
   574      struct __pthread_cleanup_frame __clframe				      \
   575        __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))		      \
   576        = { .__cancel_routine = (routine), .__cancel_arg = (arg),		      \
   577  	  .__do_it = 1 };						      \
   578      (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,		      \
   579  				  &__clframe.__cancel_type)
   580  
   581  /* Remove a cleanup handler as pthread_cleanup_pop does, but also
   582     restores the cancellation type that was in effect when the matching
   583     pthread_cleanup_push_defer was called.  */
   584  #define pthread_cleanup_pop_restore_np(execute) \
   585      (void) pthread_setcanceltype (__clframe.__cancel_type, NULL);	      \
   586      __clframe.__do_it = (execute);					      \
   587    } while (0)
   588  #endif
   589  #endif
   590  #else
   591  /* Install a cleanup handler: ROUTINE will be called with arguments ARG
   592     when the thread is canceled or calls pthread_exit.  ROUTINE will also
   593     be called with arguments ARG when the matching pthread_cleanup_pop
   594     is executed with non-zero EXECUTE argument.
   595  
   596     pthread_cleanup_push and pthread_cleanup_pop are macros and must always
   597     be used in matching pairs at the same nesting level of braces.  */
   598  #define pthread_cleanup_push(routine, arg) \
   599    do {									      \
   600      __pthread_unwind_buf_t __cancel_buf;				      \
   601      void (*__cancel_routine) (void *) = (routine);			      \
   602      void *__cancel_arg = (arg);						      \
   603      int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \
   604  					__cancel_buf.__cancel_jmp_buf, 0);    \
   605      if (__glibc_unlikely (__not_first_call))				      \
   606        {									      \
   607  	__cancel_routine (__cancel_arg);				      \
   608  	__pthread_unwind_next (&__cancel_buf);				      \
   609  	/* NOTREACHED */						      \
   610        }									      \
   611  									      \
   612      __pthread_register_cancel (&__cancel_buf);				      \
   613      do {
   614  extern void __pthread_register_cancel(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;
   615  
   616  /* Remove a cleanup handler installed by the matching pthread_cleanup_push.
   617     If EXECUTE is non-zero, the handler function is called. */
   618  #define pthread_cleanup_pop(execute) \
   619        do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\
   620      } while (0);							      \
   621      __pthread_unregister_cancel (&__cancel_buf);			      \
   622      if (execute)							      \
   623        __cancel_routine (__cancel_arg);					      \
   624    } while (0)
   625  extern void __pthread_unregister_cancel(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;
   626  
   627  #ifdef __USE_GNU
   628  /* Install a cleanup handler as pthread_cleanup_push does, but also
   629     saves the current cancellation type and sets it to deferred
   630     cancellation.  */
   631  #define pthread_cleanup_push_defer_np(routine, arg) \
   632    do {									      \
   633      __pthread_unwind_buf_t __cancel_buf;				      \
   634      void (*__cancel_routine) (void *) = (routine);			      \
   635      void *__cancel_arg = (arg);						      \
   636      int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \
   637  					__cancel_buf.__cancel_jmp_buf, 0);    \
   638      if (__glibc_unlikely (__not_first_call))				      \
   639        {									      \
   640  	__cancel_routine (__cancel_arg);				      \
   641  	__pthread_unwind_next (&__cancel_buf);				      \
   642  	/* NOTREACHED */						      \
   643        }									      \
   644  									      \
   645      __pthread_register_cancel_defer (&__cancel_buf);			      \
   646      do {
   647  extern void __pthread_register_cancel_defer(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;
   648  
   649  /* Remove a cleanup handler as pthread_cleanup_pop does, but also
   650     restores the cancellation type that was in effect when the matching
   651     pthread_cleanup_push_defer was called.  */
   652  #define pthread_cleanup_pop_restore_np(execute) \
   653        do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\
   654      } while (0);							      \
   655      __pthread_unregister_cancel_restore (&__cancel_buf);		      \
   656      if (execute)							      \
   657        __cancel_routine (__cancel_arg);					      \
   658    } while (0)
   659  extern void __pthread_unregister_cancel_restore(__pthread_unwind_buf_t * __buf) __cleanup_fct_attribute;
   660  #endif
   661  
   662  /* Internal interface to initiate cleanup.  */
   663  extern void __pthread_unwind_next(__pthread_unwind_buf_t * __buf)
   664  __cleanup_fct_attribute __attribute__ ((__noreturn__))
   665  #ifndef SHARED
   666      __attribute__ ((__weak__))
   667  #endif
   668      ;
   669  #endif
   670  
   671  /* Function used in the macros.  */
   672  struct __jmp_buf_tag;
   673  extern int __sigsetjmp(struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
   674  
   675  /* Mutex handling.  */
   676  
   677  /* Initialize a mutex.  */
   678  extern int pthread_mutex_init(pthread_mutex_t * __mutex, const pthread_mutexattr_t * __mutexattr)
   679  __THROW __nonnull((1));
   680  
   681  /* Destroy a mutex.  */
   682  extern int pthread_mutex_destroy(pthread_mutex_t * __mutex)
   683  __THROW __nonnull((1));
   684  
   685  /* Try locking a mutex.  */
   686  extern int pthread_mutex_trylock(pthread_mutex_t * __mutex)
   687  __THROWNL __nonnull((1));
   688  
   689  /* Lock a mutex.  */
   690  extern int pthread_mutex_lock(pthread_mutex_t * __mutex)
   691  __THROWNL __nonnull((1));
   692  
   693  #ifdef __USE_XOPEN2K
   694  /* Wait until lock becomes available, or specified time passes. */
   695  extern int pthread_mutex_timedlock(pthread_mutex_t * __restrict __mutex, const struct timespec *__restrict __abstime)
   696  __THROWNL __nonnull((1, 2));
   697  #endif
   698  
   699  /* Unlock a mutex.  */
   700  extern int pthread_mutex_unlock(pthread_mutex_t * __mutex)
   701  __THROWNL __nonnull((1));
   702  
   703  /* Get the priority ceiling of MUTEX.  */
   704  extern int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict __mutex, int *__restrict __prioceiling)
   705  __THROW __nonnull((1, 2));
   706  
   707  /* Set the priority ceiling of MUTEX to PRIOCEILING, return old
   708     priority ceiling value in *OLD_CEILING.  */
   709  extern int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict __mutex, int __prioceiling, int *__restrict __old_ceiling)
   710  __THROW __nonnull((1, 3));
   711  
   712  #ifdef __USE_XOPEN2K8
   713  /* Declare the state protected by MUTEX as consistent.  */
   714  extern int pthread_mutex_consistent(pthread_mutex_t * __mutex)
   715  __THROW __nonnull((1));
   716  #ifdef __USE_GNU
   717  extern int pthread_mutex_consistent_np(pthread_mutex_t * __mutex)
   718  __THROW __nonnull((1));
   719  #endif
   720  #endif
   721  
   722  /* Functions for handling mutex attributes.  */
   723  
   724  /* Initialize mutex attribute object ATTR with default attributes
   725     (kind is PTHREAD_MUTEX_TIMED_NP).  */
   726  extern int pthread_mutexattr_init(pthread_mutexattr_t * __attr)
   727  __THROW __nonnull((1));
   728  
   729  /* Destroy mutex attribute object ATTR.  */
   730  extern int pthread_mutexattr_destroy(pthread_mutexattr_t * __attr)
   731  __THROW __nonnull((1));
   732  
   733  /* Get the process-shared flag of the mutex attribute ATTR.  */
   734  extern int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __restrict __attr, int *__restrict __pshared)
   735  __THROW __nonnull((1, 2));
   736  
   737  /* Set the process-shared flag of the mutex attribute ATTR.  */
   738  extern int pthread_mutexattr_setpshared(pthread_mutexattr_t * __attr, int __pshared)
   739  __THROW __nonnull((1));
   740  
   741  #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
   742  /* Return in *KIND the mutex kind attribute in *ATTR.  */
   743  extern int pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict __attr, int *__restrict __kind)
   744  __THROW __nonnull((1, 2));
   745  
   746  /* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
   747     PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
   748     PTHREAD_MUTEX_DEFAULT).  */
   749  extern int pthread_mutexattr_settype(pthread_mutexattr_t * __attr, int __kind)
   750  __THROW __nonnull((1));
   751  #endif
   752  
   753  /* Return in *PROTOCOL the mutex protocol attribute in *ATTR.  */
   754  extern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict __attr, int *__restrict __protocol)
   755  __THROW __nonnull((1, 2));
   756  
   757  /* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
   758     PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT).  */
   759  extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t * __attr, int __protocol)
   760  __THROW __nonnull((1));
   761  
   762  /* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR.  */
   763  extern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict __attr, int *__restrict __prioceiling)
   764  __THROW __nonnull((1, 2));
   765  
   766  /* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING.  */
   767  extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t * __attr, int __prioceiling)
   768  __THROW __nonnull((1));
   769  
   770  #ifdef __USE_XOPEN2K
   771  /* Get the robustness flag of the mutex attribute ATTR.  */
   772  extern int pthread_mutexattr_getrobust(const pthread_mutexattr_t * __attr, int *__robustness)
   773  __THROW __nonnull((1, 2));
   774  #ifdef __USE_GNU
   775  extern int pthread_mutexattr_getrobust_np(const pthread_mutexattr_t * __attr, int *__robustness)
   776  __THROW __nonnull((1, 2));
   777  #endif
   778  
   779  /* Set the robustness flag of the mutex attribute ATTR.  */
   780  extern int pthread_mutexattr_setrobust(pthread_mutexattr_t * __attr, int __robustness)
   781  __THROW __nonnull((1));
   782  #ifdef __USE_GNU
   783  extern int pthread_mutexattr_setrobust_np(pthread_mutexattr_t * __attr, int __robustness)
   784  __THROW __nonnull((1));
   785  #endif
   786  #endif
   787  
   788  #if defined __USE_UNIX98 || defined __USE_XOPEN2K
   789  /* Functions for handling read-write locks.  */
   790  
   791  /* Initialize read-write lock RWLOCK using attributes ATTR, or use
   792     the default values if later is NULL.  */
   793  extern int pthread_rwlock_init(pthread_rwlock_t * __restrict __rwlock, const pthread_rwlockattr_t * __restrict __attr)
   794  __THROW __nonnull((1));
   795  
   796  /* Destroy read-write lock RWLOCK.  */
   797  extern int pthread_rwlock_destroy(pthread_rwlock_t * __rwlock)
   798  __THROW __nonnull((1));
   799  
   800  /* Acquire read lock for RWLOCK.  */
   801  extern int pthread_rwlock_rdlock(pthread_rwlock_t * __rwlock)
   802  __THROWNL __nonnull((1));
   803  
   804  /* Try to acquire read lock for RWLOCK.  */
   805  extern int pthread_rwlock_tryrdlock(pthread_rwlock_t * __rwlock)
   806  __THROWNL __nonnull((1));
   807  
   808  #ifdef __USE_XOPEN2K
   809  /* Try to acquire read lock for RWLOCK or return after specfied time.  */
   810  extern int pthread_rwlock_timedrdlock(pthread_rwlock_t * __restrict __rwlock, const struct timespec *__restrict __abstime)
   811  __THROWNL __nonnull((1, 2));
   812  #endif
   813  
   814  /* Acquire write lock for RWLOCK.  */
   815  extern int pthread_rwlock_wrlock(pthread_rwlock_t * __rwlock)
   816  __THROWNL __nonnull((1));
   817  
   818  /* Try to acquire write lock for RWLOCK.  */
   819  extern int pthread_rwlock_trywrlock(pthread_rwlock_t * __rwlock)
   820  __THROWNL __nonnull((1));
   821  
   822  #ifdef __USE_XOPEN2K
   823  /* Try to acquire write lock for RWLOCK or return after specfied time.  */
   824  extern int pthread_rwlock_timedwrlock(pthread_rwlock_t * __restrict __rwlock, const struct timespec *__restrict __abstime)
   825  __THROWNL __nonnull((1, 2));
   826  #endif
   827  
   828  /* Unlock RWLOCK.  */
   829  extern int pthread_rwlock_unlock(pthread_rwlock_t * __rwlock)
   830  __THROWNL __nonnull((1));
   831  
   832  /* Functions for handling read-write lock attributes.  */
   833  
   834  /* Initialize attribute object ATTR with default values.  */
   835  extern int pthread_rwlockattr_init(pthread_rwlockattr_t * __attr)
   836  __THROW __nonnull((1));
   837  
   838  /* Destroy attribute object ATTR.  */
   839  extern int pthread_rwlockattr_destroy(pthread_rwlockattr_t * __attr)
   840  __THROW __nonnull((1));
   841  
   842  /* Return current setting of process-shared attribute of ATTR in PSHARED.  */
   843  extern int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pshared)
   844  __THROW __nonnull((1, 2));
   845  
   846  /* Set process-shared attribute of ATTR to PSHARED.  */
   847  extern int pthread_rwlockattr_setpshared(pthread_rwlockattr_t * __attr, int __pshared)
   848  __THROW __nonnull((1));
   849  
   850  /* Return current setting of reader/writer preference.  */
   851  extern int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t * __restrict __attr, int *__restrict __pref)
   852  __THROW __nonnull((1, 2));
   853  
   854  /* Set reader/write preference.  */
   855  extern int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t * __attr, int __pref)
   856  __THROW __nonnull((1));
   857  #endif
   858  
   859  /* Functions for handling conditional variables.  */
   860  
   861  /* Initialize condition variable COND using attributes ATTR, or use
   862     the default values if later is NULL.  */
   863  extern int pthread_cond_init(pthread_cond_t * __restrict __cond, const pthread_condattr_t * __restrict __cond_attr)
   864  __THROW __nonnull((1));
   865  
   866  /* Destroy condition variable COND.  */
   867  extern int pthread_cond_destroy(pthread_cond_t * __cond)
   868  __THROW __nonnull((1));
   869  
   870  /* Wake up one thread waiting for condition variable COND.  */
   871  extern int pthread_cond_signal(pthread_cond_t * __cond)
   872  __THROWNL __nonnull((1));
   873  
   874  /* Wake up all threads waiting for condition variables COND.  */
   875  extern int pthread_cond_broadcast(pthread_cond_t * __cond)
   876  __THROWNL __nonnull((1));
   877  
   878  /* Wait for condition variable COND to be signaled or broadcast.
   879     MUTEX is assumed to be locked before.
   880  
   881     This function is a cancellation point and therefore not marked with
   882     __THROW.  */
   883  extern int pthread_cond_wait(pthread_cond_t * __restrict __cond, pthread_mutex_t * __restrict __mutex) __nonnull((1, 2));
   884  
   885  /* Wait for condition variable COND to be signaled or broadcast until
   886     ABSTIME.  MUTEX is assumed to be locked before.  ABSTIME is an
   887     absolute time specification; zero is the beginning of the epoch
   888     (00:00:00 GMT, January 1, 1970).
   889  
   890     This function is a cancellation point and therefore not marked with
   891     __THROW.  */
   892  extern int pthread_cond_timedwait(pthread_cond_t * __restrict __cond, pthread_mutex_t * __restrict __mutex, const struct timespec *__restrict __abstime) __nonnull((1, 2, 3));
   893  
   894  /* Functions for handling condition variable attributes.  */
   895  
   896  /* Initialize condition variable attribute ATTR.  */
   897  extern int pthread_condattr_init(pthread_condattr_t * __attr)
   898  __THROW __nonnull((1));
   899  
   900  /* Destroy condition variable attribute ATTR.  */
   901  extern int pthread_condattr_destroy(pthread_condattr_t * __attr)
   902  __THROW __nonnull((1));
   903  
   904  /* Get the process-shared flag of the condition variable attribute ATTR.  */
   905  extern int pthread_condattr_getpshared(const pthread_condattr_t * __restrict __attr, int *__restrict __pshared)
   906  __THROW __nonnull((1, 2));
   907  
   908  /* Set the process-shared flag of the condition variable attribute ATTR.  */
   909  extern int pthread_condattr_setpshared(pthread_condattr_t * __attr, int __pshared)
   910  __THROW __nonnull((1));
   911  
   912  #ifdef __USE_XOPEN2K
   913  /* Get the clock selected for the condition variable attribute ATTR.  */
   914  extern int pthread_condattr_getclock(const pthread_condattr_t * __restrict __attr, __clockid_t * __restrict __clock_id)
   915  __THROW __nonnull((1, 2));
   916  
   917  /* Set the clock selected for the condition variable attribute ATTR.  */
   918  extern int pthread_condattr_setclock(pthread_condattr_t * __attr, __clockid_t __clock_id)
   919  __THROW __nonnull((1));
   920  #endif
   921  
   922  #ifdef __USE_XOPEN2K
   923  /* Functions to handle spinlocks.  */
   924  
   925  /* Initialize the spinlock LOCK.  If PSHARED is nonzero the spinlock can
   926     be shared between different processes.  */
   927  extern int pthread_spin_init(pthread_spinlock_t * __lock, int __pshared)
   928  __THROW __nonnull((1));
   929  
   930  /* Destroy the spinlock LOCK.  */
   931  extern int pthread_spin_destroy(pthread_spinlock_t * __lock)
   932  __THROW __nonnull((1));
   933  
   934  /* Wait until spinlock LOCK is retrieved.  */
   935  extern int pthread_spin_lock(pthread_spinlock_t * __lock)
   936  __THROWNL __nonnull((1));
   937  
   938  /* Try to lock spinlock LOCK.  */
   939  extern int pthread_spin_trylock(pthread_spinlock_t * __lock)
   940  __THROWNL __nonnull((1));
   941  
   942  /* Release spinlock LOCK.  */
   943  extern int pthread_spin_unlock(pthread_spinlock_t * __lock)
   944  __THROWNL __nonnull((1));
   945  
   946  /* Functions to handle barriers.  */
   947  
   948  /* Initialize BARRIER with the attributes in ATTR.  The barrier is
   949     opened when COUNT waiters arrived.  */
   950  extern int pthread_barrier_init(pthread_barrier_t * __restrict __barrier, const pthread_barrierattr_t * __restrict __attr, unsigned int __count)
   951  __THROW __nonnull((1));
   952  
   953  /* Destroy a previously dynamically initialized barrier BARRIER.  */
   954  extern int pthread_barrier_destroy(pthread_barrier_t * __barrier)
   955  __THROW __nonnull((1));
   956  
   957  /* Wait on barrier BARRIER.  */
   958  extern int pthread_barrier_wait(pthread_barrier_t * __barrier)
   959  __THROWNL __nonnull((1));
   960  
   961  /* Initialize barrier attribute ATTR.  */
   962  extern int pthread_barrierattr_init(pthread_barrierattr_t * __attr)
   963  __THROW __nonnull((1));
   964  
   965  /* Destroy previously dynamically initialized barrier attribute ATTR.  */
   966  extern int pthread_barrierattr_destroy(pthread_barrierattr_t * __attr)
   967  __THROW __nonnull((1));
   968  
   969  /* Get the process-shared flag of the barrier attribute ATTR.  */
   970  extern int pthread_barrierattr_getpshared(const pthread_barrierattr_t * __restrict __attr, int *__restrict __pshared)
   971  __THROW __nonnull((1, 2));
   972  
   973  /* Set the process-shared flag of the barrier attribute ATTR.  */
   974  extern int pthread_barrierattr_setpshared(pthread_barrierattr_t * __attr, int __pshared)
   975  __THROW __nonnull((1));
   976  #endif
   977  
   978  /* Functions for handling thread-specific data.  */
   979  
   980  /* Create a key value identifying a location in the thread-specific
   981     data area.  Each thread maintains a distinct thread-specific data
   982     area.  DESTR_FUNCTION, if non-NULL, is called with the value
   983     associated to that key when the key is destroyed.
   984     DESTR_FUNCTION is not called if the value associated is NULL when
   985     the key is destroyed.  */
   986  extern int pthread_key_create(pthread_key_t * __key, void (*__destr_function) (void *))
   987  __THROW __nonnull((1));
   988  
   989  /* Destroy KEY.  */
   990  extern int pthread_key_delete(pthread_key_t __key) __THROW;
   991  
   992  /* Return current value of the thread-specific data slot identified by KEY.  */
   993  extern void *pthread_getspecific(pthread_key_t __key) __THROW;
   994  
   995  /* Store POINTER in the thread-specific data slot identified by KEY. */
   996  extern int pthread_setspecific(pthread_key_t __key, const void *__pointer) __THROW;
   997  
   998  #ifdef __USE_XOPEN2K
   999  /* Get ID of CPU-time clock for thread THREAD_ID.  */
  1000  extern int pthread_getcpuclockid(pthread_t __thread_id, __clockid_t * __clock_id)
  1001  __THROW __nonnull((2));
  1002  #endif
  1003  
  1004  /* Install handlers to be called when a new process is created with FORK.
  1005     The PREPARE handler is called in the parent process just before performing
  1006     FORK. The PARENT handler is called in the parent process just after FORK.
  1007     The CHILD handler is called in the child process.  Each of the three
  1008     handlers can be NULL, meaning that no handler needs to be called at that
  1009     point.
  1010     PTHREAD_ATFORK can be called several times, in which case the PREPARE
  1011     handlers are called in LIFO order (last added with PTHREAD_ATFORK,
  1012     first called before FORK), and the PARENT and CHILD handlers are called
  1013     in FIFO (first added, first called).  */
  1014  
  1015  extern int pthread_atfork(void (*__prepare) (void), void (*__parent) (void), void (*__child) (void)) __THROW;
  1016  
  1017  #ifdef __USE_EXTERN_INLINES
  1018  /* Optimizations.  */
  1019  __extern_inline int __NTH(pthread_equal(pthread_t __thread1, pthread_t __thread2))
  1020  {
  1021  	return __thread1 == __thread2;
  1022  }
  1023  #endif
  1024  
  1025  __END_DECLS
  1026  #endif				/* pthread.h */