diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-12 09:36:36 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-12 09:36:36 +0100 |
| commit | 50bd8f0f568120e554d416f474cc72247d0b3240 (patch) | |
| tree | 236b8ebed5af17f8220981deffd69b97f0d08fe7 /src/utils | |
| parent | 315d0f118f3d5ec2578249182f7b0eebf99d2943 (diff) | |
| parent | b36ed11e322152ff9ab813af78a08c35b42d5f94 (diff) | |
| download | nissy-core-50bd8f0f568120e554d416f474cc72247d0b3240.tar.gz nissy-core-50bd8f0f568120e554d416f474cc72247d0b3240.zip | |
Merge branch 'master' of https://github.com/sebastianotronto/nissy-core into windows
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/utils.h | 1 | ||||
| -rw-r--r-- | src/utils/wrapthread.h | 37 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/utils/utils.h b/src/utils/utils.h index d14b285..b2ab64d 100644 --- a/src/utils/utils.h +++ b/src/utils/utils.h | |||
| @@ -2,3 +2,4 @@ | |||
| 2 | #include "constants.h" | 2 | #include "constants.h" |
| 3 | #include "math.h" | 3 | #include "math.h" |
| 4 | #include "sleep.h" | 4 | #include "sleep.h" |
| 5 | #include "wrapthread.h" | ||
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 | ||
