mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-07 13:31:27 +00:00
d4ee6d00c8
This allows us to make certain guarantees about limits on the extent of namespace pollution these headers introduce. git-svn-id: https://svn.eduke32.com/eduke32@6065 1a8010ca-5511-0410-912e-c29ae57300e0
42 lines
706 B
C++
42 lines
706 B
C++
#include "compat.h"
|
|
|
|
#ifdef _WIN32
|
|
# define NEED_PROCESS_H
|
|
# include "windows_inc.h"
|
|
#endif
|
|
|
|
#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
|
|
}
|