hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sysdeps/nptl/pthread.h

Packit 6c4009
/* Copyright (C) 2002-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _PTHREAD_H
Packit 6c4009
#define _PTHREAD_H	1
Packit 6c4009
Packit 6c4009
#include <features.h>
Packit 6c4009
#include <endian.h>
Packit 6c4009
#include <sched.h>
Packit 6c4009
#include <time.h>
Packit 6c4009
Packit 6c4009
#include <bits/pthreadtypes.h>
Packit 6c4009
#include <bits/setjmp.h>
Packit 6c4009
#include <bits/wordsize.h>
Packit 6c4009
#include <bits/types/struct_timespec.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Detach state.  */
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  PTHREAD_CREATE_JOINABLE,
Packit 6c4009
#define PTHREAD_CREATE_JOINABLE	PTHREAD_CREATE_JOINABLE
Packit 6c4009
  PTHREAD_CREATE_DETACHED
Packit 6c4009
#define PTHREAD_CREATE_DETACHED	PTHREAD_CREATE_DETACHED
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Mutex types.  */
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  PTHREAD_MUTEX_TIMED_NP,
Packit 6c4009
  PTHREAD_MUTEX_RECURSIVE_NP,
Packit 6c4009
  PTHREAD_MUTEX_ERRORCHECK_NP,
Packit 6c4009
  PTHREAD_MUTEX_ADAPTIVE_NP
Packit 6c4009
#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
Packit 6c4009
  ,
Packit 6c4009
  PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP,
Packit 6c4009
  PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
Packit 6c4009
  PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
Packit 6c4009
  PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
Packit 6c4009
#endif
Packit 6c4009
#ifdef __USE_GNU
Packit 6c4009
  /* For compatibility.  */
Packit 6c4009
  , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP
Packit 6c4009
#endif
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_XOPEN2K
Packit 6c4009
/* Robust mutex or not flags.  */
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  PTHREAD_MUTEX_STALLED,
Packit 6c4009
  PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
Packit 6c4009
  PTHREAD_MUTEX_ROBUST,
Packit 6c4009
  PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
Packit 6c4009
};
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
#if defined __USE_POSIX199506 || defined __USE_UNIX98
Packit 6c4009
/* Mutex protocols.  */
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  PTHREAD_PRIO_NONE,
Packit 6c4009
  PTHREAD_PRIO_INHERIT,
Packit 6c4009
  PTHREAD_PRIO_PROTECT
Packit 6c4009
};
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
#if __PTHREAD_MUTEX_HAVE_PREV
Packit 6c4009
# define PTHREAD_MUTEX_INITIALIZER \
Packit 6c4009
  { { 0, 0, 0, 0, 0, __PTHREAD_SPINS, { 0, 0 } } }
Packit 6c4009
# ifdef __USE_GNU
Packit 6c4009
#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
Packit 6c4009
  { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
Packit 6c4009
#  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
Packit 6c4009
  { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __PTHREAD_SPINS, { 0, 0 } } }
Packit 6c4009
#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
Packit 6c4009
  { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __PTHREAD_SPINS, { 0, 0 } } }
Packit 6c4009
Packit 6c4009
# endif
Packit 6c4009
#else
Packit 6c4009
# define PTHREAD_MUTEX_INITIALIZER \
Packit 6c4009
  { { 0, 0, 0, 0, 0, { __PTHREAD_SPINS } } }
Packit 6c4009
# ifdef __USE_GNU
Packit 6c4009
#  define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
Packit 6c4009
  { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, 0, { __PTHREAD_SPINS } } }
Packit 6c4009
#  define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
Packit 6c4009
  { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, 0, { __PTHREAD_SPINS } } }
Packit 6c4009
#  define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
Packit 6c4009
  { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, 0, { __PTHREAD_SPINS } } }
Packit 6c4009
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Read-write lock types.  */
Packit 6c4009
#if defined __USE_UNIX98 || defined __USE_XOPEN2K
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  PTHREAD_RWLOCK_PREFER_READER_NP,
Packit 6c4009
  PTHREAD_RWLOCK_PREFER_WRITER_NP,
Packit 6c4009
  PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
Packit 6c4009
  PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* Define __PTHREAD_RWLOCK_INT_FLAGS_SHARED to 1 if pthread_rwlock_t
Packit 6c4009
   has the shared field.  All 64-bit architectures have the shared field
Packit 6c4009
   in pthread_rwlock_t.  */
Packit 6c4009
#ifndef __PTHREAD_RWLOCK_INT_FLAGS_SHARED
Packit 6c4009
# if __WORDSIZE == 64
Packit 6c4009
#  define __PTHREAD_RWLOCK_INT_FLAGS_SHARED 1
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Read-write lock initializers.  */
Packit 6c4009
# define PTHREAD_RWLOCK_INITIALIZER \
Packit 6c4009
  { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }
