24 #ifndef _TINYCTHREAD_H_ 25 #define _TINYCTHREAD_H_ 51 #if !defined(_TTHREAD_PLATFORM_DEFINED_) 52 #if defined(_WIN32) || defined(__WIN32__) || defined(__WINDOWS__) 53 #define _TTHREAD_WIN32_ 55 #define _TTHREAD_POSIX_ 57 #define _TTHREAD_PLATFORM_DEFINED_ 61 #if defined(_TTHREAD_POSIX_) 63 #if !defined(_GNU_SOURCE) 66 #if !defined(_POSIX_C_SOURCE) || ((_POSIX_C_SOURCE - 0) < 199309L) 67 #undef _POSIX_C_SOURCE 68 #define _POSIX_C_SOURCE 199309L 70 #if !defined(_XOPEN_SOURCE) || ((_XOPEN_SOURCE - 0) < 500) 72 #define _XOPEN_SOURCE 500 80 #if defined(_TTHREAD_POSIX_) 83 #elif defined(_TTHREAD_WIN32_) 84 #ifndef WIN32_LEAN_AND_MEAN 85 #define WIN32_LEAN_AND_MEAN 86 #define __UNDEF_LEAN_AND_MEAN 89 #ifdef __UNDEF_LEAN_AND_MEAN 90 #undef WIN32_LEAN_AND_MEAN 91 #undef __UNDEF_LEAN_AND_MEAN 100 #ifdef CLOCK_REALTIME 101 #define TIME_UTC CLOCK_REALTIME 108 #if defined(_TTHREAD_WIN32_) || defined(__APPLE_CC__) 109 #define _TTHREAD_EMULATE_CLOCK_GETTIME_ 111 #if defined(_TTHREAD_WIN32_) 112 struct _ttherad_timespec {
116 #define timespec _ttherad_timespec 120 typedef int _tthread_clockid_t;
121 #define clockid_t _tthread_clockid_t 124 int _tthread_clock_gettime(clockid_t clk_id,
struct timespec *ts);
125 #define clock_gettime _tthread_clock_gettime 126 #ifndef CLOCK_REALTIME 127 #define CLOCK_REALTIME 0 133 #define TINYCTHREAD_VERSION_MAJOR 1 135 #define TINYCTHREAD_VERSION_MINOR 1 137 #define TINYCTHREAD_VERSION (TINYCTHREAD_VERSION_MAJOR * 100 + TINYCTHREAD_VERSION_MINOR) 159 #if !(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201102L)) && !defined(_Thread_local) 160 #if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__SUNPRO_CC) || defined(__IBMCPP__) 161 #define _Thread_local __thread 163 #define _Thread_local __declspec(thread) 168 #define TSS_DTOR_ITERATIONS 0 172 #define thrd_success 1 173 #define thrd_timeout 2 181 #define mtx_recursive 8 184 #if defined(_TTHREAD_WIN32_) 186 CRITICAL_SECTION mHandle;
245 #if defined(_TTHREAD_WIN32_) 248 unsigned int mWaitersCount;
249 CRITICAL_SECTION mWaitersCountLock;
314 #if defined(_TTHREAD_WIN32_) 386 int thrd_sleep(
const struct timespec *time_point,
struct timespec *remaining);
395 #if defined(_TTHREAD_WIN32_) int mtx_trylock(mtx_t *mtx)
thrd_t thrd_current(void)
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
int mtx_timedlock(mtx_t *mtx, const struct timespec *ts)
int mtx_unlock(mtx_t *mtx)
int tss_set(tss_t key, void *val)
int thrd_create(thrd_t *thr, thrd_start_t func, void *arg)
int mtx_init(mtx_t *mtx, int type)
int(* thrd_start_t)(void *arg)
int cnd_init(cnd_t *cond)
int cnd_broadcast(cnd_t *cond)
void mtx_destroy(mtx_t *mtx)
void * tss_get(tss_t key)
void(* tss_dtor_t)(void *val)
int cnd_wait(cnd_t *cond, mtx_t *mtx)
int cnd_signal(cnd_t *cond)
int tss_create(tss_t *key, tss_dtor_t dtor)
int cnd_timedwait(cnd_t *cond, mtx_t *mtx, const struct timespec *ts)
int thrd_join(thrd_t thr, int *res)
int thrd_sleep(const struct timespec *time_point, struct timespec *remaining)
void tss_delete(tss_t key)
int thrd_detach(thrd_t thr)
void cnd_destroy(cnd_t *cond)
int thrd_equal(thrd_t thr0, thrd_t thr1)