diff --git a/source/build/include/mutex.h b/source/build/include/mutex.h index ba9c51d32..040279f8e 100644 --- a/source/build/include/mutex.h +++ b/source/build/include/mutex.h @@ -19,12 +19,12 @@ typedef HANDLE mutex_t; #else /* PK: I don't like pointer typedefs, but SDL_CreateMutex() _returns_ one, * so we're out of luck with our interface. */ -typedef SDL_mutex* mutex_t; +typedef SDL_SpinLock mutex_t; #endif extern int32_t mutex_init(mutex_t *mutex); -extern int32_t mutex_lock(mutex_t *mutex); -extern int32_t mutex_unlock(mutex_t *mutex); +extern void mutex_lock(mutex_t *mutex); +extern void mutex_unlock(mutex_t *mutex); #ifdef __cplusplus diff --git a/source/build/src/mutex.cpp b/source/build/src/mutex.cpp index 5e22cad25..e88ae8bc2 100644 --- a/source/build/src/mutex.cpp +++ b/source/build/src/mutex.cpp @@ -13,30 +13,25 @@ int32_t mutex_init(mutex_t *mutex) *mutex = CreateMutex(0, FALSE, 0); return (*mutex == 0); #else - if (mutex) - { - *mutex = SDL_CreateMutex(); - if (*mutex != NULL) - return 0; - } - return -1; + *mutex = 0; + return 0; #endif } -int32_t mutex_lock(mutex_t *mutex) +void mutex_lock(mutex_t *mutex) { #ifdef RENDERTYPEWIN - return (WaitForSingleObject(*mutex, INFINITE) == WAIT_FAILED); + return WaitForSingleObject(*mutex, INFINITE); #else - return SDL_LockMutex(*mutex); + return SDL_AtomicLock(mutex); #endif } -int32_t mutex_unlock(mutex_t *mutex) +void mutex_unlock(mutex_t *mutex) { #ifdef RENDERTYPEWIN - return (ReleaseMutex(*mutex) == 0); + ReleaseMutex(*mutex); #else - return SDL_UnlockMutex(*mutex); + SDL_AtomicUnlock(mutex); #endif }