raze-gles/source/build/src/mutex.cpp
hendricks266 1cc9d13ccf The great repository rearrangement of 2017.
Files moved but not modified. Changes to follow in a subsequent commit.

You down with CPP?

git-svn-id: https://svn.eduke32.com/eduke32@6055 1a8010ca-5511-0410-912e-c29ae57300e0
2017-02-01 10:01:11 +00:00

36 lines
633 B
C++

#include "compat.h"
#include "mutex.h"
int32_t mutex_init(mutex_t *mutex)
{
#ifdef RENDERTYPEWIN
*mutex = CreateMutex(0, FALSE, 0);
return (*mutex == 0);
#else
if (mutex)
{
*mutex = SDL_CreateMutex();
if (*mutex != NULL)
return 0;
}
return -1;
#endif
}
int32_t mutex_lock(mutex_t *mutex)
{
#ifdef RENDERTYPEWIN
return (WaitForSingleObject(*mutex, INFINITE) == WAIT_FAILED);
#else
return SDL_LockMutex(*mutex);
#endif
}
int32_t mutex_unlock(mutex_t *mutex)
{
#ifdef RENDERTYPEWIN
return (ReleaseMutex(*mutex) == 0);
#else
return SDL_UnlockMutex(*mutex);
#endif
}