Packit 6c4009
# ifdef __USE_GNU
Packit 6c4009
#  ifdef __PTHREAD_RWLOCK_INT_FLAGS_SHARED
Packit 6c4009
#   define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
Packit 6c4009
  { { 0, 0, 0, 0, 0, 0, 0, 0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0,					      \
Packit 6c4009
	PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
Packit 6c4009
#  else
Packit 6c4009
#   if __BYTE_ORDER == __LITTLE_ENDIAN
Packit 6c4009
#    define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
Packit 6c4009
  { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, \
Packit 6c4009
      0, __PTHREAD_RWLOCK_ELISION_EXTRA, 0, 0 } }
Packit 6c4009
#   else
Packit 6c4009
#    define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
Packit 6c4009
  { { 0, 0, 0, 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,\
Packit 6c4009
      0 } }
Packit 6c4009
#   endif
Packit 6c4009
#  endif
Packit 6c4009
# endif
Packit 6c4009
#endif  /* Unix98 or XOpen2K */
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Scheduler inheritance.  */
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  PTHREAD_INHERIT_SCHED,
Packit 6c4009
#define PTHREAD_INHERIT_SCHED   PTHREAD_INHERIT_SCHED
Packit 6c4009
  PTHREAD_EXPLICIT_SCHED
Packit 6c4009
#define PTHREAD_EXPLICIT_SCHED  PTHREAD_EXPLICIT_SCHED
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Scope handling.  */
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  PTHREAD_SCOPE_SYSTEM,
Packit 6c4009
#define PTHREAD_SCOPE_SYSTEM    PTHREAD_SCOPE_SYSTEM
Packit 6c4009
  PTHREAD_SCOPE_PROCESS
Packit 6c4009
#define PTHREAD_SCOPE_PROCESS   PTHREAD_SCOPE_PROCESS
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Process shared or private flag.  */
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  PTHREAD_PROCESS_PRIVATE,
Packit 6c4009
#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
Packit 6c4009
  PTHREAD_PROCESS_SHARED
Packit 6c4009
#define PTHREAD_PROCESS_SHARED  PTHREAD_PROCESS_SHARED
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Conditional variable handling.  */
Packit 6c4009
#define PTHREAD_COND_INITIALIZER { { {0}, {0}, {0, 0}, {0, 0}, 0, 0, {0, 0} } }
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Cleanup buffers */
Packit 6c4009
struct _pthread_cleanup_buffer
Packit 6c4009
{
Packit 6c4009
  void (*__routine) (void *);             /* Function to call.  */
Packit 6c4009
  void *__arg;                            /* Its argument.  */
Packit 6c4009
  int __canceltype;                       /* Saved cancellation type. */
Packit 6c4009
  struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions.  */
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* Cancellation */
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  PTHREAD_CANCEL_ENABLE,
Packit 6c4009
#define PTHREAD_CANCEL_ENABLE   PTHREAD_CANCEL_ENABLE
Packit 6c4009
  PTHREAD_CANCEL_DISABLE
Packit 6c4009
#define PTHREAD_CANCEL_DISABLE  PTHREAD_CANCEL_DISABLE
Packit 6c4009
};
Packit 6c4009
enum
Packit 6c4009
{
Packit 6c4009
  PTHREAD_CANCEL_DEFERRED,
Packit 6c4009
#define PTHREAD_CANCEL_DEFERRED	PTHREAD_CANCEL_DEFERRED
Packit 6c4009
  PTHREAD_CANCEL_ASYNCHRONOUS
Packit 6c4009
#define PTHREAD_CANCEL_ASYNCHRONOUS	PTHREAD_CANCEL_ASYNCHRONOUS
Packit 6c4009
};
Packit 6c4009
#define PTHREAD_CANCELED ((void *) -1)
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Single execution handling.  */
Packit 6c4009
#define PTHREAD_ONCE_INIT 0
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_XOPEN2K
Packit 6c4009
/* Value returned by 'pthread_barrier_wait' for one of the threads after
Packit 6c4009
   the required number of threads have called this function.
Packit 6c4009
   -1 is distinct from 0 and all errno constants */
Packit 6c4009
# define PTHREAD_BARRIER_SERIAL_THREAD -1
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
/* Create a new thread, starting with execution of START-ROUTINE
Packit 6c4009
   getting passed ARG.  Creation attributed come from ATTR.  The new
Packit 6c4009
   handle is stored in *NEWTHREAD.  */
Packit 6c4009
extern int pthread_create (pthread_t *__restrict __newthread,
Packit 6c4009
			   const pthread_attr_t *__restrict __attr,
Packit 6c4009
			   void *(*__start_routine) (void *),
Packit 6c4009
			   void *__restrict __arg) __THROWNL __nonnull ((1, 3));
Packit 6c4009
Packit 6c4009
/* Terminate calling thread.
Packit 6c4009
Packit 6c4009
   The registered cleanup handlers are called via exception handling
Packit 6c4009
   so we cannot mark this function with __THROW.*/
Packit 6c4009
extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
Packit 6c4009
Packit 6c4009
/* Make calling thread wait for termination of the thread TH.  The
Packit 6c4009
   exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
Packit 6c4009
   is not NULL.
Packit 6c4009
Packit 6c4009
   This function is a cancellation point and therefore not marked with
Packit 6c4009
   __THROW.  */
Packit 6c4009
extern int pthread_join (pthread_t __th, void **__thread_return);
Packit 6c4009
Packit 6c4009
#ifdef __USE_GNU
Packit 6c4009
/* Check whether thread TH has terminated.  If yes return the status of
Packit 6c4009
   the thread in *THREAD_RETURN, if THREAD_RETURN is not NULL.  */
Packit 6c4009
extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
Packit 6c4009
Packit 6c4009
/* Make calling thread wait for termination of the thread TH, but only
Packit 6c4009
   until TIMEOUT.  The exit status of the thread is stored in
Packit 6c4009
   *THREAD_RETURN, if THREAD_RETURN is not NULL.
Packit 6c4009
Packit 6c4009
   This function is a cancellation point and therefore not marked with
Packit 6c4009
   __THROW.  */
Packit 6c4009
extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
Packit 6c4009
				 const struct timespec *__abstime);
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
Packit 6c4009
   The resources of TH will therefore be freed immediately when it
Packit 6c4009
   terminates, instead of waiting for another thread to perform PTHREAD_JOIN
Packit 6c4009
   on it.  */
Packit 6c4009
extern int pthread_detach (pthread_t __th) __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Obtain the identifier of the current thread.  */
Packit 6c4009
extern pthread_t pthread_self (void) __THROW __attribute__ ((__const__));
Packit 6c4009
Packit 6c4009
/* Compare two thread identifiers.  */
Packit 6c4009
extern int pthread_equal (pthread_t __thread1, pthread_t __thread2)
Packit 6c4009
  __THROW __attribute__ ((__const__));
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Thread attribute handling.  */
Packit 6c4009
Packit 6c4009
/* Initialize thread attribute *ATTR with default attributes
Packit 6c4009
   (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
Packit 6c4009
    no user-provided stack).  */
Packit 6c4009
extern int pthread_attr_init (pthread_attr_t *__attr) __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy thread attribute *ATTR.  */
Packit 6c4009
extern int pthread_attr_destroy (pthread_attr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Get detach state attribute.  */
Packit 6c4009
extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
Packit 6c4009
					int *__detachstate)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set detach state attribute.  */
Packit 6c4009
extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
Packit 6c4009
					int __detachstate)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Get the size of the guard area created for stack overflow protection.  */
Packit 6c4009
extern int pthread_attr_getguardsize (const pthread_attr_t *__attr,
Packit 6c4009
				      size_t *__guardsize)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set the size of the guard area created for stack overflow protection.  */
Packit 6c4009
extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
Packit 6c4009
				      size_t __guardsize)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Return in *PARAM the scheduling parameters of *ATTR.  */
