28 lines
474 B
C
28 lines
474 B
C
//
|
|
// Created by nicol on 2018-03-18.
|
|
//
|
|
|
|
#ifdef _WIN32
|
|
#include <windows.h>
|
|
#endif
|
|
#include "mutex.h"
|
|
|
|
#ifdef _WIN32
|
|
mutex_t mutex_create() {
|
|
mutex_t mutex = malloc(sizeof(CRITICAL_SECTION));
|
|
InitializeCriticalSection(mutex);
|
|
return mutex;
|
|
}
|
|
|
|
void mutex_lock(mutex_t mutex) {
|
|
EnterCriticalSection(mutex);
|
|
}
|
|
|
|
void mutex_unlock(mutex_t mutex) {
|
|
LeaveCriticalSection(mutex);
|
|
}
|
|
|
|
void mutex_destroy(mutex_t mutex) {
|
|
DeleteCriticalSection(mutex);
|
|
}
|
|
#endif |