From 0b429e06b8c4b66a9f7fe89b5504315ab4f69616 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Fri, 8 Mar 2024 20:48:05 +0100 Subject: linux building --- src/mutex.h | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/mutex.h') diff --git a/src/mutex.h b/src/mutex.h index a745947..8499bcc 100644 --- a/src/mutex.h +++ b/src/mutex.h @@ -1,7 +1,7 @@ #ifndef INCLUDE_MUTEX #define INCLUDE_MUTEX -#ifdef _WIN32 +#if defined(_WIN32) #include #include /* _beginthread, _endthread */ #include @@ -19,11 +19,28 @@ typedef struct t_ts_thread HANDLE thread; int valid; } ts_thread; + +#elif defined(__linux__) +#include +#include +#include +#include + +typedef struct t_ts_thread +{ + pthread_t thread; + bool valid; +} ts_thread; + +typedef struct t_ts_mutex +{ + pthread_mutex_t mutex; +} ts_mutex; #endif ts_thread ts_thread_start(void *(*start_routine) (void *), void *arg); void ts_thread_join(ts_thread *ts_thread); -int ts_thread_tryjoin(ts_thread *ts_thread); +bool ts_thread_tryjoin(ts_thread *ts_thread); void ts_thread_detach(ts_thread *ts_thread); void ts_thread_stop(ts_thread *ts_thread); int ts_thread_get_id(); @@ -33,7 +50,7 @@ void ts_thread_exit(); ts_mutex ts_mutex_create_recursive(); ts_mutex ts_mutex_create(); void ts_mutex_lock(ts_mutex *ts_mutex); -int ts_mutex_trylock(ts_mutex *ts_mutex); +bool ts_mutex_trylock(ts_mutex *ts_mutex); void ts_mutex_unlock(ts_mutex *ts_mutex); void ts_mutex_destroy(ts_mutex *ts_mutex); -- cgit v1.2.3-70-g09d2