Packit 6c4009
extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict __attr,
Packit 6c4009
				       struct sched_param *__restrict __param)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM.  */
Packit 6c4009
extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
Packit 6c4009
				       const struct sched_param *__restrict
Packit 6c4009
				       __param) __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Return in *POLICY the scheduling policy of *ATTR.  */
Packit 6c4009
extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
Packit 6c4009
					__attr, int *__restrict __policy)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set scheduling policy in *ATTR according to POLICY.  */
Packit 6c4009
extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Return in *INHERIT the scheduling inheritance mode of *ATTR.  */
Packit 6c4009
extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict
Packit 6c4009
					 __attr, int *__restrict __inherit)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set scheduling inheritance mode in *ATTR according to INHERIT.  */
Packit 6c4009
extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
Packit 6c4009
					 int __inherit)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Return in *SCOPE the scheduling contention scope of *ATTR.  */
Packit 6c4009
extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
Packit 6c4009
				  int *__restrict __scope)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set scheduling contention scope in *ATTR according to SCOPE.  */
Packit 6c4009
extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Return the previously set address for the stack.  */
Packit 6c4009
extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
Packit 6c4009
				      __attr, void **__restrict __stackaddr)
Packit 6c4009
     __THROW __nonnull ((1, 2)) __attribute_deprecated__;
Packit 6c4009
Packit 6c4009
/* Set the starting address of the stack of the thread to be created.
Packit 6c4009
   Depending on whether the stack grows up or down the value must either
Packit 6c4009
   be higher or lower than all the address in the memory block.  The
Packit 6c4009
   minimal size of the block must be PTHREAD_STACK_MIN.  */
Packit 6c4009
extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
Packit 6c4009
				      void *__stackaddr)
Packit 6c4009
     __THROW __nonnull ((1)) __attribute_deprecated__;
Packit 6c4009
Packit 6c4009
/* Return the currently used minimal stack size.  */
Packit 6c4009
extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
Packit 6c4009
				      __attr, size_t *__restrict __stacksize)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Add information about the minimum stack size needed for the thread
Packit 6c4009
   to be started.  This size must never be less than PTHREAD_STACK_MIN
Packit 6c4009
   and must also not exceed the system limits.  */
Packit 6c4009
extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
Packit 6c4009
				      size_t __stacksize)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
#ifdef __USE_XOPEN2K
Packit 6c4009
/* Return the previously set address for the stack.  */
Packit 6c4009
extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
Packit 6c4009
				  void **__restrict __stackaddr,
Packit 6c4009
				  size_t *__restrict __stacksize)
Packit 6c4009
     __THROW __nonnull ((1, 2, 3));
Packit 6c4009
Packit 6c4009
/* The following two interfaces are intended to replace the last two.  They
Packit 6c4009
   require setting the address as well as the size since only setting the
Packit 6c4009
   address will make the implementation on some architectures impossible.  */
Packit 6c4009
extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
Packit 6c4009
				  size_t __stacksize) __THROW __nonnull ((1));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef __USE_GNU
Packit 6c4009
/* Thread created with attribute ATTR will be limited to run only on
Packit 6c4009
   the processors represented in CPUSET.  */
Packit 6c4009
extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
Packit 6c4009
					size_t __cpusetsize,
Packit 6c4009
					const cpu_set_t *__cpuset)
Packit 6c4009
     __THROW __nonnull ((1, 3));
Packit 6c4009
Packit 6c4009
/* Get bit set in CPUSET representing the processors threads created with
Packit 6c4009
   ATTR can run on.  */
Packit 6c4009
extern int pthread_attr_getaffinity_np (const pthread_attr_t *__attr,
Packit 6c4009
					size_t __cpusetsize,
Packit 6c4009
					cpu_set_t *__cpuset)
Packit 6c4009
     __THROW __nonnull ((1, 3));
