diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-11 10:22:56 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-11 11:48:40 +0200 |
| commit | d25f23805c6d7128b508a359d47af136dd2fd0db (patch) | |
| tree | f0fa7998db9f58a475d8e54f17239aa7822be254 /src/utils/wrapthread.h | |
| parent | 9c5c7af7abe9e444210ac86b903eee775fc76a84 (diff) | |
| download | nissy-core-d25f23805c6d7128b508a359d47af136dd2fd0db.tar.gz nissy-core-d25f23805c6d7128b508a359d47af136dd2fd0db.zip | |
Wrapped pthread use in custom API
Diffstat (limited to 'src/utils/wrapthread.h')
| -rw-r--r-- | src/utils/wrapthread.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/utils/wrapthread.h b/src/utils/wrapthread.h new file mode 100644 index 0000000..482b67f --- /dev/null +++ b/src/utils/wrapthread.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | #if THREADS == 1 | ||
| 2 | |||
| 3 | #define wrapthread_atomic | ||
| 4 | |||
| 5 | #define wrapthread_define_var_thread_t(x) char x; (void)(x) | ||
| 6 | #define wrapthread_define_var_mutex_t(x) char x; (void)(x) | ||
| 7 | #define wrapthread_define_struct_thread_t(x) char x | ||
| 8 | #define wrapthread_define_struct_mutex_t(x) char x | ||
| 9 | |||
| 10 | #define wrapthread_define_if_threads(T, x) T x; (void)(x) | ||
| 11 | |||
| 12 | #define wrapthread_create(a, b, c, d) c(d) | ||
| 13 | #define wrapthread_join(a, b) | ||
| 14 | #define wrapthread_mutex_init(a, b) | ||
| 15 | #define wrapthread_mutex_lock(a) | ||
| 16 | #define wrapthread_mutex_unlock(a) | ||
| 17 | |||
| 18 | #else | ||
| 19 | |||
| 20 | #include <pthread.h> | ||
| 21 | |||
| 22 | #define wrapthread_atomic _Atomic | ||
| 23 | |||
| 24 | #define wrapthread_define_var_thread_t(x) pthread_t x | ||
| 25 | #define wrapthread_define_var_mutex_t(x) pthread_mutex_t x | ||
| 26 | #define wrapthread_define_struct_thread_t(x) pthread_t x | ||
| 27 | #define wrapthread_define_struct_mutex_t(x) pthread_mutex_t x | ||
| 28 | |||
| 29 | #define wrapthread_define_if_threads(T, x) T x | ||
| 30 | |||
| 31 | #define wrapthread_create(a, b, c, d) pthread_create(a, b, c, d) | ||
| 32 | #define wrapthread_join(a, b) pthread_join(a, b) | ||
| 33 | #define wrapthread_mutex_init(a, b) pthread_mutex_init(a, b) | ||
| 34 | #define wrapthread_mutex_lock(a) pthread_mutex_lock(a) | ||
| 35 | #define wrapthread_mutex_unlock(a) pthread_mutex_unlock(a) | ||
| 36 | |||
| 37 | #endif | ||
