summaryrefslogtreecommitdiff
path: root/src/mutex.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/mutex.h')
-rw-r--r--src/mutex.h23
1 files changed, 20 insertions, 3 deletions
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 <windows.h>
#include <process.h> /* _beginthread, _endthread */
#include <stddef.h>
@@ -19,11 +19,28 @@ typedef struct t_ts_thread
HANDLE thread;
int valid;
} ts_thread;
+
+#elif defined(__linux__)
+#include <pthread.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+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);