From bdbea0da32cd9b1d77dfdcdcfed6b61297e61fd0 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Mon, 1 Aug 2011 03:53:57 +0000 Subject: [PATCH] - Use kernel semaphores on Mac OS X since it doesn't support POSIX semaphores. SVN r3276 (trunk) --- src/sdl/i_system.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index 0f0c7125f..ecaf1a26e 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -33,12 +33,19 @@ #include #include #include -#include #ifndef NO_GTK #include #include #endif +#ifdef __APPLE__ +#include +#include +#include +#else +#include +#endif + #include "doomerrors.h" #include @@ -125,7 +132,11 @@ static DWORD BaseTime; static int TicFrozen; // Signal based timer. +#ifdef __APPLE__ +static semaphore_t timerWait; +#else static sem_t timerWait; +#endif static int tics; static DWORD sig_start, sig_next; @@ -197,7 +208,14 @@ int I_WaitForTicSignaled (int prevtic) assert (TicFrozen == 0); while(tics <= prevtic) + { +#ifdef __APPLE__ + while(semaphore_wait(timerWait) != KERN_SUCCESS) + ; +#else while(sem_wait(&timerWait) != 0); +#endif + } return tics; } @@ -246,7 +264,11 @@ void I_HandleAlarm (int sig) tics++; sig_start = SDL_GetTicks(); sig_next = Scale((Scale (sig_start, TICRATE, 1000) + 1), 1000, TICRATE); +#ifdef __APPLE__ + semaphore_signal(timerWait); +#else sem_post(&timerWait); +#endif } // @@ -256,7 +278,11 @@ void I_HandleAlarm (int sig) // void I_SelectTimer() { +#ifdef __APPLE__ + semaphore_create(mach_task_self(), &timerWait, 0, 0); +#else sem_init(&timerWait, 0, 0); +#endif signal(SIGALRM, I_HandleAlarm); struct itimerval itv;