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