13.10. Data Definitions for libpthread

This section defines global identifiers and their values that are associated with interfaces contained in libpthread. These definitions are organized into groups that correspond to system headers. This convention is used as a convenience for the reader, and does not imply the existence of these headers, or their content. Where an interface is defined as requiring a particular system header file all of the data definitions for that system header file presented here shall be in effect.

This section gives data definitions to promote binary application portability, not to repeat source interface definitions available elsewhere. System providers and application developers should use this ABI to supplement - not to replace - source interface definition specifications.

This specification uses the ISO C (1999) C Language as the reference programming language, and data definitions are specified in ISO C format. The C language is used here as a convenient notation. Using a C language description of these data objects does not preclude their use by other programming languages.

13.10.1. pthread.h


#define PTHREAD_MUTEX_DEFAULT	0
#define PTHREAD_MUTEX_NORMAL	0
#define PTHREAD_SCOPE_SYSTEM	0
#define PTHREAD_MUTEX_RECURSIVE	1
#define PTHREAD_SCOPE_PROCESS	1
#define PTHREAD_MUTEX_ERRORCHECK	2
#define PTHREAD_RWLOCK_DEFAULT_NP	2
#define __SIZEOF_PTHREAD_BARRIERATTR_T	4
#define __SIZEOF_PTHREAD_CONDATTR_T	4
#define __SIZEOF_PTHREAD_MUTEXATTR_T	4
#define __SIZEOF_PTHREAD_COND_T	48
#define __SIZEOF_PTHREAD_RWLOCKATTR_T	8
#define pthread_cleanup_push(routine,arg)	\
        {struct _pthread_cleanup_buffer _buffer;\
        _pthread_cleanup_push(&_buffer,(routine),(arg));
#define pthread_cleanup_pop(execute)	_pthread_cleanup_pop(&_buffer,(execute));}
#define PTHREAD_COND_INITIALIZER	{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }

struct _pthread_cleanup_buffer {
    void (*__routine) (void *);
    void *__arg;
    int __canceltype;
    struct _pthread_cleanup_buffer *__prev;
};
typedef unsigned int pthread_key_t;
typedef int pthread_once_t;
typedef volatile int pthread_spinlock_t;
typedef union {
    char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];
    int __align;
} pthread_barrierattr_t;

typedef unsigned long int pthread_t;

typedef union {
    struct __pthread_mutex_s __data;
    char __size[__SIZEOF_PTHREAD_MUTEX_T];
    long int __align;
} pthread_mutex_t;
typedef union {
    char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];
    int __align;
} pthread_mutexattr_t;

typedef union {
    char __size[__SIZEOF_PTHREAD_ATTR_T];
    long int __align;
} pthread_attr_t;

typedef union {
    struct {
	int __lock;
	unsigned int __futex;
	unsigned long long int __total_seq;
	unsigned long long int __wakeup_seq;
	unsigned long long int __woken_seq;
	void *__mutex;
	unsigned int __nwaiters;
	unsigned int __broadcast_seq;
    } __data;
    char __size[__SIZEOF_PTHREAD_COND_T];
    long long int __align;
} pthread_cond_t;
typedef union {
    char __size[__SIZEOF_PTHREAD_CONDATTR_T];
    int __align;
} pthread_condattr_t;

typedef union {
    char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];
    long int __align;
} pthread_rwlockattr_t;

#define PTHREAD_CREATE_JOINABLE	0
#define PTHREAD_INHERIT_SCHED	0
#define PTHREAD_ONCE_INIT	0
#define PTHREAD_PROCESS_PRIVATE	0
#define PTHREAD_CREATE_DETACHED	1
#define PTHREAD_EXPLICIT_SCHED	1
#define PTHREAD_PROCESS_SHARED	1

#define PTHREAD_CANCELED	((void*)-1)
#define PTHREAD_CANCEL_DEFERRED	0
#define PTHREAD_CANCEL_ENABLE	0
#define PTHREAD_CANCEL_ASYNCHRONOUS	1
#define PTHREAD_CANCEL_DISABLE	1

extern int __register_atfork(void (*)(void), void (*)(void),
			     void (*)(void), void *);
extern void _pthread_cleanup_pop(struct _pthread_cleanup_buffer *, int);
extern void _pthread_cleanup_push(struct _pthread_cleanup_buffer *,
				  void (*)(void *), void *);
extern int pthread_attr_destroy(pthread_attr_t * __attr);
extern int pthread_attr_getdetachstate(const pthread_attr_t * __attr,
				       int *__detachstate);