Packit 6c4009
Packit 6c4009
/* Get the default attributes used by pthread_create in this process.  */
Packit 6c4009
extern int pthread_getattr_default_np (pthread_attr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Set the default attributes to be used by pthread_create in this
Packit 6c4009
   process.  */
Packit 6c4009
extern int pthread_setattr_default_np (const pthread_attr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Initialize thread attribute *ATTR with attributes corresponding to the
Packit 6c4009
   already running thread TH.  It shall be called on uninitialized ATTR
Packit 6c4009
   and destroyed with pthread_attr_destroy when no longer needed.  */
Packit 6c4009
extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((2));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Functions for scheduling control.  */
Packit 6c4009
Packit 6c4009
/* Set the scheduling parameters for TARGET_THREAD according to POLICY
Packit 6c4009
   and *PARAM.  */
Packit 6c4009
extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
Packit 6c4009
				  const struct sched_param *__param)
Packit 6c4009
     __THROW __nonnull ((3));
Packit 6c4009
Packit 6c4009
/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
Packit 6c4009
extern int pthread_getschedparam (pthread_t __target_thread,
Packit 6c4009
				  int *__restrict __policy,
Packit 6c4009
				  struct sched_param *__restrict __param)
Packit 6c4009
     __THROW __nonnull ((2, 3));
Packit 6c4009
Packit 6c4009
/* Set the scheduling priority for TARGET_THREAD.  */
Packit 6c4009
extern int pthread_setschedprio (pthread_t __target_thread, int __prio)
Packit 6c4009
     __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_GNU
Packit 6c4009
/* Get thread name visible in the kernel and its interfaces.  */
Packit 6c4009
extern int pthread_getname_np (pthread_t __target_thread, char *__buf,
Packit 6c4009
			       size_t __buflen)
Packit 6c4009
     __THROW __nonnull ((2));
Packit 6c4009
Packit 6c4009
/* Set thread name visible in the kernel and its interfaces.  */
Packit 6c4009
extern int pthread_setname_np (pthread_t __target_thread, const char *__name)
Packit 6c4009
     __THROW __nonnull ((2));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_UNIX98
Packit 6c4009
/* Determine level of concurrency.  */
Packit 6c4009
extern int pthread_getconcurrency (void) __THROW;
Packit 6c4009
Packit 6c4009
/* Set new concurrency level to LEVEL.  */
Packit 6c4009
extern int pthread_setconcurrency (int __level) __THROW;
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef __USE_GNU
Packit 6c4009
/* Yield the processor to another thread or process.
Packit 6c4009
   This function is similar to the POSIX `sched_yield' function but
Packit 6c4009
   might be differently implemented in the case of a m-on-n thread
Packit 6c4009
   implementation.  */
Packit 6c4009
extern int pthread_yield (void) __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Limit specified thread TH to run only on the processors represented
Packit 6c4009
   in CPUSET.  */
Packit 6c4009
extern int pthread_setaffinity_np (pthread_t __th, size_t __cpusetsize,
Packit 6c4009
				   const cpu_set_t *__cpuset)
Packit 6c4009
     __THROW __nonnull ((3));
Packit 6c4009
Packit 6c4009
/* Get bit set in CPUSET representing the processors TH can run on.  */
Packit 6c4009
extern int pthread_getaffinity_np (pthread_t __th, size_t __cpusetsize,
Packit 6c4009
				   cpu_set_t *__cpuset)
Packit 6c4009
     __THROW __nonnull ((3));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Functions for handling initialization.  */
Packit 6c4009
Packit 6c4009
/* Guarantee that the initialization function INIT_ROUTINE will be called
Packit 6c4009
   only once, even if pthread_once is executed several times with the
Packit 6c4009
   same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
Packit 6c4009
   extern variable initialized to PTHREAD_ONCE_INIT.
Packit 6c4009
Packit 6c4009
   The initialization functions might throw exception which is why
Packit 6c4009
   this function is not marked with __THROW.  */
Packit 6c4009
extern int pthread_once (pthread_once_t *__once_control,
Packit 6c4009
			 void (*__init_routine) (void)) __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Functions for handling cancellation.
Packit 6c4009
Packit 6c4009
   Note that these functions are explicitly not marked to not throw an
Packit 6c4009
   exception in C++ code.  If cancellation is implemented by unwinding
Packit 6c4009
   this is necessary to have the compiler generate the unwind information.  */
Packit 6c4009
Packit 6c4009
/* Set cancelability state of current thread to STATE, returning old
Packit 6c4009
   state in *OLDSTATE if OLDSTATE is not NULL.  */
Packit 6c4009
extern int pthread_setcancelstate (int __state, int *__oldstate);
Packit 6c4009
Packit 6c4009
/* Set cancellation state of current thread to TYPE, returning the old
Packit 6c4009
   type in *OLDTYPE if OLDTYPE is not NULL.  */
Packit 6c4009
extern int pthread_setcanceltype (int __type, int *__oldtype);
Packit 6c4009
Packit 6c4009
/* Cancel THREAD immediately or at the next possibility.  */
Packit 6c4009
extern int pthread_cancel (pthread_t __th);
Packit 6c4009
Packit 6c4009
/* Test for pending cancellation for the current thread and terminate
Packit 6c4009
   the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
Packit 6c4009
   cancelled.  */
Packit 6c4009
extern void pthread_testcancel (void);
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Cancellation handling with integration into exception handling.  */
Packit 6c4009
Packit 6c4009
typedef struct
Packit 6c4009
{
Packit 6c4009
  struct
Packit 6c4009
  {
Packit 6c4009
    __jmp_buf __cancel_jmp_buf;
Packit 6c4009
    int __mask_was_saved;
Packit 6c4009
  } __cancel_jmp_buf[1];
Packit 6c4009
  void *__pad[4];
Packit 6c4009
} __pthread_unwind_buf_t __attribute__ ((__aligned__));
Packit 6c4009
Packit 6c4009
/* No special attributes by default.  */
Packit 6c4009
#ifndef __cleanup_fct_attribute
Packit 6c4009
# define __cleanup_fct_attribute
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Structure to hold the cleanup handler information.  */
Packit 6c4009
struct __pthread_cleanup_frame
Packit 6c4009
{
Packit 6c4009
  void (*__cancel_routine) (void *);
Packit 6c4009
  void *__cancel_arg;
Packit 6c4009
  int __do_it;
Packit 6c4009
  int __cancel_type;
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
#if defined __GNUC__ && defined __EXCEPTIONS
Packit 6c4009
# ifdef __cplusplus
Packit 6c4009
/* Class to handle cancellation handler invocation.  */
Packit 6c4009
class __pthread_cleanup_class
Packit 6c4009
{
Packit 6c4009
  void (*__cancel_routine) (void *);
Packit 6c4009
  void *__cancel_arg;
Packit 6c4009
  int __do_it;
Packit 6c4009
  int __cancel_type;
Packit 6c4009
Packit 6c4009
 public:
Packit 6c4009
  __pthread_cleanup_class (void (*__fct) (void *), void *__arg)
Packit 6c4009
    : __cancel_routine (__fct), __cancel_arg (__arg), __do_it (1) { }
Packit 6c4009
  ~__pthread_cleanup_class () { if (__do_it) __cancel_routine (__cancel_arg); }
Packit 6c4009
  void __setdoit (int __newval) { __do_it = __newval; }
Packit 6c4009
  void __defer () { pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,
Packit 6c4009
					   &__cancel_type); }
Packit 6c4009
  void __restore () const { pthread_setcanceltype (__cancel_type, 0); }
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* Install a cleanup handler: ROUTINE will be called with arguments ARG
Packit 6c4009
   when the thread is canceled or calls pthread_exit.  ROUTINE will also
Packit 6c4009
   be called with arguments ARG when the matching pthread_cleanup_pop
Packit 6c4009
   is executed with non-zero EXECUTE argument.
Packit 6c4009
Packit 6c4009
   pthread_cleanup_push and pthread_cleanup_pop are macros and must always
Packit 6c4009
   be used in matching pairs at the same nesting level of braces.  */
Packit 6c4009
#  define pthread_cleanup_push(routine, arg) \
Packit 6c4009
  do {									      \
Packit 6c4009
    __pthread_cleanup_class __clframe (routine, arg)
Packit 6c4009
Packit 6c4009
/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
Packit 6c4009
   If EXECUTE is non-zero, the handler function is called. */
Packit 6c4009
#  define pthread_cleanup_pop(execute) \
Packit 6c4009
    __clframe.__setdoit (execute);					      \
Packit 6c4009
  } while (0)
Packit 6c4009
Packit 6c4009
#  ifdef __USE_GNU
Packit 6c4009
/* Install a cleanup handler as pthread_cleanup_push does, but also
Packit 6c4009
   saves the current cancellation type and sets it to deferred
Packit 6c4009
   cancellation.  */
Packit 6c4009
#   define pthread_cleanup_push_defer_np(routine, arg) \
Packit 6c4009
  do {									      \
Packit 6c4009
    __pthread_cleanup_class __clframe (routine, arg);			      \
Packit 6c4009
    __clframe.__defer ()
Packit 6c4009
Packit 6c4009
/* Remove a cleanup handler as pthread_cleanup_pop does, but also
Packit 6c4009
   restores the cancellation type that was in effect when the matching
Packit 6c4009
   pthread_cleanup_push_defer was called.  */
Packit 6c4009
#   define pthread_cleanup_pop_restore_np(execute) \
Packit 6c4009
    __clframe.__restore ();						      \
Packit 6c4009
    __clframe.__setdoit (execute);					      \
Packit 6c4009
  } while (0)
Packit 6c4009
#  endif
Packit 6c4009
# else
Packit 6c4009
/* Function called to call the cleanup handler.  As an extern inline
Packit 6c4009
   function the compiler is free to decide inlining the change when
Packit 6c4009
   needed or fall back on the copy which must exist somewhere
Packit 6c4009
   else.  */
Packit 6c4009
__extern_inline void
Packit 6c4009
__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
Packit 6c4009
{
Packit 6c4009
  if (__frame->__do_it)
Packit 6c4009
    __frame->__cancel_routine (__frame->__cancel_arg);
Packit 6c4009
}
Packit 6c4009
Packit 6c4009
/* Install a cleanup handler: ROUTINE will be called with arguments ARG
Packit 6c4009
   when the thread is canceled or calls pthread_exit.  ROUTINE will also
Packit 6c4009
   be called with arguments ARG when the matching pthread_cleanup_pop
Packit 6c4009
   is executed with non-zero EXECUTE argument.
Packit 6c4009
Packit 6c4009
   pthread_cleanup_push and pthread_cleanup_pop are macros and must always
Packit 6c4009
   be used in matching pairs at the same nesting level of braces.  */
Packit 6c4009
#  define pthread_cleanup_push(routine, arg) \
Packit 6c4009
  do {									      \
Packit 6c4009
    struct __pthread_cleanup_frame __clframe				      \
Packit 6c4009
      __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))		      \
Packit 6c4009
      = { .__cancel_routine = (routine), .__cancel_arg = (arg),	 	      \
Packit 6c4009
	  .__do_it = 1 };
Packit 6c4009
Packit 6c4009
/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
Packit 6c4009
   If EXECUTE is non-zero, the handler function is called. */
Packit 6c4009
#  define pthread_cleanup_pop(execute) \
Packit 6c4009
    __clframe.__do_it = (execute);					      \
Packit 6c4009
  } while (0)
