diff options
Diffstat (limited to 'librabbitmq/win32/threads.c')
-rw-r--r-- | librabbitmq/win32/threads.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/librabbitmq/win32/threads.c b/librabbitmq/win32/threads.c new file mode 100644 index 0000000..cf2e9ee --- /dev/null +++ b/librabbitmq/win32/threads.c @@ -0,0 +1,37 @@ +#include "threads.h" + +DWORD +pthread_self(void) +{ + return GetCurrentThreadId(); +} + +int +pthread_mutex_init(pthread_mutex_t *mutex, void *attr) +{ + *mutex = malloc(sizeof(CRITICAL_SECTION)); + if (!*mutex) + return 1; + InitializeCriticalSection(*mutex); + return 0; +} + +int +pthread_mutex_lock(pthread_mutex_t *mutex) +{ + if (!*mutex) + return 1; + + EnterCriticalSection(*mutex); + return 0; +} + +int +pthread_mutex_unlock(pthread_mutex_t *mutex) +{ + if (!*mutex) + return 1; + + LeaveCriticalSection(*mutex); + return 0; +} |