2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2016 Joyent, Inc.
20 * ISO/IEC C11 threads.h support
23 #include <sys/feature_tests.h>
25 #include <sys/types.h>
34 #if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11)
36 #if !defined(_NORETURN_KYWD)
37 #if __STDC_VERSION__ - 0 >= 201112L
38 #define _NORETURN_KYWD _Noreturn
40 #define _NORETURN_KYWD
41 #endif /* __STDC_VERSION__ - 0 >= 201112L */
42 #endif /* !defined(_NORETURN_KYWD) */
44 #define thread_local _Thread_local
45 #define ONCE_FLAG_INIT PTHREAD_ONCE_INIT
46 #define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS
48 typedef pthread_cond_t cnd_t
;
49 typedef pthread_t thrd_t
;
50 typedef pthread_key_t tss_t
;
51 typedef pthread_mutex_t mtx_t
;
52 typedef void (*tss_dtor_t
)(void *);
53 typedef int (*thrd_start_t
)(void *);
54 typedef pthread_once_t once_flag
;
70 extern void call_once(once_flag
*, void (*)(void));
71 extern int cnd_broadcast(cnd_t
*);
72 extern void cnd_destroy(cnd_t
*);
73 extern int cnd_init(cnd_t
*);
74 extern int cnd_signal(cnd_t
*);
75 extern int cnd_timedwait(cnd_t
*_RESTRICT_KYWD
, mtx_t
*_RESTRICT_KYWD
,
76 const struct timespec
*_RESTRICT_KYWD
);
77 extern int cnd_wait(cnd_t
*, mtx_t
*);
78 extern void mtx_destroy(mtx_t
*);
79 extern int mtx_init(mtx_t
*, int);
80 extern int mtx_lock(mtx_t
*);
81 extern int mtx_timedlock(mtx_t
*_RESTRICT_KYWD
,
82 const struct timespec
*_RESTRICT_KYWD
);
83 extern int mtx_trylock(mtx_t
*);
84 extern int mtx_unlock(mtx_t
*);
85 extern int thrd_create(thrd_t
*, thrd_start_t
, void *);
86 extern thrd_t
thrd_current(void);
87 extern int thrd_detach(thrd_t
);
88 extern int thrd_equal(thrd_t
, thrd_t
);
89 extern _NORETURN_KYWD
void thrd_exit(int) __NORETURN
;
90 extern int thrd_join(thrd_t
, int *);
91 extern int thrd_sleep(const struct timespec
*, struct timespec
*);
92 extern void thrd_yield(void);
93 extern int tss_create(tss_t
*, tss_dtor_t
);
94 extern void tss_delete(tss_t
);
95 extern void *tss_get(tss_t
);
96 extern int tss_set(tss_t
, void *);
98 #endif /* !_STRICT_SYMBOLS | _STDC_C11 */
104 #endif /* _THREADS_H */