Packit 6c4009
Packit 6c4009
#  ifdef __USE_GNU
Packit 6c4009
/* Install a cleanup handler as pthread_cleanup_push does, but also
Packit 6c4009
   saves the current cancellation type and sets it to deferred
Packit 6c4009
   cancellation.  */
Packit 6c4009
#   define pthread_cleanup_push_defer_np(routine, arg) \
Packit 6c4009
  do {									      \
Packit 6c4009
    struct __pthread_cleanup_frame __clframe				      \
Packit 6c4009
      __attribute__ ((__cleanup__ (__pthread_cleanup_routine)))		      \
Packit 6c4009
      = { .__cancel_routine = (routine), .__cancel_arg = (arg),		      \
Packit 6c4009
	  .__do_it = 1 };						      \
Packit 6c4009
    (void) pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED,		      \
Packit 6c4009
				  &__clframe.__cancel_type)
Packit 6c4009
Packit 6c4009
/* Remove a cleanup handler as pthread_cleanup_pop does, but also
Packit 6c4009
   restores the cancellation type that was in effect when the matching
Packit 6c4009
   pthread_cleanup_push_defer was called.  */
Packit 6c4009
#   define pthread_cleanup_pop_restore_np(execute) \
Packit 6c4009
    (void) pthread_setcanceltype (__clframe.__cancel_type, NULL);	      \
Packit 6c4009
    __clframe.__do_it = (execute);					      \
Packit 6c4009
  } while (0)
Packit 6c4009
#  endif
Packit 6c4009
# endif
Packit 6c4009
#else
Packit 6c4009
/* Install a cleanup handler: ROUTINE will be called with arguments ARG
Packit 6c4009
   when the thread is canceled or calls pthread_exit.  ROUTINE will also
Packit 6c4009
   be called with arguments ARG when the matching pthread_cleanup_pop
Packit 6c4009
   is executed with non-zero EXECUTE argument.
Packit 6c4009
Packit 6c4009
   pthread_cleanup_push and pthread_cleanup_pop are macros and must always
Packit 6c4009
   be used in matching pairs at the same nesting level of braces.  */
Packit 6c4009
# define pthread_cleanup_push(routine, arg) \
Packit 6c4009
  do {									      \
Packit 6c4009
    __pthread_unwind_buf_t __cancel_buf;				      \
Packit 6c4009
    void (*__cancel_routine) (void *) = (routine);			      \
Packit 6c4009
    void *__cancel_arg = (arg);						      \
Packit 6c4009
    int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \
Packit 6c4009
					__cancel_buf.__cancel_jmp_buf, 0);    \
Packit 6c4009
    if (__glibc_unlikely (__not_first_call))				      \
Packit 6c4009
      {									      \
Packit 6c4009
	__cancel_routine (__cancel_arg);				      \
Packit 6c4009
	__pthread_unwind_next (&__cancel_buf);				      \
Packit 6c4009
	/* NOTREACHED */						      \
Packit 6c4009
      }									      \
Packit 6c4009
									      \
Packit 6c4009
    __pthread_register_cancel (&__cancel_buf);				      \
Packit 6c4009
    do {
Packit 6c4009
extern void __pthread_register_cancel (__pthread_unwind_buf_t *__buf)
Packit 6c4009
     __cleanup_fct_attribute;
Packit 6c4009
Packit 6c4009
/* Remove a cleanup handler installed by the matching pthread_cleanup_push.
Packit 6c4009
   If EXECUTE is non-zero, the handler function is called. */
Packit 6c4009
# define pthread_cleanup_pop(execute) \
Packit 6c4009
      do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\
Packit 6c4009
    } while (0);							      \
