aboutsummaryrefslogtreecommitdiff
path: root/src/utils/wrapthread.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/wrapthread.h')
-rw-r--r--src/utils/wrapthread.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/utils/wrapthread.h b/src/utils/wrapthread.h
index 28654fe..d5de155 100644
--- a/src/utils/wrapthread.h
+++ b/src/utils/wrapthread.h
@@ -9,13 +9,32 @@
9 9
10#define wrapthread_define_if_threads(T, x) T x; (void)(x) 10#define wrapthread_define_if_threads(T, x) T x; (void)(x)
11 11
12#define wrapthread_create(a, b, c, d) c(d) 12#define wrapthread_create(t, f, arg) f(arg)
13#define wrapthread_join(a, b) 13#define wrapthread_join(a)
14#define wrapthread_mutex_init(a, b) 14#define wrapthread_mutex_init(a)
15#define wrapthread_mutex_lock(a) 15#define wrapthread_mutex_lock(a)
16#define wrapthread_mutex_unlock(a) 16#define wrapthread_mutex_unlock(a)
17 17
18#else 18#elif defined(_WIN32)
19
20#include <threads.h>
21
22#define wrapthread_atomic _Atomic
23
24#define wrapthread_define_var_thread_t(x) thrd_t x
25#define wrapthread_define_var_mutex_t(x) mtx_t x
26#define wrapthread_define_struct_thread_t(x) thrd_t x
27#define wrapthread_define_struct_mutex_t(x) mtx_t x
28
29#define wrapthread_define_if_threads(T, x) T x
30
31#define wrapthread_create(a, f, arg) thrd_create(a, (int(*)(void *))f, arg)
32#define wrapthread_join(a) thrd_join(a, NULL)
33#define wrapthread_mutex_init(a) mtx_init(a, mtx_plain)
34#define wrapthread_mutex_lock(a) mtx_lock(a)
35#define wrapthread_mutex_unlock(a) mtx_unlock(a)
36
37#elif defined(__unix__)
19 38
20#include <pthread.h> 39#include <pthread.h>
21 40
@@ -28,9 +47,9 @@
28 47
29#define wrapthread_define_if_threads(T, x) T x 48#define wrapthread_define_if_threads(T, x) T x
30 49
31#define wrapthread_create(a, b, c, d) pthread_create(a, b, c, d) 50#define wrapthread_create(a, f, arg) pthread_create(a, NULL, f, arg)
32#define wrapthread_join(a, b) pthread_join(a, b) 51#define wrapthread_join(a) pthread_join(a, NULL)
33#define wrapthread_mutex_init(a, b) pthread_mutex_init(a, b) 52#define wrapthread_mutex_init(a) pthread_mutex_init(a, NULL)
34#define wrapthread_mutex_lock(a) pthread_mutex_lock(a) 53#define wrapthread_mutex_lock(a) pthread_mutex_lock(a)
35#define wrapthread_mutex_unlock(a) pthread_mutex_unlock(a) 54#define wrapthread_mutex_unlock(a) pthread_mutex_unlock(a)
36 55

Generated with cgit - Back to sebastiano.tronto.net