From a3685d46c883c96e122b12bfebc6975705962e07 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sun, 3 Mar 2024 14:29:17 +0100 Subject: v2 initial commit --- src/mutex.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/mutex.h (limited to 'src/mutex.h') diff --git a/src/mutex.h b/src/mutex.h new file mode 100644 index 0000000..a061c2e --- /dev/null +++ b/src/mutex.h @@ -0,0 +1,42 @@ +#ifndef INCLUDE_MUTEX +#define INCLUDE_MUTEX + +#ifdef _WIN32 +#include +#include /* _beginthread, _endthread */ +#include +#include +#include +#include + +typedef struct t_mutex +{ + HANDLE mutex; +} mutex; + +typedef struct t_thread +{ + HANDLE thread; + int valid; +} thread; +#endif + +thread thread_start(void *(*start_routine) (void *), void *arg); +void thread_join(thread *thread); +int thread_tryjoin(thread *thread); +void thread_detach(thread *thread); +void thread_stop(thread *thread); +int thread_get_id(); +void thread_sleep(int microseconds); +void thread_exit(); + + +mutex mutex_create_recursive(); +mutex mutex_create(); +void mutex_lock(mutex *mutex); +int mutex_trylock(mutex *mutex); +void mutex_unlock(mutex *mutex); +void mutex_destroy(mutex *mutex); + + +#endif \ No newline at end of file -- cgit v1.2.3-70-g09d2