Packit 6c4009
    __pthread_unregister_cancel (&__cancel_buf);			      \
Packit 6c4009
    if (execute)							      \
Packit 6c4009
      __cancel_routine (__cancel_arg);					      \
Packit 6c4009
  } while (0)
Packit 6c4009
extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf)
Packit 6c4009
  __cleanup_fct_attribute;
Packit 6c4009
Packit 6c4009
# ifdef __USE_GNU
Packit 6c4009
/* Install a cleanup handler as pthread_cleanup_push does, but also
Packit 6c4009
   saves the current cancellation type and sets it to deferred
Packit 6c4009
   cancellation.  */
Packit 6c4009
#  define pthread_cleanup_push_defer_np(routine, arg) \
Packit 6c4009
  do {									      \
Packit 6c4009
    __pthread_unwind_buf_t __cancel_buf;				      \
Packit 6c4009
    void (*__cancel_routine) (void *) = (routine);			      \
Packit 6c4009
    void *__cancel_arg = (arg);						      \
Packit 6c4009
    int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *)     \
Packit 6c4009
					__cancel_buf.__cancel_jmp_buf, 0);    \
Packit 6c4009
    if (__glibc_unlikely (__not_first_call))				      \
Packit 6c4009
      {									      \
Packit 6c4009
	__cancel_routine (__cancel_arg);				      \
Packit 6c4009
	__pthread_unwind_next (&__cancel_buf);				      \
Packit 6c4009
	/* NOTREACHED */						      \
Packit 6c4009
      }									      \
Packit 6c4009
									      \
Packit 6c4009
    __pthread_register_cancel_defer (&__cancel_buf);			      \
Packit 6c4009
    do {
Packit 6c4009
extern void __pthread_register_cancel_defer (__pthread_unwind_buf_t *__buf)
Packit 6c4009
     __cleanup_fct_attribute;
Packit 6c4009
Packit 6c4009
/* Remove a cleanup handler as pthread_cleanup_pop does, but also
Packit 6c4009
   restores the cancellation type that was in effect when the matching
Packit 6c4009
   pthread_cleanup_push_defer was called.  */
Packit 6c4009
#  define pthread_cleanup_pop_restore_np(execute) \
Packit 6c4009
      do { } while (0);/* Empty to allow label before pthread_cleanup_pop.  */\
Packit 6c4009
    } while (0);							      \
Packit 6c4009
    __pthread_unregister_cancel_restore (&__cancel_buf);		      \
Packit 6c4009
    if (execute)							      \
Packit 6c4009
      __cancel_routine (__cancel_arg);					      \
Packit 6c4009
  } while (0)
Packit 6c4009
extern void __pthread_unregister_cancel_restore (__pthread_unwind_buf_t *__buf)
Packit 6c4009
  __cleanup_fct_attribute;
Packit 6c4009
# endif
Packit 6c4009
Packit 6c4009
/* Internal interface to initiate cleanup.  */
Packit 6c4009
extern void __pthread_unwind_next (__pthread_unwind_buf_t *__buf)
Packit 6c4009
     __cleanup_fct_attribute __attribute__ ((__noreturn__))
Packit 6c4009
# ifndef SHARED
Packit 6c4009
     __attribute__ ((__weak__))
Packit 6c4009
# endif
Packit 6c4009
     ;
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Function used in the macros.  */
Packit 6c4009
struct __jmp_buf_tag;
Packit 6c4009
extern int __sigsetjmp (struct __jmp_buf_tag *__env, int __savemask) __THROWNL;
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Mutex handling.  */
Packit 6c4009
Packit 6c4009
/* Initialize a mutex.  */
Packit 6c4009
extern int pthread_mutex_init (pthread_mutex_t *__mutex,
Packit 6c4009
			       const pthread_mutexattr_t *__mutexattr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy a mutex.  */
Packit 6c4009
extern int pthread_mutex_destroy (pthread_mutex_t *__mutex)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Try locking a mutex.  */
Packit 6c4009
extern int pthread_mutex_trylock (pthread_mutex_t *__mutex)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Lock a mutex.  */
Packit 6c4009
extern int pthread_mutex_lock (pthread_mutex_t *__mutex)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
#ifdef __USE_XOPEN2K
Packit 6c4009
/* Wait until lock becomes available, or specified time passes. */
Packit 6c4009
extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
Packit 6c4009
				    const struct timespec *__restrict
Packit 6c4009
				    __abstime) __THROWNL __nonnull ((1, 2));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Unlock a mutex.  */
Packit 6c4009
extern int pthread_mutex_unlock (pthread_mutex_t *__mutex)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Get the priority ceiling of MUTEX.  */
Packit 6c4009
extern int pthread_mutex_getprioceiling (const pthread_mutex_t *
Packit 6c4009
					 __restrict __mutex,
Packit 6c4009
					 int *__restrict __prioceiling)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set the priority ceiling of MUTEX to PRIOCEILING, return old
Packit 6c4009
   priority ceiling value in *OLD_CEILING.  */
Packit 6c4009
extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
Packit 6c4009
					 int __prioceiling,
Packit 6c4009
					 int *__restrict __old_ceiling)
Packit 6c4009
     __THROW __nonnull ((1, 3));
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_XOPEN2K8
Packit 6c4009
/* Declare the state protected by MUTEX as consistent.  */
Packit 6c4009
extern int pthread_mutex_consistent (pthread_mutex_t *__mutex)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
# ifdef __USE_GNU
Packit 6c4009
extern int pthread_mutex_consistent_np (pthread_mutex_t *__mutex)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Functions for handling mutex attributes.  */
Packit 6c4009
Packit 6c4009
/* Initialize mutex attribute object ATTR with default attributes
Packit 6c4009
   (kind is PTHREAD_MUTEX_TIMED_NP).  */
Packit 6c4009
extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy mutex attribute object ATTR.  */
Packit 6c4009
extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Get the process-shared flag of the mutex attribute ATTR.  */
Packit 6c4009
extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
Packit 6c4009
					 __restrict __attr,
Packit 6c4009
					 int *__restrict __pshared)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set the process-shared flag of the mutex attribute ATTR.  */
Packit 6c4009
extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
Packit 6c4009
					 int __pshared)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
