123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736 |
- #ifndef _PTHREAD_H
- #define _PTHREAD_H 1
- #include <features.h>
- #include <sched.h>
- #include <time.h>
- #include <signal.h>
- #include <bits/pthreadtypes.h>
- #include <bits/initspin.h>
- __BEGIN_DECLS
- #define PTHREAD_MUTEX_INITIALIZER \
- {0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __LOCK_INITIALIZER}
- #ifdef __USE_GNU
- # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
- {0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP, __LOCK_INITIALIZER}
- # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \
- {0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, __LOCK_INITIALIZER}
- # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \
- {0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP, __LOCK_INITIALIZER}
- #endif
- #define PTHREAD_COND_INITIALIZER {__LOCK_INITIALIZER, 0}
- #if defined __USE_UNIX98 || defined __USE_XOPEN2K
- # define PTHREAD_RWLOCK_INITIALIZER \
- { __LOCK_INITIALIZER, 0, NULL, NULL, NULL, \
- PTHREAD_RWLOCK_DEFAULT_NP, PTHREAD_PROCESS_PRIVATE }
- #endif
- #ifdef __USE_GNU
- # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \
- { __LOCK_INITIALIZER, 0, NULL, NULL, NULL, \
- PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP, PTHREAD_PROCESS_PRIVATE }
- #endif
- enum
- {
- PTHREAD_CREATE_JOINABLE,
- #define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
- PTHREAD_CREATE_DETACHED
- #define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
- };
- enum
- {
- PTHREAD_INHERIT_SCHED,
- #define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
- PTHREAD_EXPLICIT_SCHED
- #define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
- };
- enum
- {
- PTHREAD_SCOPE_SYSTEM,
- #define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
- PTHREAD_SCOPE_PROCESS
- #define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
- };
- enum
- {
- PTHREAD_MUTEX_ADAPTIVE_NP,
- PTHREAD_MUTEX_RECURSIVE_NP,
- PTHREAD_MUTEX_ERRORCHECK_NP,
- PTHREAD_MUTEX_TIMED_NP
- #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
- ,
- PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_ADAPTIVE_NP,
- PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP,
- PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP,
- PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL
- #endif
- #ifdef __USE_GNU
-
- , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_ADAPTIVE_NP
- #endif
- };
- enum
- {
- PTHREAD_PROCESS_PRIVATE,
- #define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
- PTHREAD_PROCESS_SHARED
- #define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
- };
- #if defined __USE_UNIX98 || defined __USE_XOPEN2K
- enum
- {
- PTHREAD_RWLOCK_PREFER_READER_NP,
- PTHREAD_RWLOCK_PREFER_WRITER_NP,
- PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
- PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_WRITER_NP
- };
- #endif
- #define PTHREAD_ONCE_INIT 0
- #ifdef __USE_XOPEN2K
- # define PTHREAD_BARRIER_SERIAL_THREAD -1
- #endif
- struct _pthread_cleanup_buffer
- {
- void (*__routine) (void *);
- void *__arg;
- int __canceltype;
- struct _pthread_cleanup_buffer *__prev;
- };
- enum
- {
- PTHREAD_CANCEL_ENABLE,
- #define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
- PTHREAD_CANCEL_DISABLE
- #define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
- };
- enum
- {
- PTHREAD_CANCEL_DEFERRED,
- #define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
- PTHREAD_CANCEL_ASYNCHRONOUS
- #define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
- };
- #define PTHREAD_CANCELED ((void *) -1)
- extern int pthread_create (pthread_t *__restrict __threadp,
- const pthread_attr_t *__restrict __attr,
- void *(*__start_routine) (void *),
- void *__restrict __arg) __THROWNL;
- extern pthread_t pthread_self (void) __THROW;
- extern int pthread_equal (pthread_t __thread1, pthread_t __thread2) __THROW;
- extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
- extern int pthread_join (pthread_t __th, void **__thread_return);
- #ifdef __USE_GNU
- extern int pthread_tryjoin_np (pthread_t __th, void **__thread_return) __THROW;
- extern int pthread_timedjoin_np (pthread_t __th, void **__thread_return,
- __const struct timespec *__abstime);
- #endif
- extern int pthread_detach (pthread_t __th) __THROW;
- extern int pthread_attr_init (pthread_attr_t *__attr) __THROW;
- extern int pthread_attr_destroy (pthread_attr_t *__attr) __THROW;
- extern int pthread_attr_setdetachstate (pthread_attr_t *__attr,
- int __detachstate) __THROW;
- extern int pthread_attr_getdetachstate (const pthread_attr_t *__attr,
- int *__detachstate) __THROW;
- extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
- const struct sched_param *__restrict
- __param) __THROW;
- extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict
- __attr,
- struct sched_param *__restrict __param)
- __THROW;
- extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy)
- __THROW;
- extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict
- __attr, int *__restrict __policy)
- __THROW;
- extern int pthread_attr_setinheritsched (pthread_attr_t *__attr,
- int __inherit) __THROW;
- extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict
- __attr, int *__restrict __inherit)
- __THROW;
- extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope)
- __THROW;
- extern int pthread_attr_getscope (const pthread_attr_t *__restrict __attr,
- int *__restrict __scope) __THROW;
- extern int pthread_attr_setguardsize (pthread_attr_t *__attr,
- size_t __guardsize) __THROW;
- extern int pthread_attr_getguardsize (const pthread_attr_t *__restrict
- __attr, size_t *__restrict __guardsize)
- __THROW;
- #if 0
- extern int pthread_attr_setstackaddr (pthread_attr_t *__attr,
- void *__stackaddr) __THROW;
- extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict
- __attr, void **__restrict __stackaddr)
- __THROW;
- #endif
- #ifdef __USE_XOPEN2K
- extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
- size_t __stacksize) __THROW;
- extern int pthread_attr_getstack (const pthread_attr_t *__restrict __attr,
- void **__restrict __stackaddr,
- size_t *__restrict __stacksize) __THROW;
- #endif
- extern int pthread_attr_setstacksize (pthread_attr_t *__attr,
- size_t __stacksize) __THROW;
- extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict
- __attr, size_t *__restrict __stacksize)
- __THROW;
- #if 0
- #ifdef __USE_GNU
- extern int pthread_getattr_np (pthread_t __th, pthread_attr_t *__attr) __THROW;
- #endif
- #endif
- extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
- const struct sched_param *__param)
- __THROW;
- extern int pthread_getschedparam (pthread_t __target_thread,
- int *__restrict __policy,
- struct sched_param *__restrict __param)
- __THROW;
- #ifdef __USE_UNIX98
- extern int pthread_getconcurrency (void) __THROW;
- extern int pthread_setconcurrency (int __level) __THROW;
- #endif
- #ifdef __USE_GNU
- #define pthread_yield() sched_yield()
- #endif
- extern int pthread_mutex_init (pthread_mutex_t *__restrict __mutex,
- const pthread_mutexattr_t *__restrict
- __mutex_attr) __THROW;
- extern int pthread_mutex_destroy (pthread_mutex_t *__mutex) __THROW;
- extern int pthread_mutex_trylock (pthread_mutex_t *__mutex) __THROWNL;
- extern int pthread_mutex_lock (pthread_mutex_t *__mutex) __THROWNL;
- #ifdef __USE_XOPEN2K
- extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
- const struct timespec *__restrict
- __abstime) __THROWNL;
- #endif
- extern int pthread_mutex_unlock (pthread_mutex_t *__mutex) __THROWNL;
- extern int pthread_mutexattr_init (pthread_mutexattr_t *__attr) __THROW;
- extern int pthread_mutexattr_destroy (pthread_mutexattr_t *__attr) __THROW;
- extern int pthread_mutexattr_getpshared (const pthread_mutexattr_t *
- __restrict __attr,
- int *__restrict __pshared) __THROW;
- extern int pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
- int __pshared) __THROW;
- #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
- extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind)
- __THROW;
- extern int pthread_mutexattr_gettype (const pthread_mutexattr_t *__restrict
- __attr, int *__restrict __kind) __THROW;
- #endif
- extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
- const pthread_condattr_t *__restrict
- __cond_attr) __THROW;
- libpthread_hidden_proto(pthread_cond_init)
- extern int pthread_cond_destroy (pthread_cond_t *__cond) __THROW;
- libpthread_hidden_proto(pthread_cond_destroy)
- extern int pthread_cond_signal (pthread_cond_t *__cond) __THROWNL;
- libpthread_hidden_proto(pthread_cond_signal)
- extern int pthread_cond_broadcast (pthread_cond_t *__cond) __THROWNL;
- libpthread_hidden_proto(pthread_cond_broadcast)
- extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
- pthread_mutex_t *__restrict __mutex);
- libpthread_hidden_proto(pthread_cond_wait)
- extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
- pthread_mutex_t *__restrict __mutex,
- const struct timespec *__restrict
- __abstime);
- libpthread_hidden_proto(pthread_cond_timedwait)
- extern int pthread_condattr_init (pthread_condattr_t *__attr) __THROW;
- libpthread_hidden_proto(pthread_condattr_init)
- extern int pthread_condattr_destroy (pthread_condattr_t *__attr) __THROW;
- libpthread_hidden_proto(pthread_condattr_destroy)
- extern int pthread_condattr_getpshared (const pthread_condattr_t *
- __restrict __attr,
- int *__restrict __pshared) __THROW;
- extern int pthread_condattr_setpshared (pthread_condattr_t *__attr,
- int __pshared) __THROW;
- #ifdef __USE_XOPEN2K
- extern int pthread_condattr_getclock (const pthread_condattr_t *
- __restrict __attr,
- __clockid_t *__restrict __clock_id)
- __THROW __nonnull ((1, 2));
- extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
- __clockid_t __clock_id)
- __THROW __nonnull ((1));
- #endif
- #if defined __USE_UNIX98 || defined __USE_XOPEN2K
- extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
- const pthread_rwlockattr_t *__restrict
- __attr) __THROW;
- extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock) __THROW;
- extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock) __THROWNL;
- extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock) __THROWNL;
- # ifdef __USE_XOPEN2K
- extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
- const struct timespec *__restrict
- __abstime) __THROWNL;
- # endif
- extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock) __THROWNL;
- extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock) __THROWNL;
- # ifdef __USE_XOPEN2K
- extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
- const struct timespec *__restrict
- __abstime) __THROWNL;
- # endif
- extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock) __THROWNL;
- extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr) __THROW;
- extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr) __THROW;
- extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
- __restrict __attr,
- int *__restrict __pshared) __THROW;
- extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
- int __pshared) __THROW;
- extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *__attr,
- int *__pref) __THROW;
- extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
- int __pref) __THROW;
- #endif
- #if 0
- #ifdef __USE_XOPEN2K
- extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
- __THROW;
- extern int pthread_spin_destroy (pthread_spinlock_t *__lock) __THROW;
- extern int pthread_spin_lock (pthread_spinlock_t *__lock) __THROWNL;
- extern int pthread_spin_trylock (pthread_spinlock_t *__lock) __THROWNL;
- extern int pthread_spin_unlock (pthread_spinlock_t *__lock) __THROWNL;
- extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
- const pthread_barrierattr_t *__restrict
- __attr, unsigned int __count) __THROW;
- extern int pthread_barrier_destroy (pthread_barrier_t *__barrier) __THROW;
- extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr) __THROW;
- extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr) __THROW;
- extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
- __restrict __attr,
- int *__restrict __pshared) __THROW;
- extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
- int __pshared) __THROW;
- extern int pthread_barrier_wait (pthread_barrier_t *__barrier) __THROWNL;
- #endif
- #endif
- extern int pthread_key_create (pthread_key_t *__key,
- void (*__destr_function) (void *)) __THROW;
- extern int pthread_key_delete (pthread_key_t __key) __THROW;
- extern int pthread_setspecific (pthread_key_t __key,
- const void *__pointer) __THROW;
- extern void *pthread_getspecific (pthread_key_t __key) __THROW;
- extern int pthread_once (pthread_once_t *__once_control,
- void (*__init_routine) (void));
- extern int pthread_setcancelstate (int __state, int *__oldstate);
- extern int pthread_setcanceltype (int __type, int *__oldtype);
- extern int pthread_cancel (pthread_t __cancelthread);
- extern void pthread_testcancel (void);
- #define pthread_cleanup_push(routine,arg) \
- { struct _pthread_cleanup_buffer _buffer; \
- _pthread_cleanup_push (&_buffer, (routine), (arg));
- extern void _pthread_cleanup_push (struct _pthread_cleanup_buffer *__buffer,
- void (*__routine) (void *),
- void *__arg) __THROW;
- #define pthread_cleanup_pop(execute) \
- _pthread_cleanup_pop (&_buffer, (execute)); }
- extern void _pthread_cleanup_pop (struct _pthread_cleanup_buffer *__buffer,
- int __execute) __THROW;
- #ifdef __USE_GNU
- # define pthread_cleanup_push_defer_np(routine,arg) \
- { struct _pthread_cleanup_buffer _buffer; \
- _pthread_cleanup_push_defer (&_buffer, (routine), (arg));
- extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
- void (*__routine) (void *),
- void *__arg) __THROW;
- extern void __pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *__buffer,
- void (*__routine) (void *),
- void *__arg) __THROW;
- # define pthread_cleanup_pop_restore_np(execute) \
- _pthread_cleanup_pop_restore (&_buffer, (execute)); }
- extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
- int __execute) __THROW;
- extern void __pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *__buffer,
- int __execute) __THROW;
- #endif
- #if 0
- #ifdef __USE_XOPEN2K
- extern int pthread_getcpuclockid (pthread_t __thread_id,
- clockid_t *__clock_id) __THROW;
- #endif
- #endif
- #include <bits/sigthread.h>
- #ifdef __ARCH_USE_MMU__
- extern int pthread_atfork (void (*__prepare) (void),
- void (*__parent) (void),
- void (*__child) (void)) __THROW;
- #endif
- extern void pthread_kill_other_threads_np (void) __THROW;
- __END_DECLS
- #endif
|