25 #if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 201112L)
27 #include <sys/cdefs.h>
46 #define thrd_success 0
48 #define thrd_timedout -2
64 #define ONCE_FLAG_INIT KTHREAD_ONCE_INIT
93 #define mtx_plain (1 << 0)
94 #define mtx_recursive (1 << 1)
95 #define mtx_timed (1 << 2)
119 extern int mtx_init(mtx_t *mtx,
int type);
159 const struct timespec *restrict ts);
271 extern int cnd_timedwait(cnd_t *restrict cond, mtx_t *restrict mtx,
272 const struct timespec *restrict ts);
289 extern int cnd_wait(cnd_t *cond, mtx_t *mtx);
362 extern int thrd_equal(thrd_t thr0, thrd_t thr1);
372 extern _Noreturn
void thrd_exit(
int res);
393 extern int thrd_join(thrd_t thr,
int *res);
415 extern int thrd_sleep(
const struct timespec *duration,
416 struct timespec *remaining);
434 #define TSS_DTOR_ITERATIONS 1
485 extern void *
tss_get(tss_t key);
498 extern int tss_set(tss_t key,
void *val);
Thread-local storage support.
int mtx_trylock(mtx_t *mtx)
Attempt to acquire a mutex lock.
condvar_t cnd_t
C11 condition variable type.
Definition: threads.h:199
Object type backing kthread_once.
Definition: once.h:34
int mtx_timedlock(mtx_t *restrict mtx, const struct timespec *restrict ts)
Lock a mutex lock with a timeout.
kthread_t * thrd_t
C11 thread identifier type.
Definition: threads.h:298
void mtx_destroy(mtx_t *mtx)
Deinitialize a mutex lock.
int cnd_signal(cnd_t *cond)
Signal one thread locked on a condition variable.
_Noreturn void thrd_exit(int res)
Terminate the current thread immediately.
int thrd_detach(thrd_t thr)
Detach a running thread.
void * tss_get(tss_t key)
Retrieve the value associated with a thread-specific storage key.
kthread_once_t once_flag
Object type backing call_once.
Definition: threads.h:61
int mtx_unlock(mtx_t *mtx)
Unlock a previously acquired lock.
mutex_t mtx_t
C11 mutual exclusion lock type.
Definition: threads.h:84
int thrd_sleep(const struct timespec *duration, struct timespec *remaining)
Put the currently running thread to sleep.
int mtx_lock(mtx_t *mtx)
Lock a mutex lock.
thrd_t thrd_current(void)
Return the identifier of the currently running thread.
Dynamic package initialization.
int thrd_join(thrd_t thr, int *res)
Join a running thread.
int cnd_init(cnd_t *cond)
Initialize a condition variable.
Condition variable.
Definition: cond.h:61
Mutual exclusion lock type.
Definition: mutex.h:70
int thrd_equal(thrd_t thr0, thrd_t thr1)
Compare two threads for equality.
int thrd_create(thrd_t *thr, thrd_start_t func, void *arg)
Create and start a new thread.
void thrd_yield(void)
Yield the current thread's timeslice.
void(* tss_dtor_t)(void *)
C11 thread-specific storage destructor type.
Definition: threads.h:453
void call_once(once_flag *flag, void(*func)(void))
Call a function one time, no matter how many threads try.
Structure describing one running thread.
Definition: thread.h:90
int tss_set(tss_t key, void *val)
Set the value associated with a thread-specific storage key.
int cnd_wait(cnd_t *cond, mtx_t *mtx)
Wait on a condition variable.
kthread_key_t tss_t
C11 thread-specific storage type.
Definition: threads.h:444
int(* thrd_start_t)(void *)
C11 thread start function type.
Definition: threads.h:307
void cnd_destroy(cnd_t *cond)
Deinitialize a condition variable.
int cnd_timedwait(cnd_t *restrict cond, mtx_t *restrict mtx, const struct timespec *restrict ts)
Wait on a condition variable (with a timeout).
int tss_create(tss_t *key, tss_dtor_t dtor)
Create a thread-specific storage pointer.
void tss_delete(tss_t key)
Free resources associated with a thread-specific storage key.
int kthread_key_t
Thread-local storage key type.
Definition: tls.h:27
int cnd_broadcast(cnd_t *cond)
Broadcast to all threads locked on a condition variable.
int mtx_init(mtx_t *mtx, int type)
Initialize a mutex lock.