extern int pthread_attr_getguardsize(const pthread_attr_t * __attr,
				     size_t * __guardsize);
extern int pthread_attr_getinheritsched(const pthread_attr_t * __attr,
					int *__inherit);
extern int pthread_attr_getschedparam(const pthread_attr_t * __attr,
				      struct sched_param *__param);
extern int pthread_attr_getschedpolicy(const pthread_attr_t * __attr,
				       int *__policy);
extern int pthread_attr_getscope(const pthread_attr_t * __attr,
				 int *__scope);
extern int pthread_attr_getstack(const pthread_attr_t * __attr,
				 void **__stackaddr, size_t * __stacksize);
extern int pthread_attr_getstackaddr(const pthread_attr_t * __attr,
				     void **__stackaddr);
extern int pthread_attr_getstacksize(const pthread_attr_t * __attr,
				     size_t * __stacksize);
extern int pthread_attr_init(pthread_attr_t * __attr);
extern int pthread_attr_setdetachstate(pthread_attr_t * __attr,
				       int __detachstate);
extern int pthread_attr_setguardsize(pthread_attr_t * __attr,
				     size_t __guardsize);
extern int pthread_attr_setinheritsched(pthread_attr_t * __attr,
					int __inherit);
extern int pthread_attr_setschedparam(pthread_attr_t * __attr,
				      const struct sched_param *__param);
extern int pthread_attr_setschedpolicy(pthread_attr_t * __attr,
				       int __policy);
extern int pthread_attr_setscope(pthread_attr_t * __attr, int __scope);
extern int pthread_attr_setstack(pthread_attr_t * __attr,
				 void *__stackaddr, size_t __stacksize);
extern int pthread_attr_setstackaddr(pthread_attr_t * __attr,
				     void *__stackaddr);
extern int pthread_attr_setstacksize(pthread_attr_t * __attr,
				     size_t __stacksize);
extern int pthread_barrier_destroy(pthread_barrier_t * __barrier);
extern int pthread_barrier_init(pthread_barrier_t * __barrier,
				const pthread_barrierattr_t * __attr,
				unsigned int __count);
extern int pthread_barrier_wait(pthread_barrier_t * __barrier);
extern int pthread_barrierattr_destroy(pthread_barrierattr_t * __attr);
extern int pthread_barrierattr_getpshared(const pthread_barrierattr_t *
					  __attr, int *__pshared);
extern int pthread_barrierattr_init(pthread_barrierattr_t * __attr);
extern int pthread_barrierattr_setpshared(pthread_barrierattr_t * __attr,
					  int __pshared);
extern int pthread_cancel(pthread_t __th);
extern int pthread_cond_broadcast(pthread_cond_t * __cond);
extern int pthread_cond_destroy(pthread_cond_t * __cond);
extern int pthread_cond_init(pthread_cond_t * __cond,
			     const pthread_condattr_t * __cond_attr);
extern int pthread_cond_signal(pthread_cond_t * __cond);
extern int pthread_cond_timedwait(pthread_cond_t * __cond,
				  pthread_mutex_t * __mutex,
				  const struct timespec *__abstime);
extern int pthread_cond_wait(pthread_cond_t * __cond,
			     pthread_mutex_t * __mutex);
extern int pthread_condattr_destroy(pthread_condattr_t * __attr);
extern int pthread_condattr_getpshared(const pthread_condattr_t * __attr,
				       int *__pshared);
extern int pthread_condattr_init(pthread_condattr_t * __attr);
extern int pthread_condattr_setpshared(pthread_condattr_t * __attr,
				       int __pshared);
extern int pthread_create(pthread_t * __newthread,
			  const pthread_attr_t * __attr,
			  void *(*__start_routine) (void *), void *__arg);
extern int pthread_detach(pthread_t __th);
extern int pthread_equal(pthread_t __thread1, pthread_t __thread2);
extern void pthread_exit(void *__retval);
extern int pthread_getconcurrency(void);
extern int pthread_getcpuclockid(pthread_t __thread_id,
				 clockid_t * __clock_id);
extern int pthread_getschedparam(pthread_t __target_thread, int *__policy,
				 struct sched_param *__param);
extern void *pthread_getspecific(pthread_key_t __key);
extern int pthread_join(pthread_t __th, void **__thread_return);
extern int pthread_key_create(pthread_key_t * __key,
			      void (*__destr_function) (void *));
extern int pthread_key_delete(pthread_key_t __key);
extern int pthread_mutex_destroy(pthread_mutex_t * __mutex);
extern int pthread_mutex_getprioceiling(const pthread_mutex_t * __mutex,
					int *__prioceiling);