#if defined __USE_UNIX98 || defined __USE_XOPEN2K8
Packit 6c4009
/* Return in *KIND the mutex kind attribute in *ATTR.  */
Packit 6c4009
extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
Packit 6c4009
				      __attr, int *__restrict __kind)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
Packit 6c4009
   PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
Packit 6c4009
   PTHREAD_MUTEX_DEFAULT).  */
Packit 6c4009
extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* Return in *PROTOCOL the mutex protocol attribute in *ATTR.  */
Packit 6c4009
extern int pthread_mutexattr_getprotocol (const pthread_mutexattr_t *
Packit 6c4009
					  __restrict __attr,
Packit 6c4009
					  int *__restrict __protocol)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
Packit 6c4009
   PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT).  */
Packit 6c4009
extern int pthread_mutexattr_setprotocol (pthread_mutexattr_t *__attr,
Packit 6c4009
					  int __protocol)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR.  */
Packit 6c4009
extern int pthread_mutexattr_getprioceiling (const pthread_mutexattr_t *
Packit 6c4009
					     __restrict __attr,
Packit 6c4009
					     int *__restrict __prioceiling)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING.  */
Packit 6c4009
extern int pthread_mutexattr_setprioceiling (pthread_mutexattr_t *__attr,
Packit 6c4009
					     int __prioceiling)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
#ifdef __USE_XOPEN2K
Packit 6c4009
/* Get the robustness flag of the mutex attribute ATTR.  */
Packit 6c4009
extern int pthread_mutexattr_getrobust (const pthread_mutexattr_t *__attr,
Packit 6c4009
					int *__robustness)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
# ifdef __USE_GNU
Packit 6c4009
extern int pthread_mutexattr_getrobust_np (const pthread_mutexattr_t *__attr,
Packit 6c4009
					   int *__robustness)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
# endif
Packit 6c4009
Packit 6c4009
/* Set the robustness flag of the mutex attribute ATTR.  */
Packit 6c4009
extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
Packit 6c4009
					int __robustness)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
# ifdef __USE_GNU
Packit 6c4009
extern int pthread_mutexattr_setrobust_np (pthread_mutexattr_t *__attr,
Packit 6c4009
					   int __robustness)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
#if defined __USE_UNIX98 || defined __USE_XOPEN2K
Packit 6c4009
/* Functions for handling read-write locks.  */
Packit 6c4009
Packit 6c4009
/* Initialize read-write lock RWLOCK using attributes ATTR, or use
Packit 6c4009
   the default values if later is NULL.  */
Packit 6c4009
extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
Packit 6c4009
				const pthread_rwlockattr_t *__restrict
Packit 6c4009
				__attr) __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy read-write lock RWLOCK.  */
Packit 6c4009
extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Acquire read lock for RWLOCK.  */
Packit 6c4009
extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Try to acquire read lock for RWLOCK.  */
Packit 6c4009
extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
Packit 6c4009
  __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
# ifdef __USE_XOPEN2K
Packit 6c4009
/* Try to acquire read lock for RWLOCK or return after specfied time.  */
Packit 6c4009
extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
Packit 6c4009
				       const struct timespec *__restrict
Packit 6c4009
				       __abstime) __THROWNL __nonnull ((1, 2));
Packit 6c4009
# endif
Packit 6c4009
Packit 6c4009
/* Acquire write lock for RWLOCK.  */
Packit 6c4009
extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Try to acquire write lock for RWLOCK.  */
Packit 6c4009
extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
# ifdef __USE_XOPEN2K
Packit 6c4009
/* Try to acquire write lock for RWLOCK or return after specfied time.  */
Packit 6c4009
extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
Packit 6c4009
				       const struct timespec *__restrict
Packit 6c4009
				       __abstime) __THROWNL __nonnull ((1, 2));
Packit 6c4009
# endif
Packit 6c4009
Packit 6c4009
/* Unlock RWLOCK.  */
Packit 6c4009
extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Functions for handling read-write lock attributes.  */
Packit 6c4009
Packit 6c4009
/* Initialize attribute object ATTR with default values.  */
Packit 6c4009
extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy attribute object ATTR.  */
Packit 6c4009
extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Return current setting of process-shared attribute of ATTR in PSHARED.  */
Packit 6c4009
extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
Packit 6c4009
					  __restrict __attr,
Packit 6c4009
					  int *__restrict __pshared)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set process-shared attribute of ATTR to PSHARED.  */
Packit 6c4009
extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
Packit 6c4009
					  int __pshared)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Return current setting of reader/writer preference.  */
Packit 6c4009
extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *
Packit 6c4009
					  __restrict __attr,
Packit 6c4009
					  int *__restrict __pref)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set reader/write preference.  */
Packit 6c4009
extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
Packit 6c4009
					  int __pref) __THROW __nonnull ((1));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Functions for handling conditional variables.  */
Packit 6c4009
Packit 6c4009
/* Initialize condition variable COND using attributes ATTR, or use
Packit 6c4009
   the default values if later is NULL.  */
Packit 6c4009
extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
Packit 6c4009
			      const pthread_condattr_t *__restrict __cond_attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy condition variable COND.  */
Packit 6c4009
extern int pthread_cond_destroy (pthread_cond_t *__cond)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Wake up one thread waiting for condition variable COND.  */
Packit 6c4009
extern int pthread_cond_signal (pthread_cond_t *__cond)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Wake up all threads waiting for condition variables COND.  */
Packit 6c4009
extern int pthread_cond_broadcast (pthread_cond_t *__cond)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Wait for condition variable COND to be signaled or broadcast.
Packit 6c4009
   MUTEX is assumed to be locked before.
Packit 6c4009
Packit 6c4009
   This function is a cancellation point and therefore not marked with
Packit 6c4009
   __THROW.  */
Packit 6c4009
extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
Packit 6c4009
			      pthread_mutex_t *__restrict __mutex)
Packit 6c4009
     __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Wait for condition variable COND to be signaled or broadcast until
Packit 6c4009
   ABSTIME.  MUTEX is assumed to be locked before.  ABSTIME is an
Packit 6c4009
   absolute time specification; zero is the beginning of the epoch
Packit 6c4009
   (00:00:00 GMT, January 1, 1970).
Packit 6c4009
Packit 6c4009
   This function is a cancellation point and therefore not marked with
Packit 6c4009
   __THROW.  */
