| [aad342c] | 1 | /* threads.h: The ABC representation of standard C library.
|
|---|
| 2 | * Based on C11 Standard.
|
|---|
| 3 | */
|
|---|
| 4 | #ifndef _THREADS_
|
|---|
| 5 | #define _THREADS_
|
|---|
| 6 |
|
|---|
| 7 | #include <time.h>
|
|---|
| 8 |
|
|---|
| 9 | /* Macros */
|
|---|
| 10 | #define thread_local _Thread_local
|
|---|
| 11 | #define ONCE_FLAG_INIT 0
|
|---|
| 12 | #define TSS_DTOR_ITERATIONS 1
|
|---|
| 13 |
|
|---|
| 14 | /* Types */
|
|---|
| 15 | typedef struct cnd_t cnd_t;
|
|---|
| 16 | typedef struct thrd_t thrd_t;
|
|---|
| 17 | typedef struct tss_t tss_t;
|
|---|
| 18 | typedef struct mtx_t mtx_t;
|
|---|
| 19 | typedef void (*tss_dtor_t)(void*);
|
|---|
| 20 | typedef int (*thrd_start_t)(int);
|
|---|
| 21 | typedef struct once_flag once_flag;
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | /* Functions */
|
|---|
| 25 | void call_once(once_flag *flag, void (*func)(void));
|
|---|
| 26 | int cnd_broadcast(cnd_t *cond);
|
|---|
| 27 | void cnd_destroy(cnd_t *cond);
|
|---|
| 28 | int cnd_init(cnd_t *cond);
|
|---|
| 29 | int cnd_signal(cnd_t *cond);
|
|---|
| 30 | int cnd_timedwait(cnd_t *restrict cond,mtx_t *restrict mtx,
|
|---|
| 31 | const struct timespec *restrict ts);
|
|---|
| 32 | int cnd_wait(cnd_t *cond, mtx_t *mtx);
|
|---|
| 33 | void mtx_destroy(mtx_t *mtx);
|
|---|
| 34 | int mtx_init(mtx_t *mtx, int type);
|
|---|
| 35 | int mtx_lock(mtx_t *mtx);
|
|---|
| 36 | int mtx_timedlock(mtx_t *restrict mtx, const struct timespec *restrict ts);
|
|---|
| 37 | int mtx_trylock(mtx_t *mtx);
|
|---|
| 38 | int mtx_unlock(mtx_t *mtx);
|
|---|
| 39 | int thrd_create(thrd_t *thr, thrd_start_t func,void *arg);
|
|---|
| 40 | thrd_t thrd_current(void);
|
|---|
| 41 | int thrd_detach(thrd_t thr);
|
|---|
| 42 | int thrd_equal(thrd_t thr0, thrd_t thr1);
|
|---|
| 43 | _Noreturn void thrd_exit(int res);
|
|---|
| 44 | int thrd_join(thrd_t thr, int *res);
|
|---|
| 45 | int thrd_sleep(const struct timespec *duration,struct timespec *remaining);
|
|---|
| 46 | void thrd_yield(void);
|
|---|
| 47 | int tss_create(tss_t *key, tss_dtor_t dtor);
|
|---|
| 48 | void tss_delete(tss_t key);
|
|---|
| 49 | void *tss_get(tss_t key);
|
|---|
| 50 | int tss_set(tss_t key, void *val);
|
|---|
| 51 |
|
|---|
| 52 | #endif
|
|---|