diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-03-30 20:55:27 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-03-30 20:55:27 +0200 |
commit | 9010a500e7b1c8e7f16b0093b7cf456e07dd7d85 (patch) | |
tree | 0e820ee840edebc01a0483bc856adf7923d8c950 | |
parent | e9df4bc8972f69815e1dd6fe19e1162a9a97b092 (diff) | |
download | wolfbones-9010a500e7b1c8e7f16b0093b7cf456e07dd7d85.tar.gz wolfbones-9010a500e7b1c8e7f16b0093b7cf456e07dd7d85.tar.bz2 |
mutexes on native Windows
-rw-r--r-- | include/wolf/mutex.h | 18 | ||||
-rw-r--r-- | src/Makefile.W32 | 6 | ||||
-rw-r--r-- | src/mutex.c | 14 |
3 files changed, 37 insertions, 1 deletions
diff --git a/include/wolf/mutex.h b/include/wolf/mutex.h index e09a167..33c3ee9 100644 --- a/include/wolf/mutex.h +++ b/include/wolf/mutex.h @@ -65,6 +65,24 @@ static inline void wolf_mutex_unlock( wolf_mutex_t *mutex ) { #ifdef _WIN32 +#include <windows.h> + +typedef CRITICAL_SECTION wolf_mutex_t; + +#define WOLF_MUTEX_DEFAULT_ATTR + +wolf_error_t wolf_mutex_init( wolf_mutex_t *mutex ); +wolf_error_t wolf_mutex_destroy( wolf_mutex_t *mutex ); + +static void wolf_mutex_lock( wolf_mutex_t *mutex ) { + EnterCriticalSection( mutex ); +} + +static void wolf_mutex_unlock( wolf_mutex_t *mutex ) { + LeaveCriticalSection( mutex ); +} + + #endif /* _WIN32 */ #ifdef __cplusplus diff --git a/src/Makefile.W32 b/src/Makefile.W32 index 25d6eb0..5d46c75 100644 --- a/src/Makefile.W32 +++ b/src/Makefile.W32 @@ -24,10 +24,14 @@ LOG_OBJS = \ SERVICE_OBJS = \ service\service.obj +THREADING_OBJS = \ + mutex.obj + OBJS = \ $(PORT_OBJS) \ $(LOG_OBJS) \ - $(SERVICE_OBJS) + $(SERVICE_OBJS) \ + $(THREADING_OBJS) local_all: $(LIBRARIES) diff --git a/src/mutex.c b/src/mutex.c index 5aa18cf..573dc2c 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -76,3 +76,17 @@ wolf_error_t wolf_mutex_destroy( wolf_mutex_t *mutex ) { } #endif /* defined HAVE_PTHREADS */ + +#if defined _WIN32 + +wolf_error_t wolf_mutex_init( wolf_mutex_t *mutex ) { + InitializeCriticalSection( mutex ); + return WOLF_OK; +} + +wolf_error_t wolf_mutex_destroy( wolf_mutex_t *mutex ) { + DeleteCriticalSection( mutex ); + return WOLF_OK; +} + +#endif /* defined _WIN32 */ |