Packit 6c4009
extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
Packit 6c4009
				   pthread_mutex_t *__restrict __mutex,
Packit 6c4009
				   const struct timespec *__restrict __abstime)
Packit 6c4009
     __nonnull ((1, 2, 3));
Packit 6c4009
Packit 6c4009
/* Functions for handling condition variable attributes.  */
Packit 6c4009
Packit 6c4009
/* Initialize condition variable attribute ATTR.  */
Packit 6c4009
extern int pthread_condattr_init (pthread_condattr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy condition variable attribute ATTR.  */
Packit 6c4009
extern int pthread_condattr_destroy (pthread_condattr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Get the process-shared flag of the condition variable attribute ATTR.  */
Packit 6c4009
extern int pthread_condattr_getpshared (const pthread_condattr_t *
Packit 6c4009
					__restrict __attr,
Packit 6c4009
					int *__restrict __pshared)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set the process-shared flag of the condition variable attribute ATTR.  */
Packit 6c4009
extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
Packit 6c4009
					int __pshared) __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
#ifdef __USE_XOPEN2K
Packit 6c4009
/* Get the clock selected for the condition variable attribute ATTR.  */
Packit 6c4009
extern int pthread_condattr_getclock (const pthread_condattr_t *
Packit 6c4009
				      __restrict __attr,
Packit 6c4009
				      __clockid_t *__restrict __clock_id)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set the clock selected for the condition variable attribute ATTR.  */
Packit 6c4009
extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
Packit 6c4009
				      __clockid_t __clock_id)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_XOPEN2K
Packit 6c4009
/* Functions to handle spinlocks.  */
Packit 6c4009
Packit 6c4009
/* Initialize the spinlock LOCK.  If PSHARED is nonzero the spinlock can
Packit 6c4009
   be shared between different processes.  */
Packit 6c4009
extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy the spinlock LOCK.  */
Packit 6c4009
extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Wait until spinlock LOCK is retrieved.  */
Packit 6c4009
extern int pthread_spin_lock (pthread_spinlock_t *__lock)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Try to lock spinlock LOCK.  */
Packit 6c4009
extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Release spinlock LOCK.  */
Packit 6c4009
extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Functions to handle barriers.  */
Packit 6c4009
Packit 6c4009
/* Initialize BARRIER with the attributes in ATTR.  The barrier is
Packit 6c4009
   opened when COUNT waiters arrived.  */
Packit 6c4009
extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
Packit 6c4009
				 const pthread_barrierattr_t *__restrict
Packit 6c4009
				 __attr, unsigned int __count)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy a previously dynamically initialized barrier BARRIER.  */
Packit 6c4009
extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Wait on barrier BARRIER.  */
Packit 6c4009
extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
Packit 6c4009
     __THROWNL __nonnull ((1));
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Initialize barrier attribute ATTR.  */
Packit 6c4009
extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy previously dynamically initialized barrier attribute ATTR.  */
Packit 6c4009
extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Get the process-shared flag of the barrier attribute ATTR.  */
Packit 6c4009
extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
Packit 6c4009
					   __restrict __attr,
Packit 6c4009
					   int *__restrict __pshared)
Packit 6c4009
     __THROW __nonnull ((1, 2));
Packit 6c4009
Packit 6c4009
/* Set the process-shared flag of the barrier attribute ATTR.  */
Packit 6c4009
extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
Packit 6c4009
					   int __pshared)
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Functions for handling thread-specific data.  */
Packit 6c4009
Packit 6c4009
/* Create a key value identifying a location in the thread-specific
Packit 6c4009
   data area.  Each thread maintains a distinct thread-specific data
Packit 6c4009
   area.  DESTR_FUNCTION, if non-NULL, is called with the value
Packit 6c4009
   associated to that key when the key is destroyed.
Packit 6c4009
   DESTR_FUNCTION is not called if the value associated is NULL when
Packit 6c4009
   the key is destroyed.  */
Packit 6c4009
extern int pthread_key_create (pthread_key_t *__key,
Packit 6c4009
			       void (*__destr_function) (void *))
Packit 6c4009
     __THROW __nonnull ((1));
Packit 6c4009
Packit 6c4009
/* Destroy KEY.  */
Packit 6c4009
extern int pthread_key_delete (pthread_key_t __key) __THROW;
Packit 6c4009
Packit 6c4009
/* Return current value of the thread-specific data slot identified by KEY.  */
Packit 6c4009
extern void *pthread_getspecific (pthread_key_t __key) __THROW;
Packit 6c4009
Packit 6c4009
/* Store POINTER in the thread-specific data slot identified by KEY. */
Packit 6c4009
extern int pthread_setspecific (pthread_key_t __key,
Packit 6c4009
				const void *__pointer) __THROW ;
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_XOPEN2K
Packit 6c4009
/* Get ID of CPU-time clock for thread THREAD_ID.  */
Packit 6c4009
extern int pthread_getcpuclockid (pthread_t __thread_id,
Packit 6c4009
				  __clockid_t *__clock_id)
Packit 6c4009
     __THROW __nonnull ((2));
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Install handlers to be called when a new process is created with FORK.
Packit 6c4009
   The PREPARE handler is called in the parent process just before performing
Packit 6c4009
   FORK. The PARENT handler is called in the parent process just after FORK.
Packit 6c4009
   The CHILD handler is called in the child process.  Each of the three
Packit 6c4009
   handlers can be NULL, meaning that no handler needs to be called at that
Packit 6c4009
   point.
Packit 6c4009
   PTHREAD_ATFORK can be called several times, in which case the PREPARE
Packit 6c4009
   handlers are called in LIFO order (last added with PTHREAD_ATFORK,
Packit 6c4009
   first called before FORK), and the PARENT and CHILD handlers are called
Packit 6c4009
   in FIFO (first added, first called).  */
Packit 6c4009
Packit 6c4009
extern int pthread_atfork (void (*__prepare) (void),
Packit 6c4009
			   void (*__parent) (void),
Packit 6c4009
			   void (*__child) (void)) __THROW;
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifdef __USE_EXTERN_INLINES
Packit 6c4009
/* Optimizations.  */
Packit 6c4009
__extern_inline int
Packit 6c4009
__NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2))
Packit 6c4009
{
Packit 6c4009
  return __thread1 == __thread2;
Packit 6c4009
}
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
Packit 6c4009
#endif	/* pthread.h */