mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 22:48:18 +00:00
fixed semaphore on macosx
This commit is contained in:
parent
0ef72767d8
commit
c16c4ee4d9
|
@ -505,18 +505,20 @@ void lock_release(LOCK lock)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
void semaphore_init(SEMAPHORE *sem) { sem_init(sem, 0, 0); }
|
||||
void semaphore_wait(SEMAPHORE *sem) { sem_wait(sem); }
|
||||
void semaphore_signal(SEMAPHORE *sem) { sem_post(sem); }
|
||||
void semaphore_destroy(SEMAPHORE *sem) { sem_destroy(sem); }
|
||||
#elif defined(CONF_FAMILY_WINDOWS)
|
||||
void semaphore_init(SEMAPHORE *sem) { *sem = CreateSemaphore(0, 0, 10000, 0); }
|
||||
void semaphore_wait(SEMAPHORE *sem) { WaitForSingleObject((HANDLE)*sem, 0L); }
|
||||
void semaphore_signal(SEMAPHORE *sem) { ReleaseSemaphore((HANDLE)*sem, 1, NULL); }
|
||||
void semaphore_destroy(SEMAPHORE *sem) { CloseHandle((HANDLE)*sem); }
|
||||
#else
|
||||
#error not implemented on this platform
|
||||
#if !defined(CONF_PLATFORM_MACOSX)
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
void semaphore_init(SEMAPHORE *sem) { sem_init(sem, 0, 0); }
|
||||
void semaphore_wait(SEMAPHORE *sem) { sem_wait(sem); }
|
||||
void semaphore_signal(SEMAPHORE *sem) { sem_post(sem); }
|
||||
void semaphore_destroy(SEMAPHORE *sem) { sem_destroy(sem); }
|
||||
#elif defined(CONF_FAMILY_WINDOWS)
|
||||
void semaphore_init(SEMAPHORE *sem) { *sem = CreateSemaphore(0, 0, 10000, 0); }
|
||||
void semaphore_wait(SEMAPHORE *sem) { WaitForSingleObject((HANDLE)*sem, 0L); }
|
||||
void semaphore_signal(SEMAPHORE *sem) { ReleaseSemaphore((HANDLE)*sem, 1, NULL); }
|
||||
void semaphore_destroy(SEMAPHORE *sem) { CloseHandle((HANDLE)*sem); }
|
||||
#else
|
||||
#error not implemented on this platform
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -403,19 +403,21 @@ void lock_release(LOCK lock);
|
|||
|
||||
/* Group: Semaphores */
|
||||
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
#include <semaphore.h>
|
||||
typedef sem_t SEMAPHORE;
|
||||
#elif defined(CONF_FAMILY_WINDOWS)
|
||||
typedef void* SEMAPHORE;
|
||||
#else
|
||||
#error missing sempahore implementation
|
||||
#endif
|
||||
#if !defined(CONF_PLATFORM_MACOSX)
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
#include <semaphore.h>
|
||||
typedef sem_t SEMAPHORE;
|
||||
#elif defined(CONF_FAMILY_WINDOWS)
|
||||
typedef void* SEMAPHORE;
|
||||
#else
|
||||
#error missing sempahore implementation
|
||||
#endif
|
||||
|
||||
void semaphore_init(SEMAPHORE *sem);
|
||||
void semaphore_wait(SEMAPHORE *sem);
|
||||
void semaphore_signal(SEMAPHORE *sem);
|
||||
void semaphore_destroy(SEMAPHORE *sem);
|
||||
void semaphore_init(SEMAPHORE *sem);
|
||||
void semaphore_wait(SEMAPHORE *sem);
|
||||
void semaphore_signal(SEMAPHORE *sem);
|
||||
void semaphore_destroy(SEMAPHORE *sem);
|
||||
#endif
|
||||
|
||||
/* Group: Timer */
|
||||
#ifdef __GNUC__
|
||||
|
|
|
@ -58,15 +58,21 @@
|
|||
#error missing atomic implementation for this compiler
|
||||
#endif
|
||||
|
||||
class semaphore
|
||||
{
|
||||
SEMAPHORE sem;
|
||||
public:
|
||||
semaphore() { semaphore_init(&sem); }
|
||||
~semaphore() { semaphore_destroy(&sem); }
|
||||
void wait() { semaphore_wait(&sem); }
|
||||
void signal() { semaphore_signal(&sem); }
|
||||
};
|
||||
#if defined(CONF_PLATFORM_MACOSX)
|
||||
/*
|
||||
use semaphore provided by SDL on macosx
|
||||
*/
|
||||
#else
|
||||
class semaphore
|
||||
{
|
||||
SEMAPHORE sem;
|
||||
public:
|
||||
semaphore() { semaphore_init(&sem); }
|
||||
~semaphore() { semaphore_destroy(&sem); }
|
||||
void wait() { semaphore_wait(&sem); }
|
||||
void signal() { semaphore_signal(&sem); }
|
||||
};
|
||||
#endif
|
||||
|
||||
class lock
|
||||
{
|
||||
|
|
|
@ -30,6 +30,16 @@
|
|||
|
||||
#include <AGL/agl.h>
|
||||
|
||||
class semaphore
|
||||
{
|
||||
SDL_sem *sem;
|
||||
public:
|
||||
semaphore() { sem = SDL_CreateSemaphore(0); }
|
||||
~semaphore() { SDL_DestroySemaphore(sem); }
|
||||
void wait() { SDL_SemWait(sem); }
|
||||
void signal() { SDL_SemPost(sem); }
|
||||
};
|
||||
|
||||
struct SGLContext
|
||||
{
|
||||
AGLContext m_Context;
|
||||
|
|
|
@ -177,8 +177,6 @@ class CClient : public IClient, public CDemoPlayer::IListner
|
|||
class CHostLookup m_VersionServeraddr;
|
||||
} m_VersionInfo;
|
||||
|
||||
semaphore m_GfxRenderSemaphore;
|
||||
semaphore m_GfxStateSemaphore;
|
||||
volatile int m_GfxState;
|
||||
static void GraphicsThreadProxy(void *pThis) { ((CClient*)pThis)->GraphicsThread(); }
|
||||
void GraphicsThread();
|
||||
|
|
|
@ -22,6 +22,20 @@
|
|||
#include "graphics.h"
|
||||
|
||||
|
||||
#if defined(CONF_PLATFORM_MACOSX)
|
||||
|
||||
class semaphore
|
||||
{
|
||||
SDL_sem *sem;
|
||||
public:
|
||||
semaphore() { sem = SDL_CreateSemaphore(0); }
|
||||
~semaphore() { SDL_DestroySemaphore(sem); }
|
||||
void wait() { SDL_SemWait(sem); }
|
||||
void signal() { SDL_SemPost(sem); }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
static CVideoMode g_aFakeModes[] = {
|
||||
{320,240,8,8,8}, {400,300,8,8,8}, {640,480,8,8,8},
|
||||
{720,400,8,8,8}, {768,576,8,8,8}, {800,600,8,8,8},
|
||||
|
|
Loading…
Reference in a new issue