extern int pthread_mutex_init(pthread_mutex_t * __mutex,
			      const pthread_mutexattr_t * __mutexattr);
extern int pthread_mutex_lock(pthread_mutex_t * __mutex);
extern int pthread_mutex_setprioceiling(pthread_mutex_t * __mutex,
					int __prioceiling,
					int *__old_ceiling);
extern int pthread_mutex_timedlock(pthread_mutex_t * __mutex,
				   const struct timespec *__abstime);
extern int pthread_mutex_trylock(pthread_mutex_t * __mutex);
extern int pthread_mutex_unlock(pthread_mutex_t * __mutex);
extern int pthread_mutexattr_destroy(pthread_mutexattr_t * __attr);
extern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *
					    __attr, int *__prioceiling);
extern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *
					 __attr, int *__protocol);
extern int pthread_mutexattr_getpshared(const pthread_mutexattr_t * __attr,
					int *__pshared);
extern int pthread_mutexattr_gettype(const pthread_mutexattr_t * __attr,
				     int *__kind);
extern int pthread_mutexattr_init(pthread_mutexattr_t * __attr);
extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t * __attr,
					    int __prioceiling);
extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t * __attr,
					 int __protocol);
extern int pthread_mutexattr_setpshared(pthread_mutexattr_t * __attr,
					int __pshared);
extern int pthread_mutexattr_settype(pthread_mutexattr_t * __attr,
				     int __kind);
extern int pthread_once(pthread_once_t * __once_control,
			void (*__init_routine) (void));
extern int pthread_rwlock_destroy(pthread_rwlock_t * __rwlock);
extern int pthread_rwlock_init(pthread_rwlock_t * __rwlock,
			       const pthread_rwlockattr_t * __attr);
extern int pthread_rwlock_rdlock(pthread_rwlock_t * __rwlock);
extern int pthread_rwlock_timedrdlock(pthread_rwlock_t * __rwlock,
				      const struct timespec *__abstime);
extern int pthread_rwlock_timedwrlock(pthread_rwlock_t * __rwlock,
				      const struct timespec *__abstime);
extern int pthread_rwlock_tryrdlock(pthread_rwlock_t * __rwlock);
extern int pthread_rwlock_trywrlock(pthread_rwlock_t * __rwlock);
extern int pthread_rwlock_unlock(pthread_rwlock_t * __rwlock);
extern int pthread_rwlock_wrlock(pthread_rwlock_t * __rwlock);
extern int pthread_rwlockattr_destroy(pthread_rwlockattr_t * __attr);
extern int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *
					 __attr, int *__pshared);
extern int pthread_rwlockattr_init(pthread_rwlockattr_t * __attr);
extern int pthread_rwlockattr_setpshared(pthread_rwlockattr_t * __attr,
					 int __pshared);
extern pthread_t pthread_self(void);
extern int pthread_setcancelstate(int __state, int *__oldstate);
extern int pthread_setcanceltype(int __type, int *__oldtype);
extern int pthread_setconcurrency(int __level);
extern int pthread_setschedparam(pthread_t __target_thread, int __policy,
				 const struct sched_param *__param);
extern int pthread_setschedprio(pthread_t __target_thread, int __prio);
extern int pthread_setspecific(pthread_key_t __key, const void *__pointer);
extern int pthread_spin_destroy(pthread_spinlock_t * __lock);
extern int pthread_spin_init(pthread_spinlock_t * __lock, int __pshared);
extern int pthread_spin_lock(pthread_spinlock_t * __lock);
extern int pthread_spin_trylock(pthread_spinlock_t * __lock);
extern int pthread_spin_unlock(pthread_spinlock_t * __lock);
extern void pthread_testcancel(void);

13.10.2. semaphore.h


typedef union {
    char __size[__SIZEOF_SEM_T];
    long int __align;
} sem_t;

#define SEM_FAILED	((sem_t*)0)

#define SEM_VALUE_MAX	((int)((~0u)>>1))

extern int sem_close(sem_t * __sem);
extern int sem_destroy(sem_t * __sem);
extern int sem_getvalue(sem_t * __sem, int *__sval);
extern int sem_init(sem_t * __sem, int __pshared, unsigned int __value);
extern sem_t *sem_open(const char *__name, int __oflag, ...);
extern int sem_post(sem_t * __sem);
extern int sem_timedwait(sem_t * __sem, const struct timespec *__abstime);
extern int sem_trywait(sem_t * __sem);
extern int sem_unlink(const char *__name);
extern int sem_wait(sem_t * __sem);