mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Simplify mutex wrapper into simply differentiating between RENDERTYPEWIN (which is deprecated...) and everything else, which uses SDL mutexes.
git-svn-id: https://svn.eduke32.com/eduke32@4441 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
d287b50cd7
commit
a33f9c2ca1
2 changed files with 5 additions and 15 deletions
|
@ -3,11 +3,9 @@
|
|||
|
||||
/* Mutual exclusion mechanism wrappers for the different platforms */
|
||||
|
||||
#if defined(_WIN32)
|
||||
#ifdef RENDERTYPEWIN
|
||||
# include <windows.h>
|
||||
# include <process.h>
|
||||
#elif !defined GEKKO
|
||||
# include <pthread.h>
|
||||
#else
|
||||
# include "sdl_inc.h"
|
||||
#endif
|
||||
|
@ -16,10 +14,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#ifdef RENDERTYPEWIN
|
||||
typedef HANDLE mutex_t;
|
||||
#elif !defined GEKKO
|
||||
typedef pthread_mutex_t mutex_t;
|
||||
#else
|
||||
/* PK: I don't like pointer typedefs, but SDL_CreateMutex() _returns_ one,
|
||||
* so we're out of luck with our interface. */
|
||||
|
|
|
@ -3,11 +3,9 @@
|
|||
|
||||
int32_t mutex_init(mutex_t *mutex)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef RENDERTYPEWIN
|
||||
*mutex = CreateMutex(0, FALSE, 0);
|
||||
return (*mutex == 0);
|
||||
#elif !defined GEKKO
|
||||
return pthread_mutex_init(mutex, NULL);
|
||||
#else
|
||||
if (mutex)
|
||||
{
|
||||
|
@ -21,10 +19,8 @@ int32_t mutex_init(mutex_t *mutex)
|
|||
|
||||
int32_t mutex_lock(mutex_t *mutex)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef RENDERTYPEWIN
|
||||
return (WaitForSingleObject(*mutex, INFINITE) == WAIT_FAILED);
|
||||
#elif !defined GEKKO
|
||||
return pthread_mutex_lock(mutex);
|
||||
#else
|
||||
return SDL_LockMutex(*mutex);
|
||||
#endif
|
||||
|
@ -32,10 +28,8 @@ int32_t mutex_lock(mutex_t *mutex)
|
|||
|
||||
int32_t mutex_unlock(mutex_t *mutex)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#ifdef RENDERTYPEWIN
|
||||
return (ReleaseMutex(*mutex) == 0);
|
||||
#elif !defined GEKKO
|
||||
return pthread_mutex_unlock(mutex);
|
||||
#else
|
||||
return SDL_UnlockMutex(*mutex);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue