Rename SDL semaphore and condition variable functions to match SDL 3.0 naming convention

Fixes https://github.com/libsdl-org/SDL/issues/7642
This commit is contained in:
Sam Lantinga 2023-04-27 20:49:54 -07:00
parent 170c410d35
commit 61c0c009ab
45 changed files with 458 additions and 362 deletions

View file

@ -2538,3 +2538,58 @@ typedef SDL_atomic_t, SDL_AtomicInt;
@@ @@
- SDL_atomic_t - SDL_atomic_t
+ SDL_AtomicInt + SDL_AtomicInt
@@
@@
- SDL_SemWait
+ SDL_WaitSemaphore
(...)
@@
@@
- SDL_SemTryWait
+ SDL_TryWaitSemaphore
(...)
@@
@@
- SDL_SemWaitTimeout
+ SDL_WaitSemaphoreTimeout
(...)
@@
@@
- SDL_SemPost
+ SDL_PostSemaphore
(...)
@@
@@
- SDL_SemValue
+ SDL_GetSemaphoreValue
(...)
@@
@@
- SDL_CreateCond
+ SDL_CreateCondition
(...)
@@
@@
- SDL_DestroyCond
+ SDL_DestroyCondition
(...)
@@
@@
- SDL_CondSignal
+ SDL_SignalCondition
(...)
@@
@@
- SDL_CondBroadcast
+ SDL_BroadcastCondition
(...)
@@
@@
- SDL_CondWait
+ SDL_WaitCondition
(...)
@@
@@
- SDL_CondWaitTimeout
+ SDL_WaitConditionTimeout
(...)

View file

@ -554,6 +554,21 @@ SDL_GetMouseState(), SDL_GetGlobalMouseState(), SDL_GetRelativeMouseState(), SDL
The following functions have been renamed: The following functions have been renamed:
* SDL_FreeCursor() => SDL_DestroyCursor() * SDL_FreeCursor() => SDL_DestroyCursor()
## SDL_mutex.h
The following functions have been renamed:
* SDL_CondBroadcast() => SDL_BroadcastCondition()
* SDL_CondSignal() => SDL_SignalCondition()
* SDL_CondWait() => SDL_WaitCondition()
* SDL_CondWaitTimeout() => SDL_WaitConditionTimeout()
* SDL_CreateCond() => SDL_CreateCondition()
* SDL_DestroyCond() => SDL_DestroyCondition()
* SDL_SemPost() => SDL_PostSemaphore()
* SDL_SemTryWait() => SDL_TryWaitSemaphore()
* SDL_SemValue() => SDL_GetSemaphoreValue()
* SDL_SemWait() => SDL_WaitSemaphore()
* SDL_SemWaitTimeout() => SDL_WaitSemaphoreTimeout()
## SDL_pixels.h ## SDL_pixels.h
SDL_CalculateGammaRamp has been removed, because SDL_SetWindowGammaRamp has been removed as well due to poor support in modern operating systems (see [SDL_video.h](#sdl_videoh)). SDL_CalculateGammaRamp has been removed, because SDL_SetWindowGammaRamp has been removed as well due to poor support in modern operating systems (see [SDL_video.h](#sdl_videoh)).

View file

@ -25,4 +25,4 @@ cmake --install build
- SDL3_main should be used to ensure ROMFS is enabled - this is done with `#include <SDL3/SDL_main.h>` in the source file that contains your main function. - SDL3_main should be used to ensure ROMFS is enabled - this is done with `#include <SDL3/SDL_main.h>` in the source file that contains your main function.
- By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function. - By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function.
- `SDL_GetBasePath` returns the romfs root instead of the executable's directory. - `SDL_GetBasePath` returns the romfs root instead of the executable's directory.
- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_SemWait`, `SDL_CondWait`, `SDL_WaitThread`). To avoid starving other threads, `SDL_SemTryWait` and `SDL_SemWaitTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information. - The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_WaitSemaphore`, `SDL_WaitCondition`, `SDL_WaitThread`). To avoid starving other threads, `SDL_TryWaitSemaphore` and `SDL_WaitSemaphoreTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information.

View file

@ -481,11 +481,11 @@ typedef struct SDL_semaphore SDL_sem;
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_SemPost * \sa SDL_PostSemaphore
* \sa SDL_SemTryWait * \sa SDL_TryWaitSemaphore
* \sa SDL_SemValue * \sa SDL_GetSemaphoreValue
* \sa SDL_SemWait * \sa SDL_WaitSemaphore
* \sa SDL_SemWaitTimeout * \sa SDL_WaitSemaphoreTimeout
*/ */
extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
@ -500,11 +500,11 @@ extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
* \sa SDL_SemPost * \sa SDL_PostSemaphore
* \sa SDL_SemTryWait * \sa SDL_TryWaitSemaphore
* \sa SDL_SemValue * \sa SDL_GetSemaphoreValue
* \sa SDL_SemWait * \sa SDL_WaitSemaphore
* \sa SDL_SemWaitTimeout * \sa SDL_WaitSemaphoreTimeout
*/ */
extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem);
@ -516,7 +516,7 @@ extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem);
* signal or error. If the call is successful it will atomically decrement the * signal or error. If the call is successful it will atomically decrement the
* semaphore value. * semaphore value.
* *
* This function is the equivalent of calling SDL_SemWaitTimeout() with a time * This function is the equivalent of calling SDL_WaitSemaphoreTimeout() with a time
* length of `SDL_MUTEX_MAXWAIT`. * length of `SDL_MUTEX_MAXWAIT`.
* *
* \param sem the semaphore wait on * \param sem the semaphore wait on
@ -527,13 +527,13 @@ extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem);
* *
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_SemPost * \sa SDL_PostSemaphore
* \sa SDL_SemTryWait * \sa SDL_TryWaitSemaphore
* \sa SDL_SemValue * \sa SDL_GetSemaphoreValue
* \sa SDL_SemWait * \sa SDL_WaitSemaphore
* \sa SDL_SemWaitTimeout * \sa SDL_WaitSemaphoreTimeout
*/ */
extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); extern DECLSPEC int SDLCALL SDL_WaitSemaphore(SDL_sem *sem);
/** /**
* See if a semaphore has a positive value and decrement it if it does. * See if a semaphore has a positive value and decrement it if it does.
@ -552,12 +552,12 @@ extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem);
* *
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_SemPost * \sa SDL_PostSemaphore
* \sa SDL_SemValue * \sa SDL_GetSemaphoreValue
* \sa SDL_SemWait * \sa SDL_WaitSemaphore
* \sa SDL_SemWaitTimeout * \sa SDL_WaitSemaphoreTimeout
*/ */
extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); extern DECLSPEC int SDLCALL SDL_TryWaitSemaphore(SDL_sem *sem);
/** /**
* Wait until a semaphore has a positive value and then decrements it. * Wait until a semaphore has a positive value and then decrements it.
@ -577,12 +577,12 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem);
* *
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_SemPost * \sa SDL_PostSemaphore
* \sa SDL_SemTryWait * \sa SDL_TryWaitSemaphore
* \sa SDL_SemValue * \sa SDL_GetSemaphoreValue
* \sa SDL_SemWait * \sa SDL_WaitSemaphore
*/ */
extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Sint32 timeoutMS); extern DECLSPEC int SDLCALL SDL_WaitSemaphoreTimeout(SDL_sem *sem, Sint32 timeoutMS);
/** /**
* Atomically increment a semaphore's value and wake waiting threads. * Atomically increment a semaphore's value and wake waiting threads.
@ -595,12 +595,12 @@ extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Sint32 timeoutMS);
* *
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
* \sa SDL_DestroySemaphore * \sa SDL_DestroySemaphore
* \sa SDL_SemTryWait * \sa SDL_TryWaitSemaphore
* \sa SDL_SemValue * \sa SDL_GetSemaphoreValue
* \sa SDL_SemWait * \sa SDL_WaitSemaphore
* \sa SDL_SemWaitTimeout * \sa SDL_WaitSemaphoreTimeout
*/ */
extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); extern DECLSPEC int SDLCALL SDL_PostSemaphore(SDL_sem *sem);
/** /**
* Get the current value of a semaphore. * Get the current value of a semaphore.
@ -612,7 +612,7 @@ extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem);
* *
* \sa SDL_CreateSemaphore * \sa SDL_CreateSemaphore
*/ */
extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); extern DECLSPEC Uint32 SDLCALL SDL_GetSemaphoreValue(SDL_sem *sem);
/* @} *//* Semaphore functions */ /* @} *//* Semaphore functions */
@ -634,13 +634,13 @@ typedef struct SDL_cond SDL_cond;
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_CondBroadcast * \sa SDL_BroadcastCondition
* \sa SDL_CondSignal * \sa SDL_SignalCondition
* \sa SDL_CondWait * \sa SDL_WaitCondition
* \sa SDL_CondWaitTimeout * \sa SDL_WaitConditionTimeout
* \sa SDL_DestroyCond * \sa SDL_DestroyCondition
*/ */
extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCondition(void);
/** /**
* Destroy a condition variable. * Destroy a condition variable.
@ -649,13 +649,13 @@ extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_CondBroadcast * \sa SDL_BroadcastCondition
* \sa SDL_CondSignal * \sa SDL_SignalCondition
* \sa SDL_CondWait * \sa SDL_WaitCondition
* \sa SDL_CondWaitTimeout * \sa SDL_WaitConditionTimeout
* \sa SDL_CreateCond * \sa SDL_CreateCondition
*/ */
extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); extern DECLSPEC void SDLCALL SDL_DestroyCondition(SDL_cond *cond);
/** /**
* Restart one of the threads that are waiting on the condition variable. * Restart one of the threads that are waiting on the condition variable.
@ -666,13 +666,13 @@ extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_CondBroadcast * \sa SDL_BroadcastCondition
* \sa SDL_CondWait * \sa SDL_WaitCondition
* \sa SDL_CondWaitTimeout * \sa SDL_WaitConditionTimeout
* \sa SDL_CreateCond * \sa SDL_CreateCondition
* \sa SDL_DestroyCond * \sa SDL_DestroyCondition
*/ */
extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); extern DECLSPEC int SDLCALL SDL_SignalCondition(SDL_cond *cond);
/** /**
* Restart all threads that are waiting on the condition variable. * Restart all threads that are waiting on the condition variable.
@ -683,19 +683,19 @@ extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_CondSignal * \sa SDL_SignalCondition
* \sa SDL_CondWait * \sa SDL_WaitCondition
* \sa SDL_CondWaitTimeout * \sa SDL_WaitConditionTimeout
* \sa SDL_CreateCond * \sa SDL_CreateCondition
* \sa SDL_DestroyCond * \sa SDL_DestroyCondition
*/ */
extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); extern DECLSPEC int SDLCALL SDL_BroadcastCondition(SDL_cond *cond);
/** /**
* Wait until a condition variable is signaled. * Wait until a condition variable is signaled.
* *
* This function unlocks the specified `mutex` and waits for another thread to * This function unlocks the specified `mutex` and waits for another thread to
* call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable * call SDL_SignalCondition() or SDL_BroadcastCondition() on the condition variable
* `cond`. Once the condition variable is signaled, the mutex is re-locked and * `cond`. Once the condition variable is signaled, the mutex is re-locked and
* the function returns. * the function returns.
* *
@ -703,7 +703,7 @@ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond);
* recursively (more than once) is not supported and leads to undefined * recursively (more than once) is not supported and leads to undefined
* behavior. * behavior.
* *
* This function is the equivalent of calling SDL_CondWaitTimeout() with a * This function is the equivalent of calling SDL_WaitConditionTimeout() with a
* time length of `SDL_MUTEX_MAXWAIT`. * time length of `SDL_MUTEX_MAXWAIT`.
* *
* \param cond the condition variable to wait on * \param cond the condition variable to wait on
@ -713,19 +713,19 @@ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_CondBroadcast * \sa SDL_BroadcastCondition
* \sa SDL_CondSignal * \sa SDL_SignalCondition
* \sa SDL_CondWaitTimeout * \sa SDL_WaitConditionTimeout
* \sa SDL_CreateCond * \sa SDL_CreateCondition
* \sa SDL_DestroyCond * \sa SDL_DestroyCondition
*/ */
extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex); extern DECLSPEC int SDLCALL SDL_WaitCondition(SDL_cond *cond, SDL_mutex *mutex);
/** /**
* Wait until a condition variable is signaled or a certain time has passed. * Wait until a condition variable is signaled or a certain time has passed.
* *
* This function unlocks the specified `mutex` and waits for another thread to * This function unlocks the specified `mutex` and waits for another thread to
* call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable * call SDL_SignalCondition() or SDL_BroadcastCondition() on the condition variable
* `cond`, or for the specified time to elapse. Once the condition variable is * `cond`, or for the specified time to elapse. Once the condition variable is
* signaled or the time elapsed, the mutex is re-locked and the function * signaled or the time elapsed, the mutex is re-locked and the function
* returns. * returns.
@ -744,13 +744,13 @@ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex);
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_CondBroadcast * \sa SDL_BroadcastCondition
* \sa SDL_CondSignal * \sa SDL_SignalCondition
* \sa SDL_CondWait * \sa SDL_WaitCondition
* \sa SDL_CreateCond * \sa SDL_CreateCondition
* \sa SDL_DestroyCond * \sa SDL_DestroyCondition
*/ */
extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, extern DECLSPEC int SDLCALL SDL_WaitConditionTimeout(SDL_cond *cond,
SDL_mutex *mutex, Sint32 timeoutMS); SDL_mutex *mutex, Sint32 timeoutMS);
/* @} *//* Condition variable functions */ /* @} *//* Condition variable functions */

View file

@ -314,6 +314,19 @@
/* ##SDL_mouse.h */ /* ##SDL_mouse.h */
#define SDL_FreeCursor SDL_DestroyCursor #define SDL_FreeCursor SDL_DestroyCursor
/* ##SDL_mutex.h */
#define SDL_CondBroadcast SDL_BroadcastCondition
#define SDL_CondSignal SDL_SignalCondition
#define SDL_CondWait SDL_WaitCondition
#define SDL_CondWaitTimeout SDL_WaitConditionTimeout
#define SDL_CreateCond SDL_CreateCondition
#define SDL_DestroyCond SDL_DestroyCondition
#define SDL_SemPost SDL_PostSemaphore
#define SDL_SemTryWait SDL_TryWaitSemaphore
#define SDL_SemValue SDL_GetSemaphoreValue
#define SDL_SemWait SDL_WaitSemaphore
#define SDL_SemWaitTimeout SDL_WaitSemaphoreTimeout
/* ##SDL_pixels.h */ /* ##SDL_pixels.h */
#define SDL_AllocFormat SDL_CreatePixelFormat #define SDL_AllocFormat SDL_CreatePixelFormat
#define SDL_AllocPalette SDL_CreatePalette #define SDL_AllocPalette SDL_CreatePalette
@ -711,6 +724,19 @@
/* ##SDL_mouse.h */ /* ##SDL_mouse.h */
#define SDL_FreeCursor SDL_FreeCursor_renamed_SDL_DestroyCursor #define SDL_FreeCursor SDL_FreeCursor_renamed_SDL_DestroyCursor
/* ##SDL_mutex.h */
#define SDL_CondBroadcast SDL_CondBroadcast_renamed_SDL_BroadcastCondition
#define SDL_CondSignal SDL_CondSignal_renamed_SDL_SignalCondition
#define SDL_CondWait SDL_CondWait_renamed_SDL_WaitCondition
#define SDL_CondWaitTimeout SDL_CondWaitTimeout_renamed_SDL_WaitConditionTimeout
#define SDL_CreateCond SDL_CreateCond_renamed_SDL_CreateCondition
#define SDL_DestroyCond SDL_DestroyCond_renamed_SDL_DestroyCondition
#define SDL_SemPost SDL_SemPost_renamed_SDL_PostSemaphore
#define SDL_SemTryWait SDL_SemTryWait_renamed_SDL_TryWaitSemaphore
#define SDL_SemValue SDL_SemValue_renamed_SDL_GetSemaphoreValue
#define SDL_SemWait SDL_SemWait_renamed_SDL_WaitSemaphore
#define SDL_SemWaitTimeout SDL_SemWaitTimeout_renamed_SDL_WaitSemaphoreTimeout
/* ##SDL_pixels.h */ /* ##SDL_pixels.h */
#define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_CreatePixelFormat #define SDL_AllocFormat SDL_AllocFormat_renamed_SDL_CreatePixelFormat
#define SDL_AllocPalette SDL_AllocPalette_renamed_SDL_CreatePalette #define SDL_AllocPalette SDL_AllocPalette_renamed_SDL_CreatePalette

View file

@ -197,8 +197,8 @@
extern "C" { extern "C" {
#endif #endif
extern DECLSPEC int SDLCALL SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS); extern DECLSPEC int SDLCALL SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS);
extern DECLSPEC int SDLCALL SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS); extern DECLSPEC int SDLCALL SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS);
extern DECLSPEC int SDLCALL SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS); extern DECLSPEC int SDLCALL SDL_WaitEventTimeoutNS(SDL_Event *event, Sint64 timeoutNS);
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */

View file

@ -950,14 +950,14 @@ static int audioqueue_thread(void *arg)
rc = prepare_audioqueue(this); rc = prepare_audioqueue(this);
if (!rc) { if (!rc) {
this->hidden->thread_error = SDL_strdup(SDL_GetError()); this->hidden->thread_error = SDL_strdup(SDL_GetError());
SDL_SemPost(this->hidden->ready_semaphore); SDL_PostSemaphore(this->hidden->ready_semaphore);
return 0; return 0;
} }
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH); SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
/* init was successful, alert parent thread and start running... */ /* init was successful, alert parent thread and start running... */
SDL_SemPost(this->hidden->ready_semaphore); SDL_PostSemaphore(this->hidden->ready_semaphore);
while (!SDL_AtomicGet(&this->shutdown)) { while (!SDL_AtomicGet(&this->shutdown)) {
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.10, 1); CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.10, 1);
@ -1119,7 +1119,7 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname)
return -1; return -1;
} }
SDL_SemWait(this->hidden->ready_semaphore); SDL_WaitSemaphore(this->hidden->ready_semaphore);
SDL_DestroySemaphore(this->hidden->ready_semaphore); SDL_DestroySemaphore(this->hidden->ready_semaphore);
this->hidden->ready_semaphore = NULL; this->hidden->ready_semaphore = NULL;

View file

@ -137,7 +137,7 @@ static void jackShutdownCallback(void *arg) /* JACK went away; device is lost. *
{ {
SDL_AudioDevice *this = (SDL_AudioDevice *)arg; SDL_AudioDevice *this = (SDL_AudioDevice *)arg;
SDL_OpenedAudioDeviceDisconnected(this); SDL_OpenedAudioDeviceDisconnected(this);
SDL_SemPost(this->hidden->iosem); /* unblock the SDL thread. */ SDL_PostSemaphore(this->hidden->iosem); /* unblock the SDL thread. */
} }
// !!! FIXME: implement and register these! // !!! FIXME: implement and register these!
@ -169,7 +169,7 @@ static int jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
} }
} }
SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; refill the buffer. */ SDL_PostSemaphore(this->hidden->iosem); /* tell SDL thread we're done; refill the buffer. */
return 0; return 0;
} }
@ -177,7 +177,7 @@ static int jackProcessPlaybackCallback(jack_nframes_t nframes, void *arg)
static void JACK_WaitDevice(_THIS) static void JACK_WaitDevice(_THIS)
{ {
if (SDL_AtomicGet(&this->enabled)) { if (SDL_AtomicGet(&this->enabled)) {
if (SDL_SemWait(this->hidden->iosem) == -1) { if (SDL_WaitSemaphore(this->hidden->iosem) == -1) {
SDL_OpenedAudioDeviceDisconnected(this); SDL_OpenedAudioDeviceDisconnected(this);
} }
} }
@ -210,7 +210,7 @@ static int jackProcessCaptureCallback(jack_nframes_t nframes, void *arg)
} }
} }
SDL_SemPost(this->hidden->iosem); /* tell SDL thread we're done; new buffer is ready! */ SDL_PostSemaphore(this->hidden->iosem); /* tell SDL thread we're done; new buffer is ready! */
return 0; return 0;
} }
@ -219,7 +219,7 @@ static int JACK_CaptureFromDevice(_THIS, void *buffer, int buflen)
SDL_assert(buflen == this->spec.size); /* we always fill a full buffer. */ SDL_assert(buflen == this->spec.size); /* we always fill a full buffer. */
/* Wait for JACK to fill the iobuffer */ /* Wait for JACK to fill the iobuffer */
if (SDL_SemWait(this->hidden->iosem) == -1) { if (SDL_WaitSemaphore(this->hidden->iosem) == -1) {
return -1; return -1;
} }
@ -229,7 +229,7 @@ static int JACK_CaptureFromDevice(_THIS, void *buffer, int buflen)
static void JACK_FlushCapture(_THIS) static void JACK_FlushCapture(_THIS)
{ {
SDL_SemWait(this->hidden->iosem); SDL_WaitSemaphore(this->hidden->iosem);
} }
static void JACK_CloseDevice(_THIS) static void JACK_CloseDevice(_THIS)

View file

@ -186,7 +186,7 @@ static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context; struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context;
LOGV("SLES: Recording Callback"); LOGV("SLES: Recording Callback");
SDL_SemPost(audiodata->playsem); SDL_PostSemaphore(audiodata->playsem);
} }
static void openslES_DestroyPCMRecorder(_THIS) static void openslES_DestroyPCMRecorder(_THIS)
@ -363,7 +363,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context; struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context;
LOGV("SLES: Playback Callback"); LOGV("SLES: Playback Callback");
SDL_SemPost(audiodata->playsem); SDL_PostSemaphore(audiodata->playsem);
} }
static void openslES_DestroyPCMPlayer(_THIS) static void openslES_DestroyPCMPlayer(_THIS)
@ -625,7 +625,7 @@ static void openslES_WaitDevice(_THIS)
LOGV("openslES_WaitDevice()"); LOGV("openslES_WaitDevice()");
/* Wait for an audio chunk to finish */ /* Wait for an audio chunk to finish */
SDL_SemWait(audiodata->playsem); SDL_WaitSemaphore(audiodata->playsem);
} }
static void openslES_PlayDevice(_THIS) static void openslES_PlayDevice(_THIS)
@ -646,7 +646,7 @@ static void openslES_PlayDevice(_THIS)
/* If Enqueue fails, callback won't be called. /* If Enqueue fails, callback won't be called.
* Post the semphore, not to run out of buffer */ * Post the semphore, not to run out of buffer */
if (SL_RESULT_SUCCESS != result) { if (SL_RESULT_SUCCESS != result) {
SDL_SemPost(audiodata->playsem); SDL_PostSemaphore(audiodata->playsem);
} }
} }
@ -676,7 +676,7 @@ static int openslES_CaptureFromDevice(_THIS, void *buffer, int buflen)
SLresult result; SLresult result;
/* Wait for new recorded data */ /* Wait for new recorded data */
SDL_SemWait(audiodata->playsem); SDL_WaitSemaphore(audiodata->playsem);
/* Copy it to the output buffer */ /* Copy it to the output buffer */
SDL_assert(buflen == this->spec.size); SDL_assert(buflen == this->spec.size);

View file

@ -175,7 +175,7 @@ void SDL_WasapiDeviceEventHandler::OnDeviceUpdated(DeviceWatcher ^ sender, Devic
void SDL_WasapiDeviceEventHandler::OnEnumerationCompleted(DeviceWatcher ^ sender, Platform::Object ^ args) void SDL_WasapiDeviceEventHandler::OnEnumerationCompleted(DeviceWatcher ^ sender, Platform::Object ^ args)
{ {
SDL_assert(sender == this->watcher); SDL_assert(sender == this->watcher);
SDL_SemPost(this->completed); SDL_PostSemaphore(this->completed);
} }
void SDL_WasapiDeviceEventHandler::OnDefaultRenderDeviceChanged(Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args) void SDL_WasapiDeviceEventHandler::OnDefaultRenderDeviceChanged(Platform::Object ^ sender, DefaultAudioRenderDeviceChangedEventArgs ^ args)
@ -225,8 +225,8 @@ void WASAPI_EnumerateEndpoints(void)
// listening for updates. // listening for updates.
playback_device_event_handler = new SDL_WasapiDeviceEventHandler(SDL_FALSE); playback_device_event_handler = new SDL_WasapiDeviceEventHandler(SDL_FALSE);
capture_device_event_handler = new SDL_WasapiDeviceEventHandler(SDL_TRUE); capture_device_event_handler = new SDL_WasapiDeviceEventHandler(SDL_TRUE);
SDL_SemWait(playback_device_event_handler->completed); SDL_WaitSemaphore(playback_device_event_handler->completed);
SDL_SemWait(capture_device_event_handler->completed); SDL_WaitSemaphore(capture_device_event_handler->completed);
} }
struct SDL_WasapiActivationHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>, FtmBase, IActivateAudioInterfaceCompletionHandler> struct SDL_WasapiActivationHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>, FtmBase, IActivateAudioInterfaceCompletionHandler>

View file

@ -859,8 +859,8 @@ retry:
SDL_LockMutex(Android_ActivityMutex); SDL_LockMutex(Android_ActivityMutex);
pauseSignaled = SDL_SemValue(Android_PauseSem); pauseSignaled = SDL_GetSemaphoreValue(Android_PauseSem);
resumeSignaled = SDL_SemValue(Android_ResumeSem); resumeSignaled = SDL_GetSemaphoreValue(Android_ResumeSem);
if (pauseSignaled > resumeSignaled) { if (pauseSignaled > resumeSignaled) {
SDL_UnlockMutex(Android_ActivityMutex); SDL_UnlockMutex(Android_ActivityMutex);
@ -1225,12 +1225,12 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)(
SDL_SendQuit(); SDL_SendQuit();
SDL_SendAppEvent(SDL_EVENT_TERMINATING); SDL_SendAppEvent(SDL_EVENT_TERMINATING);
/* Robustness: clear any pending Pause */ /* Robustness: clear any pending Pause */
while (SDL_SemTryWait(Android_PauseSem) == 0) { while (SDL_TryWaitSemaphore(Android_PauseSem) == 0) {
/* empty */ /* empty */
} }
/* Resume the event loop so that the app can catch SDL_EVENT_QUIT which /* Resume the event loop so that the app can catch SDL_EVENT_QUIT which
* should now be the top event in the event queue. */ * should now be the top event in the event queue. */
SDL_SemPost(Android_ResumeSem); SDL_PostSemaphore(Android_ResumeSem);
} }
/* Activity ends */ /* Activity ends */
@ -1272,7 +1272,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)(
/* Signal the pause semaphore so the event loop knows to pause and (optionally) block itself. /* Signal the pause semaphore so the event loop knows to pause and (optionally) block itself.
* Sometimes 2 pauses can be queued (eg pause/resume/pause), so it's always increased. */ * Sometimes 2 pauses can be queued (eg pause/resume/pause), so it's always increased. */
SDL_SemPost(Android_PauseSem); SDL_PostSemaphore(Android_PauseSem);
} }
/* Resume */ /* Resume */
@ -1285,7 +1285,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)(
* We can't restore the GL Context here because it needs to be done on the SDL main thread * We can't restore the GL Context here because it needs to be done on the SDL main thread
* and this function will be called from the Java thread instead. * and this function will be called from the Java thread instead.
*/ */
SDL_SemPost(Android_ResumeSem); SDL_PostSemaphore(Android_ResumeSem);
} }
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeFocusChanged)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeFocusChanged)(

View file

@ -44,16 +44,16 @@ SDL3_0.0.0 {
SDL_CloseJoystick; SDL_CloseJoystick;
SDL_CloseSensor; SDL_CloseSensor;
SDL_ComposeCustomBlendMode; SDL_ComposeCustomBlendMode;
SDL_CondBroadcast; SDL_BroadcastCondition;
SDL_CondSignal; SDL_SignalCondition;
SDL_CondWait; SDL_WaitCondition;
SDL_CondWaitTimeout; SDL_WaitConditionTimeout;
SDL_ConvertPixels; SDL_ConvertPixels;
SDL_ConvertSurface; SDL_ConvertSurface;
SDL_ConvertSurfaceFormat; SDL_ConvertSurfaceFormat;
SDL_CreateAudioStream; SDL_CreateAudioStream;
SDL_CreateColorCursor; SDL_CreateColorCursor;
SDL_CreateCond; SDL_CreateCondition;
SDL_CreateCursor; SDL_CreateCursor;
SDL_CreateMutex; SDL_CreateMutex;
SDL_CreatePalette; SDL_CreatePalette;
@ -80,7 +80,7 @@ SDL3_0.0.0 {
SDL_DelayNS; SDL_DelayNS;
SDL_DequeueAudio; SDL_DequeueAudio;
SDL_DestroyAudioStream; SDL_DestroyAudioStream;
SDL_DestroyCond; SDL_DestroyCondition;
SDL_DestroyMutex; SDL_DestroyMutex;
SDL_DestroyPalette; SDL_DestroyPalette;
SDL_DestroyPixelFormat; SDL_DestroyPixelFormat;
@ -548,11 +548,11 @@ SDL3_0.0.0 {
SDL_SaveBMP_RW; SDL_SaveBMP_RW;
SDL_ScreenKeyboardShown; SDL_ScreenKeyboardShown;
SDL_ScreenSaverEnabled; SDL_ScreenSaverEnabled;
SDL_SemPost; SDL_PostSemaphore;
SDL_SemTryWait; SDL_TryWaitSemaphore;
SDL_SemValue; SDL_GetSemaphoreValue;
SDL_SemWait; SDL_WaitSemaphore;
SDL_SemWaitTimeout; SDL_WaitSemaphoreTimeout;
SDL_SendGamepadEffect; SDL_SendGamepadEffect;
SDL_SendJoystickEffect; SDL_SendJoystickEffect;
SDL_SetAssertionHandler; SDL_SetAssertionHandler;

View file

@ -68,16 +68,16 @@
#define SDL_CloseJoystick SDL_CloseJoystick_REAL #define SDL_CloseJoystick SDL_CloseJoystick_REAL
#define SDL_CloseSensor SDL_CloseSensor_REAL #define SDL_CloseSensor SDL_CloseSensor_REAL
#define SDL_ComposeCustomBlendMode SDL_ComposeCustomBlendMode_REAL #define SDL_ComposeCustomBlendMode SDL_ComposeCustomBlendMode_REAL
#define SDL_CondBroadcast SDL_CondBroadcast_REAL #define SDL_BroadcastCondition SDL_BroadcastCondition_REAL
#define SDL_CondSignal SDL_CondSignal_REAL #define SDL_SignalCondition SDL_SignalCondition_REAL
#define SDL_CondWait SDL_CondWait_REAL #define SDL_WaitCondition SDL_WaitCondition_REAL
#define SDL_CondWaitTimeout SDL_CondWaitTimeout_REAL #define SDL_WaitConditionTimeout SDL_WaitConditionTimeout_REAL
#define SDL_ConvertPixels SDL_ConvertPixels_REAL #define SDL_ConvertPixels SDL_ConvertPixels_REAL
#define SDL_ConvertSurface SDL_ConvertSurface_REAL #define SDL_ConvertSurface SDL_ConvertSurface_REAL
#define SDL_ConvertSurfaceFormat SDL_ConvertSurfaceFormat_REAL #define SDL_ConvertSurfaceFormat SDL_ConvertSurfaceFormat_REAL
#define SDL_CreateAudioStream SDL_CreateAudioStream_REAL #define SDL_CreateAudioStream SDL_CreateAudioStream_REAL
#define SDL_CreateColorCursor SDL_CreateColorCursor_REAL #define SDL_CreateColorCursor SDL_CreateColorCursor_REAL
#define SDL_CreateCond SDL_CreateCond_REAL #define SDL_CreateCondition SDL_CreateCondition_REAL
#define SDL_CreateCursor SDL_CreateCursor_REAL #define SDL_CreateCursor SDL_CreateCursor_REAL
#define SDL_CreateMutex SDL_CreateMutex_REAL #define SDL_CreateMutex SDL_CreateMutex_REAL
#define SDL_CreatePalette SDL_CreatePalette_REAL #define SDL_CreatePalette SDL_CreatePalette_REAL
@ -104,7 +104,7 @@
#define SDL_DelayNS SDL_DelayNS_REAL #define SDL_DelayNS SDL_DelayNS_REAL
#define SDL_DequeueAudio SDL_DequeueAudio_REAL #define SDL_DequeueAudio SDL_DequeueAudio_REAL
#define SDL_DestroyAudioStream SDL_DestroyAudioStream_REAL #define SDL_DestroyAudioStream SDL_DestroyAudioStream_REAL
#define SDL_DestroyCond SDL_DestroyCond_REAL #define SDL_DestroyCondition SDL_DestroyCondition_REAL
#define SDL_DestroyMutex SDL_DestroyMutex_REAL #define SDL_DestroyMutex SDL_DestroyMutex_REAL
#define SDL_DestroyPalette SDL_DestroyPalette_REAL #define SDL_DestroyPalette SDL_DestroyPalette_REAL
#define SDL_DestroyPixelFormat SDL_DestroyPixelFormat_REAL #define SDL_DestroyPixelFormat SDL_DestroyPixelFormat_REAL
@ -572,11 +572,11 @@
#define SDL_SaveBMP_RW SDL_SaveBMP_RW_REAL #define SDL_SaveBMP_RW SDL_SaveBMP_RW_REAL
#define SDL_ScreenKeyboardShown SDL_ScreenKeyboardShown_REAL #define SDL_ScreenKeyboardShown SDL_ScreenKeyboardShown_REAL
#define SDL_ScreenSaverEnabled SDL_ScreenSaverEnabled_REAL #define SDL_ScreenSaverEnabled SDL_ScreenSaverEnabled_REAL
#define SDL_SemPost SDL_SemPost_REAL #define SDL_PostSemaphore SDL_PostSemaphore_REAL
#define SDL_SemTryWait SDL_SemTryWait_REAL #define SDL_TryWaitSemaphore SDL_TryWaitSemaphore_REAL
#define SDL_SemValue SDL_SemValue_REAL #define SDL_GetSemaphoreValue SDL_GetSemaphoreValue_REAL
#define SDL_SemWait SDL_SemWait_REAL #define SDL_WaitSemaphore SDL_WaitSemaphore_REAL
#define SDL_SemWaitTimeout SDL_SemWaitTimeout_REAL #define SDL_WaitSemaphoreTimeout SDL_WaitSemaphoreTimeout_REAL
#define SDL_SendGamepadEffect SDL_SendGamepadEffect_REAL #define SDL_SendGamepadEffect SDL_SendGamepadEffect_REAL
#define SDL_SendJoystickEffect SDL_SendJoystickEffect_REAL #define SDL_SendJoystickEffect SDL_SendJoystickEffect_REAL
#define SDL_SetAssertionHandler SDL_SetAssertionHandler_REAL #define SDL_SetAssertionHandler SDL_SetAssertionHandler_REAL

View file

@ -149,16 +149,16 @@ SDL_DYNAPI_PROC(void,SDL_CloseGamepad,(SDL_Gamepad *a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseJoystick,(SDL_Joystick *a),(a),) SDL_DYNAPI_PROC(void,SDL_CloseJoystick,(SDL_Joystick *a),(a),)
SDL_DYNAPI_PROC(void,SDL_CloseSensor,(SDL_Sensor *a),(a),) SDL_DYNAPI_PROC(void,SDL_CloseSensor,(SDL_Sensor *a),(a),)
SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_CondBroadcast,(SDL_cond *a),(a),return) SDL_DYNAPI_PROC(int,SDL_BroadcastCondition,(SDL_cond *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_CondSignal,(SDL_cond *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SignalCondition,(SDL_cond *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_CondWait,(SDL_cond *a, SDL_mutex *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_WaitCondition,(SDL_cond *a, SDL_mutex *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_CondWaitTimeout,(SDL_cond *a, SDL_mutex *b, Sint32 c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_WaitConditionTimeout,(SDL_cond *a, SDL_mutex *b, Sint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_ConvertPixels,(int a, int b, Uint32 c, const void *d, int e, Uint32 f, void *g, int h),(a,b,c,d,e,f,g,h),return) SDL_DYNAPI_PROC(int,SDL_ConvertPixels,(int a, int b, Uint32 c, const void *d, int e, Uint32 f, void *g, int h),(a,b,c,d,e,f,g,h),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurface,(SDL_Surface *a, const SDL_PixelFormat *b),(a,b),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurface,(SDL_Surface *a, const SDL_PixelFormat *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceFormat,(SDL_Surface *a, Uint32 b),(a,b),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceFormat,(SDL_Surface *a, Uint32 b),(a,b),return)
SDL_DYNAPI_PROC(SDL_AudioStream*,SDL_CreateAudioStream,(SDL_AudioFormat a, int b, int c, SDL_AudioFormat d, int e, int f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(SDL_AudioStream*,SDL_CreateAudioStream,(SDL_AudioFormat a, int b, int c, SDL_AudioFormat d, int e, int f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateColorCursor,(SDL_Surface *a, int b, int c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateColorCursor,(SDL_Surface *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_cond*,SDL_CreateCond,(void),(),return) SDL_DYNAPI_PROC(SDL_cond*,SDL_CreateCondition,(void),(),return)
SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateCursor,(const Uint8 *a, const Uint8 *b, int c, int d, int e, int f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateCursor,(const Uint8 *a, const Uint8 *b, int c, int d, int e, int f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_mutex*,SDL_CreateMutex,(void),(),return) SDL_DYNAPI_PROC(SDL_mutex*,SDL_CreateMutex,(void),(),return)
SDL_DYNAPI_PROC(SDL_Palette*,SDL_CreatePalette,(int a),(a),return) SDL_DYNAPI_PROC(SDL_Palette*,SDL_CreatePalette,(int a),(a),return)
@ -182,7 +182,7 @@ SDL_DYNAPI_PROC(void,SDL_Delay,(Uint32 a),(a),)
SDL_DYNAPI_PROC(void,SDL_DelayNS,(Uint64 a),(a),) SDL_DYNAPI_PROC(void,SDL_DelayNS,(Uint64 a),(a),)
SDL_DYNAPI_PROC(Uint32,SDL_DequeueAudio,(SDL_AudioDeviceID a, void *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(Uint32,SDL_DequeueAudio,(SDL_AudioDeviceID a, void *b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_DestroyAudioStream,(SDL_AudioStream *a),(a),) SDL_DYNAPI_PROC(void,SDL_DestroyAudioStream,(SDL_AudioStream *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroyCond,(SDL_cond *a),(a),) SDL_DYNAPI_PROC(void,SDL_DestroyCondition,(SDL_cond *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroyMutex,(SDL_mutex *a),(a),) SDL_DYNAPI_PROC(void,SDL_DestroyMutex,(SDL_mutex *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroyPalette,(SDL_Palette *a),(a),) SDL_DYNAPI_PROC(void,SDL_DestroyPalette,(SDL_Palette *a),(a),)
SDL_DYNAPI_PROC(void,SDL_DestroyPixelFormat,(SDL_PixelFormat *a),(a),) SDL_DYNAPI_PROC(void,SDL_DestroyPixelFormat,(SDL_PixelFormat *a),(a),)
@ -628,11 +628,11 @@ SDL_DYNAPI_PROC(size_t,SDL_SIMDGetAlignment,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_SaveBMP_RW,(SDL_Surface *a, SDL_RWops *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_SaveBMP_RW,(SDL_Surface *a, SDL_RWops *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ScreenKeyboardShown,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_ScreenKeyboardShown,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ScreenSaverEnabled,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_ScreenSaverEnabled,(void),(),return)
SDL_DYNAPI_PROC(int,SDL_SemPost,(SDL_sem *a),(a),return) SDL_DYNAPI_PROC(int,SDL_PostSemaphore,(SDL_sem *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SemTryWait,(SDL_sem *a),(a),return) SDL_DYNAPI_PROC(int,SDL_TryWaitSemaphore,(SDL_sem *a),(a),return)
SDL_DYNAPI_PROC(Uint32,SDL_SemValue,(SDL_sem *a),(a),return) SDL_DYNAPI_PROC(Uint32,SDL_GetSemaphoreValue,(SDL_sem *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SemWait,(SDL_sem *a),(a),return) SDL_DYNAPI_PROC(int,SDL_WaitSemaphore,(SDL_sem *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SemWaitTimeout,(SDL_sem *a, Sint32 b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_WaitSemaphoreTimeout,(SDL_sem *a, Sint32 b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SendGamepadEffect,(SDL_Gamepad *a, const void *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_SendGamepadEffect,(SDL_Gamepad *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SendJoystickEffect,(SDL_Joystick *a, const void *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_SendJoystickEffect,(SDL_Joystick *a, const void *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_SetAssertionHandler,(SDL_AssertionHandler a, void *b),(a,b),) SDL_DYNAPI_PROC(void,SDL_SetAssertionHandler,(SDL_AssertionHandler a, void *b),(a,b),)

View file

@ -108,7 +108,7 @@ static int SDL_CreateThreadBarrier(SDL_ThreadBarrier *barrier, Uint32 count)
if (barrier->mutex == NULL) { if (barrier->mutex == NULL) {
return -1; /* Error set by CreateMutex */ return -1; /* Error set by CreateMutex */
} }
barrier->cond = SDL_CreateCond(); barrier->cond = SDL_CreateCondition();
if (barrier->cond == NULL) { if (barrier->cond == NULL) {
return -1; /* Error set by CreateCond */ return -1; /* Error set by CreateCond */
} }
@ -121,7 +121,7 @@ static int SDL_CreateThreadBarrier(SDL_ThreadBarrier *barrier, Uint32 count)
static void SDL_DestroyThreadBarrier(SDL_ThreadBarrier *barrier) static void SDL_DestroyThreadBarrier(SDL_ThreadBarrier *barrier)
{ {
SDL_DestroyCond(barrier->cond); SDL_DestroyCondition(barrier->cond);
SDL_DestroyMutex(barrier->mutex); SDL_DestroyMutex(barrier->mutex);
} }
@ -131,11 +131,11 @@ static int SDL_WaitThreadBarrier(SDL_ThreadBarrier *barrier)
barrier->count += 1; barrier->count += 1;
if (barrier->count >= barrier->trip_count) { if (barrier->count >= barrier->trip_count) {
barrier->count = 0; barrier->count = 0;
SDL_CondBroadcast(barrier->cond); SDL_BroadcastCondition(barrier->cond);
SDL_UnlockMutex(barrier->mutex); SDL_UnlockMutex(barrier->mutex);
return 1; return 1;
} }
SDL_CondWait(barrier->cond, barrier->mutex); SDL_WaitCondition(barrier->cond, barrier->mutex);
SDL_UnlockMutex(barrier->mutex); SDL_UnlockMutex(barrier->mutex);
return 0; return 0;
} }
@ -219,7 +219,7 @@ static hid_device *new_hid_device(void)
dev->blocking = 1; dev->blocking = 1;
dev->mutex = SDL_CreateMutex(); dev->mutex = SDL_CreateMutex();
dev->condition = SDL_CreateCond(); dev->condition = SDL_CreateCondition();
SDL_CreateThreadBarrier(&dev->barrier, 2); SDL_CreateThreadBarrier(&dev->barrier, 2);
return dev; return dev;
@ -229,7 +229,7 @@ static void free_hid_device(hid_device *dev)
{ {
/* Clean up the thread objects */ /* Clean up the thread objects */
SDL_DestroyThreadBarrier(&dev->barrier); SDL_DestroyThreadBarrier(&dev->barrier);
SDL_DestroyCond(dev->condition); SDL_DestroyCondition(dev->condition);
SDL_DestroyMutex(dev->mutex); SDL_DestroyMutex(dev->mutex);
/* Free the device itself */ /* Free the device itself */
@ -1011,7 +1011,7 @@ static void LIBUSB_CALL read_callback(struct libusb_transfer *transfer)
if (dev->input_reports == NULL) { if (dev->input_reports == NULL) {
/* The list is empty. Put it at the root. */ /* The list is empty. Put it at the root. */
dev->input_reports = rpt; dev->input_reports = rpt;
SDL_CondSignal(dev->condition); SDL_SignalCondition(dev->condition);
} }
else { else {
/* Find the end of the list and attach. */ /* Find the end of the list and attach. */
@ -1122,7 +1122,7 @@ static int SDLCALL read_thread(void *param)
the condition actually will go to sleep before the condition is the condition actually will go to sleep before the condition is
signaled. */ signaled. */
SDL_LockMutex(dev->mutex); SDL_LockMutex(dev->mutex);
SDL_CondBroadcast(dev->condition); SDL_BroadcastCondition(dev->condition);
SDL_UnlockMutex(dev->mutex); SDL_UnlockMutex(dev->mutex);
/* The dev->transfer->buffer and dev->transfer objects are cleaned up /* The dev->transfer->buffer and dev->transfer objects are cleaned up
@ -1466,7 +1466,7 @@ int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t
if (milliseconds == -1) { if (milliseconds == -1) {
/* Blocking */ /* Blocking */
while (!dev->input_reports && !dev->shutdown_thread) { while (!dev->input_reports && !dev->shutdown_thread) {
SDL_CondWait(dev->condition, dev->mutex); SDL_WaitCondition(dev->condition, dev->mutex);
} }
if (dev->input_reports) { if (dev->input_reports) {
bytes_read = return_data(dev, data, length); bytes_read = return_data(dev, data, length);
@ -1477,7 +1477,7 @@ int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t
int res; int res;
while (!dev->input_reports && !dev->shutdown_thread) { while (!dev->input_reports && !dev->shutdown_thread) {
res = SDL_CondWaitTimeout(dev->condition, dev->mutex, milliseconds); res = SDL_WaitConditionTimeout(dev->condition, dev->mutex, milliseconds);
if (res == 0) { if (res == 0) {
if (dev->input_reports) { if (dev->input_reports) {
bytes_read = return_data(dev, data, length); bytes_read = return_data(dev, data, length);

View file

@ -64,7 +64,7 @@ static int SDLCALL SDL_HIDAPI_RumbleThread(void *data)
while (SDL_AtomicGet(&ctx->running)) { while (SDL_AtomicGet(&ctx->running)) {
SDL_HIDAPI_RumbleRequest *request = NULL; SDL_HIDAPI_RumbleRequest *request = NULL;
SDL_SemWait(ctx->request_sem); SDL_WaitSemaphore(ctx->request_sem);
SDL_LockMutex(SDL_HIDAPI_rumble_lock); SDL_LockMutex(SDL_HIDAPI_rumble_lock);
request = ctx->requests_tail; request = ctx->requests_tail;
@ -107,7 +107,7 @@ static void SDL_HIDAPI_StopRumbleThread(SDL_HIDAPI_RumbleContext *ctx)
if (ctx->thread) { if (ctx->thread) {
int result; int result;
SDL_SemPost(ctx->request_sem); SDL_PostSemaphore(ctx->request_sem);
SDL_WaitThread(ctx->thread, &result); SDL_WaitThread(ctx->thread, &result);
ctx->thread = NULL; ctx->thread = NULL;
} }
@ -236,7 +236,7 @@ int SDL_HIDAPI_SendRumbleWithCallbackAndUnlock(SDL_HIDAPI_Device *device, const
/* Make sure we unlock before posting the semaphore so the rumble thread can run immediately */ /* Make sure we unlock before posting the semaphore so the rumble thread can run immediately */
SDL_HIDAPI_UnlockRumble(); SDL_HIDAPI_UnlockRumble();
SDL_SemPost(ctx->request_sem); SDL_PostSemaphore(ctx->request_sem);
return size; return size;
} }

View file

@ -365,7 +365,7 @@ static int SDLCALL SDL_JoystickThread(void *_data)
#endif #endif
#ifdef SDL_JOYSTICK_XINPUT #ifdef SDL_JOYSTICK_XINPUT
/* WM_DEVICECHANGE not working, poll for new XINPUT controllers */ /* WM_DEVICECHANGE not working, poll for new XINPUT controllers */
SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000); SDL_WaitConditionTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000);
if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) { if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) {
/* scan for any change in XInput devices */ /* scan for any change in XInput devices */
Uint8 userId; Uint8 userId;
@ -403,7 +403,7 @@ static int SDL_StartJoystickThread(void)
return -1; return -1;
} }
s_condJoystickThread = SDL_CreateCond(); s_condJoystickThread = SDL_CreateCondition();
if (s_condJoystickThread == NULL) { if (s_condJoystickThread == NULL) {
return -1; return -1;
} }
@ -424,7 +424,7 @@ static void SDL_StopJoystickThread(void)
SDL_LockMutex(s_mutexJoyStickEnum); SDL_LockMutex(s_mutexJoyStickEnum);
s_bJoystickThreadQuit = SDL_TRUE; s_bJoystickThreadQuit = SDL_TRUE;
SDL_CondBroadcast(s_condJoystickThread); /* signal the joystick thread to quit */ SDL_BroadcastCondition(s_condJoystickThread); /* signal the joystick thread to quit */
SDL_UnlockMutex(s_mutexJoyStickEnum); SDL_UnlockMutex(s_mutexJoyStickEnum);
PostThreadMessage(SDL_GetThreadID(s_joystickThread), WM_QUIT, 0, 0); PostThreadMessage(SDL_GetThreadID(s_joystickThread), WM_QUIT, 0, 0);
@ -434,7 +434,7 @@ static void SDL_StopJoystickThread(void)
SDL_WaitThread(s_joystickThread, NULL); /* wait for it to bugger off */ SDL_WaitThread(s_joystickThread, NULL); /* wait for it to bugger off */
SDL_LockJoysticks(); SDL_LockJoysticks();
SDL_DestroyCond(s_condJoystickThread); SDL_DestroyCondition(s_condJoystickThread);
s_condJoystickThread = NULL; s_condJoystickThread = NULL;
SDL_DestroyMutex(s_mutexJoyStickEnum); SDL_DestroyMutex(s_mutexJoyStickEnum);

View file

@ -481,17 +481,17 @@ void SDL_DetachThread(SDL_Thread *thread)
} }
} }
int SDL_SemWait(SDL_sem *sem) int SDL_WaitSemaphore(SDL_sem *sem)
{ {
return SDL_SemWaitTimeoutNS(sem, SDL_MUTEX_MAXWAIT); return SDL_WaitSemaphoreTimeoutNS(sem, SDL_MUTEX_MAXWAIT);
} }
int SDL_SemTryWait(SDL_sem *sem) int SDL_TryWaitSemaphore(SDL_sem *sem)
{ {
return SDL_SemWaitTimeoutNS(sem, 0); return SDL_WaitSemaphoreTimeoutNS(sem, 0);
} }
int SDL_SemWaitTimeout(SDL_sem *sem, Sint32 timeoutMS) int SDL_WaitSemaphoreTimeout(SDL_sem *sem, Sint32 timeoutMS)
{ {
Sint64 timeoutNS; Sint64 timeoutNS;
@ -500,15 +500,15 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Sint32 timeoutMS)
} else { } else {
timeoutNS = -1; timeoutNS = -1;
} }
return SDL_SemWaitTimeoutNS(sem, timeoutNS); return SDL_WaitSemaphoreTimeoutNS(sem, timeoutNS);
} }
int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) int SDL_WaitCondition(SDL_cond *cond, SDL_mutex *mutex)
{ {
return SDL_CondWaitTimeoutNS(cond, mutex, SDL_MUTEX_MAXWAIT); return SDL_WaitConditionTimeoutNS(cond, mutex, SDL_MUTEX_MAXWAIT);
} }
int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Sint32 timeoutMS) int SDL_WaitConditionTimeout(SDL_cond *cond, SDL_mutex *mutex, Sint32 timeoutMS)
{ {
Sint64 timeoutNS; Sint64 timeoutNS;
@ -517,5 +517,5 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Sint32 timeoutMS)
} else { } else {
timeoutNS = -1; timeoutNS = -1;
} }
return SDL_CondWaitTimeoutNS(cond, mutex, timeoutNS); return SDL_WaitConditionTimeoutNS(cond, mutex, timeoutNS);
} }

View file

@ -33,11 +33,11 @@
* suffixed * suffixed
*/ */
#ifndef SDL_THREAD_GENERIC_COND_SUFFIX #ifndef SDL_THREAD_GENERIC_COND_SUFFIX
#define SDL_CreateCond_generic SDL_CreateCond #define SDL_CreateCondition_generic SDL_CreateCondition
#define SDL_DestroyCond_generic SDL_DestroyCond #define SDL_DestroyCondition_generic SDL_DestroyCondition
#define SDL_CondSignal_generic SDL_CondSignal #define SDL_SignalCondition_generic SDL_SignalCondition
#define SDL_CondBroadcast_generic SDL_CondBroadcast #define SDL_BroadcastCondition_generic SDL_BroadcastCondition
#define SDL_CondWaitTimeoutNS_generic SDL_CondWaitTimeoutNS #define SDL_WaitConditionTimeoutNS_generic SDL_WaitConditionTimeoutNS
#endif #endif
typedef struct SDL_cond_generic typedef struct SDL_cond_generic
@ -51,7 +51,7 @@ typedef struct SDL_cond_generic
/* Create a condition variable */ /* Create a condition variable */
SDL_cond * SDL_cond *
SDL_CreateCond_generic(void) SDL_CreateCondition_generic(void)
{ {
SDL_cond_generic *cond; SDL_cond_generic *cond;
@ -62,7 +62,7 @@ SDL_CreateCond_generic(void)
cond->wait_done = SDL_CreateSemaphore(0); cond->wait_done = SDL_CreateSemaphore(0);
cond->waiting = cond->signals = 0; cond->waiting = cond->signals = 0;
if (!cond->lock || !cond->wait_sem || !cond->wait_done) { if (!cond->lock || !cond->wait_sem || !cond->wait_done) {
SDL_DestroyCond_generic((SDL_cond *)cond); SDL_DestroyCondition_generic((SDL_cond *)cond);
cond = NULL; cond = NULL;
} }
} else { } else {
@ -72,7 +72,7 @@ SDL_CreateCond_generic(void)
} }
/* Destroy a condition variable */ /* Destroy a condition variable */
void SDL_DestroyCond_generic(SDL_cond *_cond) void SDL_DestroyCondition_generic(SDL_cond *_cond)
{ {
SDL_cond_generic *cond = (SDL_cond_generic *)_cond; SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
if (cond) { if (cond) {
@ -90,7 +90,7 @@ void SDL_DestroyCond_generic(SDL_cond *_cond)
} }
/* Restart one of the threads that are waiting on the condition variable */ /* Restart one of the threads that are waiting on the condition variable */
int SDL_CondSignal_generic(SDL_cond *_cond) int SDL_SignalCondition_generic(SDL_cond *_cond)
{ {
SDL_cond_generic *cond = (SDL_cond_generic *)_cond; SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
if (cond == NULL) { if (cond == NULL) {
@ -103,9 +103,9 @@ int SDL_CondSignal_generic(SDL_cond *_cond)
SDL_LockMutex(cond->lock); SDL_LockMutex(cond->lock);
if (cond->waiting > cond->signals) { if (cond->waiting > cond->signals) {
++cond->signals; ++cond->signals;
SDL_SemPost(cond->wait_sem); SDL_PostSemaphore(cond->wait_sem);
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
SDL_SemWait(cond->wait_done); SDL_WaitSemaphore(cond->wait_done);
} else { } else {
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
} }
@ -114,7 +114,7 @@ int SDL_CondSignal_generic(SDL_cond *_cond)
} }
/* Restart all threads that are waiting on the condition variable */ /* Restart all threads that are waiting on the condition variable */
int SDL_CondBroadcast_generic(SDL_cond *_cond) int SDL_BroadcastCondition_generic(SDL_cond *_cond)
{ {
SDL_cond_generic *cond = (SDL_cond_generic *)_cond; SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
if (cond == NULL) { if (cond == NULL) {
@ -131,14 +131,14 @@ int SDL_CondBroadcast_generic(SDL_cond *_cond)
num_waiting = (cond->waiting - cond->signals); num_waiting = (cond->waiting - cond->signals);
cond->signals = cond->waiting; cond->signals = cond->waiting;
for (i = 0; i < num_waiting; ++i) { for (i = 0; i < num_waiting; ++i) {
SDL_SemPost(cond->wait_sem); SDL_PostSemaphore(cond->wait_sem);
} }
/* Now all released threads are blocked here, waiting for us. /* Now all released threads are blocked here, waiting for us.
Collect them all (and win fabulous prizes!) :-) Collect them all (and win fabulous prizes!) :-)
*/ */
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
for (i = 0; i < num_waiting; ++i) { for (i = 0; i < num_waiting; ++i) {
SDL_SemWait(cond->wait_done); SDL_WaitSemaphore(cond->wait_done);
} }
} else { } else {
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
@ -156,7 +156,7 @@ Typical use:
Thread A: Thread A:
SDL_LockMutex(lock); SDL_LockMutex(lock);
while ( ! condition ) { while ( ! condition ) {
SDL_CondWait(cond, lock); SDL_WaitCondition(cond, lock);
} }
SDL_UnlockMutex(lock); SDL_UnlockMutex(lock);
@ -165,10 +165,10 @@ Thread B:
... ...
condition = true; condition = true;
... ...
SDL_CondSignal(cond); SDL_SignalCondition(cond);
SDL_UnlockMutex(lock); SDL_UnlockMutex(lock);
*/ */
int SDL_CondWaitTimeoutNS_generic(SDL_cond *_cond, SDL_mutex *mutex, Sint64 timeoutNS) int SDL_WaitConditionTimeoutNS_generic(SDL_cond *_cond, SDL_mutex *mutex, Sint64 timeoutNS)
{ {
SDL_cond_generic *cond = (SDL_cond_generic *)_cond; SDL_cond_generic *cond = (SDL_cond_generic *)_cond;
int retval; int retval;
@ -189,7 +189,7 @@ int SDL_CondWaitTimeoutNS_generic(SDL_cond *_cond, SDL_mutex *mutex, Sint64 time
SDL_UnlockMutex(mutex); SDL_UnlockMutex(mutex);
/* Wait for a signal */ /* Wait for a signal */
retval = SDL_SemWaitTimeoutNS(cond->wait_sem, timeoutNS); retval = SDL_WaitSemaphoreTimeoutNS(cond->wait_sem, timeoutNS);
/* Let the signaler know we have completed the wait, otherwise /* Let the signaler know we have completed the wait, otherwise
the signaler can race ahead and get the condition semaphore the signaler can race ahead and get the condition semaphore
@ -201,10 +201,10 @@ int SDL_CondWaitTimeoutNS_generic(SDL_cond *_cond, SDL_mutex *mutex, Sint64 time
if (cond->signals > 0) { if (cond->signals > 0) {
/* If we timed out, we need to eat a condition signal */ /* If we timed out, we need to eat a condition signal */
if (retval > 0) { if (retval > 0) {
SDL_SemWait(cond->wait_sem); SDL_WaitSemaphore(cond->wait_sem);
} }
/* We always notify the signal thread that we are done */ /* We always notify the signal thread that we are done */
SDL_SemPost(cond->wait_done); SDL_PostSemaphore(cond->wait_done);
/* Signal handshake complete */ /* Signal handshake complete */
--cond->signals; --cond->signals;

View file

@ -25,11 +25,11 @@
#ifdef SDL_THREAD_GENERIC_COND_SUFFIX #ifdef SDL_THREAD_GENERIC_COND_SUFFIX
SDL_cond *SDL_CreateCond_generic(void); SDL_cond *SDL_CreateCondition_generic(void);
void SDL_DestroyCond_generic(SDL_cond *cond); void SDL_DestroyCondition_generic(SDL_cond *cond);
int SDL_CondSignal_generic(SDL_cond *cond); int SDL_SignalCondition_generic(SDL_cond *cond);
int SDL_CondBroadcast_generic(SDL_cond *cond); int SDL_BroadcastCondition_generic(SDL_cond *cond);
int SDL_CondWaitTimeoutNS_generic(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS); int SDL_WaitConditionTimeoutNS_generic(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS);
#endif /* SDL_THREAD_GENERIC_COND_SUFFIX */ #endif /* SDL_THREAD_GENERIC_COND_SUFFIX */

View file

@ -89,7 +89,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn
We set the locking thread id after we obtain the lock We set the locking thread id after we obtain the lock
so unlocks from other threads will fail. so unlocks from other threads will fail.
*/ */
SDL_SemWait(mutex->sem); SDL_WaitSemaphore(mutex->sem);
mutex->owner = this_thread; mutex->owner = this_thread;
mutex->recursive = 0; mutex->recursive = 0;
} }
@ -119,7 +119,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex)
We set the locking thread id after we obtain the lock We set the locking thread id after we obtain the lock
so unlocks from other threads will fail. so unlocks from other threads will fail.
*/ */
retval = SDL_SemWait(mutex->sem); retval = SDL_WaitSemaphore(mutex->sem);
if (retval == 0) { if (retval == 0) {
mutex->owner = this_thread; mutex->owner = this_thread;
mutex->recursive = 0; mutex->recursive = 0;
@ -154,7 +154,7 @@ int SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doe
then release the lock semaphore. then release the lock semaphore.
*/ */
mutex->owner = 0; mutex->owner = 0;
SDL_SemPost(mutex->sem); SDL_PostSemaphore(mutex->sem);
} }
return 0; return 0;
#endif /* SDL_THREADS_DISABLED */ #endif /* SDL_THREADS_DISABLED */

View file

@ -65,7 +65,7 @@ SDL_rwlock *SDL_CreateRWLock_generic(void)
return NULL; return NULL;
} }
rwlock->condition = SDL_CreateCond(); rwlock->condition = SDL_CreateCondition();
if (!rwlock->condition) { if (!rwlock->condition) {
SDL_DestroyMutex(rwlock->lock); SDL_DestroyMutex(rwlock->lock);
SDL_free(rwlock); SDL_free(rwlock);
@ -82,7 +82,7 @@ void SDL_DestroyRWLock_generic(SDL_rwlock *rwlock)
{ {
if (rwlock) { if (rwlock) {
SDL_DestroyMutex(rwlock->lock); SDL_DestroyMutex(rwlock->lock);
SDL_DestroyCond(rwlock->condition); SDL_DestroyCondition(rwlock->condition);
SDL_free(rwlock); SDL_free(rwlock);
} }
} }
@ -111,7 +111,7 @@ int SDL_LockRWLockForWriting_generic(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_AN
} }
while (SDL_AtomicGet(&rwlock->reader_count) > 0) { /* while something is holding the shared lock, keep waiting. */ while (SDL_AtomicGet(&rwlock->reader_count) > 0) { /* while something is holding the shared lock, keep waiting. */
SDL_CondWait(rwlock->condition, rwlock->lock); /* release the lock and wait for readers holding the shared lock to release it, regrab the lock. */ SDL_WaitCondition(rwlock->condition, rwlock->lock); /* release the lock and wait for readers holding the shared lock to release it, regrab the lock. */
} }
/* we hold the lock! */ /* we hold the lock! */
@ -172,7 +172,7 @@ int SDL_UnlockRWLock_generic(SDL_rwlock *rwlock) SDL_NO_THREAD_SAFETY_ANALYSIS /
if (SDL_AtomicGet(&rwlock->reader_count) > 0) { /* we're a reader */ if (SDL_AtomicGet(&rwlock->reader_count) > 0) { /* we're a reader */
SDL_AtomicAdd(&rwlock->reader_count, -1); SDL_AtomicAdd(&rwlock->reader_count, -1);
SDL_CondBroadcast(rwlock->condition); /* alert any pending writers to attempt to try to grab the lock again. */ SDL_BroadcastCondition(rwlock->condition); /* alert any pending writers to attempt to try to grab the lock again. */
} else if (SDL_AtomicGet(&rwlock->writer_count) > 0) { /* we're a writer */ } else if (SDL_AtomicGet(&rwlock->writer_count) > 0) { /* we're a writer */
SDL_AtomicAdd(&rwlock->writer_count, -1); SDL_AtomicAdd(&rwlock->writer_count, -1);
SDL_UnlockMutex(rwlock->lock); /* recursive unlock. */ SDL_UnlockMutex(rwlock->lock); /* recursive unlock. */

View file

@ -37,18 +37,18 @@ void SDL_DestroySemaphore(SDL_sem *sem)
{ {
} }
int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS) int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
{ {
return SDL_SetError("SDL not built with thread support"); return SDL_SetError("SDL not built with thread support");
} }
Uint32 Uint32
SDL_SemValue(SDL_sem *sem) SDL_GetSemaphoreValue(SDL_sem *sem)
{ {
return 0; return 0;
} }
int SDL_SemPost(SDL_sem *sem) int SDL_PostSemaphore(SDL_sem *sem)
{ {
return SDL_SetError("SDL not built with thread support"); return SDL_SetError("SDL not built with thread support");
} }
@ -77,7 +77,7 @@ SDL_CreateSemaphore(Uint32 initial_value)
sem->waiters_count = 0; sem->waiters_count = 0;
sem->count_lock = SDL_CreateMutex(); sem->count_lock = SDL_CreateMutex();
sem->count_nonzero = SDL_CreateCond(); sem->count_nonzero = SDL_CreateCondition();
if (!sem->count_lock || !sem->count_nonzero) { if (!sem->count_lock || !sem->count_nonzero) {
SDL_DestroySemaphore(sem); SDL_DestroySemaphore(sem);
return NULL; return NULL;
@ -94,10 +94,10 @@ void SDL_DestroySemaphore(SDL_sem *sem)
if (sem) { if (sem) {
sem->count = 0xFFFFFFFF; sem->count = 0xFFFFFFFF;
while (sem->waiters_count > 0) { while (sem->waiters_count > 0) {
SDL_CondSignal(sem->count_nonzero); SDL_SignalCondition(sem->count_nonzero);
SDL_Delay(10); SDL_Delay(10);
} }
SDL_DestroyCond(sem->count_nonzero); SDL_DestroyCondition(sem->count_nonzero);
if (sem->count_lock) { if (sem->count_lock) {
SDL_LockMutex(sem->count_lock); SDL_LockMutex(sem->count_lock);
SDL_UnlockMutex(sem->count_lock); SDL_UnlockMutex(sem->count_lock);
@ -107,7 +107,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
} }
} }
int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS) int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
{ {
int retval; int retval;
@ -132,7 +132,7 @@ int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
++sem->waiters_count; ++sem->waiters_count;
retval = 0; retval = 0;
while ((sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT)) { while ((sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT)) {
retval = SDL_CondWaitTimeoutNS(sem->count_nonzero, retval = SDL_WaitConditionTimeoutNS(sem->count_nonzero,
sem->count_lock, timeoutNS); sem->count_lock, timeoutNS);
} }
--sem->waiters_count; --sem->waiters_count;
@ -145,7 +145,7 @@ int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
} }
Uint32 Uint32
SDL_SemValue(SDL_sem *sem) SDL_GetSemaphoreValue(SDL_sem *sem)
{ {
Uint32 value; Uint32 value;
@ -158,7 +158,7 @@ SDL_SemValue(SDL_sem *sem)
return value; return value;
} }
int SDL_SemPost(SDL_sem *sem) int SDL_PostSemaphore(SDL_sem *sem)
{ {
if (sem == NULL) { if (sem == NULL) {
return SDL_InvalidParamError("sem"); return SDL_InvalidParamError("sem");
@ -166,7 +166,7 @@ int SDL_SemPost(SDL_sem *sem)
SDL_LockMutex(sem->count_lock); SDL_LockMutex(sem->count_lock);
if (sem->waiters_count > 0) { if (sem->waiters_count > 0) {
SDL_CondSignal(sem->count_nonzero); SDL_SignalCondition(sem->count_nonzero);
} }
++sem->count; ++sem->count;
SDL_UnlockMutex(sem->count_lock); SDL_UnlockMutex(sem->count_lock);

View file

@ -33,7 +33,7 @@ struct SDL_cond
/* Create a condition variable */ /* Create a condition variable */
SDL_cond * SDL_cond *
SDL_CreateCond(void) SDL_CreateCondition(void)
{ {
SDL_cond *cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond)); SDL_cond *cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond));
if (cond) { if (cond) {
@ -45,7 +45,7 @@ SDL_CreateCond(void)
} }
/* Destroy a condition variable */ /* Destroy a condition variable */
void SDL_DestroyCond(SDL_cond *cond) void SDL_DestroyCondition(SDL_cond *cond)
{ {
if (cond) { if (cond) {
SDL_free(cond); SDL_free(cond);
@ -53,7 +53,7 @@ void SDL_DestroyCond(SDL_cond *cond)
} }
/* Restart one of the threads that are waiting on the condition variable */ /* Restart one of the threads that are waiting on the condition variable */
int SDL_CondSignal(SDL_cond *cond) int SDL_SignalCondition(SDL_cond *cond)
{ {
if (cond == NULL) { if (cond == NULL) {
return SDL_InvalidParamError("cond"); return SDL_InvalidParamError("cond");
@ -64,7 +64,7 @@ int SDL_CondSignal(SDL_cond *cond)
} }
/* Restart all threads that are waiting on the condition variable */ /* Restart all threads that are waiting on the condition variable */
int SDL_CondBroadcast(SDL_cond *cond) int SDL_BroadcastCondition(SDL_cond *cond)
{ {
if (cond == NULL) { if (cond == NULL) {
return SDL_InvalidParamError("cond"); return SDL_InvalidParamError("cond");
@ -83,7 +83,7 @@ Typical use:
Thread A: Thread A:
SDL_LockMutex(lock); SDL_LockMutex(lock);
while ( ! condition ) { while ( ! condition ) {
SDL_CondWait(cond, lock); SDL_WaitCondition(cond, lock);
} }
SDL_UnlockMutex(lock); SDL_UnlockMutex(lock);
@ -92,10 +92,10 @@ Thread B:
... ...
condition = true; condition = true;
... ...
SDL_CondSignal(cond); SDL_SignalCondition(cond);
SDL_UnlockMutex(lock); SDL_UnlockMutex(lock);
*/ */
int SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS) int SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
{ {
Result res; Result res;

View file

@ -61,7 +61,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
SDL_free(sem); SDL_free(sem);
} }
int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS) int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
{ {
if (sem == NULL) { if (sem == NULL) {
return SDL_InvalidParamError("sem"); return SDL_InvalidParamError("sem");
@ -97,7 +97,7 @@ int WaitOnSemaphoreFor(SDL_sem *sem, Sint64 timeout)
return SDL_MUTEX_TIMEDOUT; return SDL_MUTEX_TIMEDOUT;
} }
Uint32 SDL_SemValue(SDL_sem *sem) Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
{ {
if (sem == NULL) { if (sem == NULL) {
SDL_InvalidParamError("sem"); SDL_InvalidParamError("sem");
@ -106,7 +106,7 @@ Uint32 SDL_SemValue(SDL_sem *sem)
return sem->semaphore.current_count; return sem->semaphore.current_count;
} }
int SDL_SemPost(SDL_sem *sem) int SDL_PostSemaphore(SDL_sem *sem)
{ {
if (sem == NULL) { if (sem == NULL) {
return SDL_InvalidParamError("sem"); return SDL_InvalidParamError("sem");

View file

@ -101,7 +101,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
} }
} }
int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS) int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
{ {
if (sem == NULL) { if (sem == NULL) {
return SDL_InvalidParamError("sem"); return SDL_InvalidParamError("sem");
@ -140,7 +140,7 @@ int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
} }
Uint32 Uint32
SDL_SemValue(SDL_sem *sem) SDL_GetSemaphoreValue(SDL_sem *sem)
{ {
if (sem == NULL) { if (sem == NULL) {
SDL_InvalidParamError("sem"); SDL_InvalidParamError("sem");
@ -149,7 +149,7 @@ SDL_SemValue(SDL_sem *sem)
return sem->count; return sem->count;
} }
int SDL_SemPost(SDL_sem *sem) int SDL_PostSemaphore(SDL_sem *sem)
{ {
if (sem == NULL) { if (sem == NULL) {
return SDL_InvalidParamError("sem"); return SDL_InvalidParamError("sem");

View file

@ -79,7 +79,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
} }
} }
int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS) int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
{ {
int ret; int ret;
struct timer_alarm_t alarm; struct timer_alarm_t alarm;
@ -110,7 +110,7 @@ int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
} }
/* Returns the current count of the semaphore */ /* Returns the current count of the semaphore */
Uint32 SDL_SemValue(SDL_sem *sem) Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
{ {
ee_sema_t info; ee_sema_t info;
@ -126,7 +126,7 @@ Uint32 SDL_SemValue(SDL_sem *sem)
return 0; return 0;
} }
int SDL_SemPost(SDL_sem *sem) int SDL_PostSemaphore(SDL_sem *sem)
{ {
int res; int res;

View file

@ -39,7 +39,7 @@ struct SDL_cond
/* Create a condition variable */ /* Create a condition variable */
SDL_cond * SDL_cond *
SDL_CreateCond(void) SDL_CreateCondition(void)
{ {
SDL_cond *cond; SDL_cond *cond;
@ -50,7 +50,7 @@ SDL_CreateCond(void)
cond->wait_done = SDL_CreateSemaphore(0); cond->wait_done = SDL_CreateSemaphore(0);
cond->waiting = cond->signals = 0; cond->waiting = cond->signals = 0;
if (!cond->lock || !cond->wait_sem || !cond->wait_done) { if (!cond->lock || !cond->wait_sem || !cond->wait_done) {
SDL_DestroyCond(cond); SDL_DestroyCondition(cond);
cond = NULL; cond = NULL;
} }
} else { } else {
@ -60,7 +60,7 @@ SDL_CreateCond(void)
} }
/* Destroy a condition variable */ /* Destroy a condition variable */
void SDL_DestroyCond(SDL_cond *cond) void SDL_DestroyCondition(SDL_cond *cond)
{ {
if (cond) { if (cond) {
if (cond->wait_sem) { if (cond->wait_sem) {
@ -77,7 +77,7 @@ void SDL_DestroyCond(SDL_cond *cond)
} }
/* Restart one of the threads that are waiting on the condition variable */ /* Restart one of the threads that are waiting on the condition variable */
int SDL_CondSignal(SDL_cond *cond) int SDL_SignalCondition(SDL_cond *cond)
{ {
if (cond == NULL) { if (cond == NULL) {
return SDL_InvalidParamError("cond"); return SDL_InvalidParamError("cond");
@ -89,9 +89,9 @@ int SDL_CondSignal(SDL_cond *cond)
SDL_LockMutex(cond->lock); SDL_LockMutex(cond->lock);
if (cond->waiting > cond->signals) { if (cond->waiting > cond->signals) {
++cond->signals; ++cond->signals;
SDL_SemPost(cond->wait_sem); SDL_PostSemaphore(cond->wait_sem);
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
SDL_SemWait(cond->wait_done); SDL_WaitSemaphore(cond->wait_done);
} else { } else {
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
} }
@ -100,7 +100,7 @@ int SDL_CondSignal(SDL_cond *cond)
} }
/* Restart all threads that are waiting on the condition variable */ /* Restart all threads that are waiting on the condition variable */
int SDL_CondBroadcast(SDL_cond *cond) int SDL_BroadcastCondition(SDL_cond *cond)
{ {
if (cond == NULL) { if (cond == NULL) {
return SDL_InvalidParamError("cond"); return SDL_InvalidParamError("cond");
@ -116,14 +116,14 @@ int SDL_CondBroadcast(SDL_cond *cond)
num_waiting = (cond->waiting - cond->signals); num_waiting = (cond->waiting - cond->signals);
cond->signals = cond->waiting; cond->signals = cond->waiting;
for (i = 0; i < num_waiting; ++i) { for (i = 0; i < num_waiting; ++i) {
SDL_SemPost(cond->wait_sem); SDL_PostSemaphore(cond->wait_sem);
} }
/* Now all released threads are blocked here, waiting for us. /* Now all released threads are blocked here, waiting for us.
Collect them all (and win fabulous prizes!) :-) Collect them all (and win fabulous prizes!) :-)
*/ */
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
for (i = 0; i < num_waiting; ++i) { for (i = 0; i < num_waiting; ++i) {
SDL_SemWait(cond->wait_done); SDL_WaitSemaphore(cond->wait_done);
} }
} else { } else {
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
@ -141,7 +141,7 @@ Typical use:
Thread A: Thread A:
SDL_LockMutex(lock); SDL_LockMutex(lock);
while ( ! condition ) { while ( ! condition ) {
SDL_CondWait(cond, lock); SDL_WaitCondition(cond, lock);
} }
SDL_UnlockMutex(lock); SDL_UnlockMutex(lock);
@ -150,10 +150,10 @@ Thread B:
... ...
condition = true; condition = true;
... ...
SDL_CondSignal(cond); SDL_SignalCondition(cond);
SDL_UnlockMutex(lock); SDL_UnlockMutex(lock);
*/ */
int SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS) int SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
{ {
int retval; int retval;
@ -173,7 +173,7 @@ int SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
SDL_UnlockMutex(mutex); SDL_UnlockMutex(mutex);
/* Wait for a signal */ /* Wait for a signal */
retval = SDL_SemWaitTimeout(cond->wait_sem, timeoutNS); retval = SDL_WaitSemaphoreTimeout(cond->wait_sem, timeoutNS);
/* Let the signaler know we have completed the wait, otherwise /* Let the signaler know we have completed the wait, otherwise
the signaler can race ahead and get the condition semaphore the signaler can race ahead and get the condition semaphore
@ -185,10 +185,10 @@ int SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
if (cond->signals > 0) { if (cond->signals > 0) {
/* If we timed out, we need to eat a condition signal */ /* If we timed out, we need to eat a condition signal */
if (retval > 0) { if (retval > 0) {
SDL_SemWait(cond->wait_sem); SDL_WaitSemaphore(cond->wait_sem);
} }
/* We always notify the signal thread that we are done */ /* We always notify the signal thread that we are done */
SDL_SemPost(cond->wait_done); SDL_PostSemaphore(cond->wait_done);
/* Signal handshake complete */ /* Signal handshake complete */
--cond->signals; --cond->signals;

View file

@ -73,7 +73,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
* If the timeout is 0 then just poll the semaphore; if it's SDL_MUTEX_MAXWAIT, pass * If the timeout is 0 then just poll the semaphore; if it's SDL_MUTEX_MAXWAIT, pass
* NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout * NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout
* is specified, convert it to microseconds. */ * is specified, convert it to microseconds. */
int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS) int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
{ {
SceUInt timeoutUS; SceUInt timeoutUS;
SceUInt *pTimeout; SceUInt *pTimeout;
@ -110,7 +110,7 @@ int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
} }
/* Returns the current count of the semaphore */ /* Returns the current count of the semaphore */
Uint32 SDL_SemValue(SDL_sem *sem) Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
{ {
SceKernelSemaInfo info; SceKernelSemaInfo info;
@ -126,7 +126,7 @@ Uint32 SDL_SemValue(SDL_sem *sem)
return 0; return 0;
} }
int SDL_SemPost(SDL_sem *sem) int SDL_PostSemaphore(SDL_sem *sem)
{ {
int res; int res;

View file

@ -35,7 +35,7 @@ struct SDL_cond
/* Create a condition variable */ /* Create a condition variable */
SDL_cond * SDL_cond *
SDL_CreateCond(void) SDL_CreateCondition(void)
{ {
SDL_cond *cond; SDL_cond *cond;
@ -51,7 +51,7 @@ SDL_CreateCond(void)
} }
/* Destroy a condition variable */ /* Destroy a condition variable */
void SDL_DestroyCond(SDL_cond *cond) void SDL_DestroyCondition(SDL_cond *cond)
{ {
if (cond) { if (cond) {
pthread_cond_destroy(&cond->cond); pthread_cond_destroy(&cond->cond);
@ -60,7 +60,7 @@ void SDL_DestroyCond(SDL_cond *cond)
} }
/* Restart one of the threads that are waiting on the condition variable */ /* Restart one of the threads that are waiting on the condition variable */
int SDL_CondSignal(SDL_cond *cond) int SDL_SignalCondition(SDL_cond *cond)
{ {
int retval; int retval;
@ -76,7 +76,7 @@ int SDL_CondSignal(SDL_cond *cond)
} }
/* Restart all threads that are waiting on the condition variable */ /* Restart all threads that are waiting on the condition variable */
int SDL_CondBroadcast(SDL_cond *cond) int SDL_BroadcastCondition(SDL_cond *cond)
{ {
int retval; int retval;
@ -91,7 +91,7 @@ int SDL_CondBroadcast(SDL_cond *cond)
return retval; return retval;
} }
int SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS) int SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
{ {
int retval; int retval;
#ifndef HAVE_CLOCK_GETTIME #ifndef HAVE_CLOCK_GETTIME

View file

@ -63,7 +63,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
} }
} }
int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS) int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
{ {
int retval = 0; int retval = 0;
#ifdef HAVE_SEM_TIMEDWAIT #ifdef HAVE_SEM_TIMEDWAIT
@ -150,7 +150,7 @@ int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
} }
Uint32 Uint32
SDL_SemValue(SDL_sem *sem) SDL_GetSemaphoreValue(SDL_sem *sem)
{ {
int ret = 0; int ret = 0;
@ -166,7 +166,7 @@ SDL_SemValue(SDL_sem *sem)
return (Uint32)ret; return (Uint32)ret;
} }
int SDL_SemPost(SDL_sem *sem) int SDL_PostSemaphore(SDL_sem *sem)
{ {
int retval; int retval;

View file

@ -37,7 +37,7 @@ struct SDL_cond
/* Create a condition variable */ /* Create a condition variable */
extern "C" SDL_cond * extern "C" SDL_cond *
SDL_CreateCond(void) SDL_CreateCondition(void)
{ {
/* Allocate and initialize the condition variable */ /* Allocate and initialize the condition variable */
try { try {
@ -54,7 +54,7 @@ SDL_CreateCond(void)
/* Destroy a condition variable */ /* Destroy a condition variable */
extern "C" void extern "C" void
SDL_DestroyCond(SDL_cond *cond) SDL_DestroyCondition(SDL_cond *cond)
{ {
if (cond != NULL) { if (cond != NULL) {
delete cond; delete cond;
@ -63,7 +63,7 @@ SDL_DestroyCond(SDL_cond *cond)
/* Restart one of the threads that are waiting on the condition variable */ /* Restart one of the threads that are waiting on the condition variable */
extern "C" int extern "C" int
SDL_CondSignal(SDL_cond *cond) SDL_SignalCondition(SDL_cond *cond)
{ {
if (cond == NULL) { if (cond == NULL) {
return SDL_InvalidParamError("cond"); return SDL_InvalidParamError("cond");
@ -75,7 +75,7 @@ SDL_CondSignal(SDL_cond *cond)
/* Restart all threads that are waiting on the condition variable */ /* Restart all threads that are waiting on the condition variable */
extern "C" int extern "C" int
SDL_CondBroadcast(SDL_cond *cond) SDL_BroadcastCondition(SDL_cond *cond)
{ {
if (cond == NULL) { if (cond == NULL) {
return SDL_InvalidParamError("cond"); return SDL_InvalidParamError("cond");
@ -94,7 +94,7 @@ Typical use:
Thread A: Thread A:
SDL_LockMutex(lock); SDL_LockMutex(lock);
while ( ! condition ) { while ( ! condition ) {
SDL_CondWait(cond, lock); SDL_WaitCondition(cond, lock);
} }
SDL_UnlockMutex(lock); SDL_UnlockMutex(lock);
@ -103,11 +103,11 @@ Thread B:
... ...
condition = true; condition = true;
... ...
SDL_CondSignal(cond); SDL_SignalCondition(cond);
SDL_UnlockMutex(lock); SDL_UnlockMutex(lock);
*/ */
extern "C" int extern "C" int
SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS) SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
{ {
if (cond == NULL) { if (cond == NULL) {
return SDL_InvalidParamError("cond"); return SDL_InvalidParamError("cond");

View file

@ -39,7 +39,7 @@ struct SDL_cond
/* Create a condition variable */ /* Create a condition variable */
SDL_cond * SDL_cond *
SDL_CreateCond(void) SDL_CreateCondition(void)
{ {
SDL_cond *cond; SDL_cond *cond;
@ -50,7 +50,7 @@ SDL_CreateCond(void)
cond->wait_done = SDL_CreateSemaphore(0); cond->wait_done = SDL_CreateSemaphore(0);
cond->waiting = cond->signals = 0; cond->waiting = cond->signals = 0;
if (!cond->lock || !cond->wait_sem || !cond->wait_done) { if (!cond->lock || !cond->wait_sem || !cond->wait_done) {
SDL_DestroyCond(cond); SDL_DestroyCondition(cond);
cond = NULL; cond = NULL;
} }
} else { } else {
@ -60,7 +60,7 @@ SDL_CreateCond(void)
} }
/* Destroy a condition variable */ /* Destroy a condition variable */
void SDL_DestroyCond(SDL_cond *cond) void SDL_DestroyCondition(SDL_cond *cond)
{ {
if (cond != NULL) { if (cond != NULL) {
if (cond->wait_sem) { if (cond->wait_sem) {
@ -77,7 +77,7 @@ void SDL_DestroyCond(SDL_cond *cond)
} }
/* Restart one of the threads that are waiting on the condition variable */ /* Restart one of the threads that are waiting on the condition variable */
int SDL_CondSignal(SDL_cond *cond) int SDL_SignalCondition(SDL_cond *cond)
{ {
if (cond == NULL) { if (cond == NULL) {
return SDL_InvalidParamError("cond"); return SDL_InvalidParamError("cond");
@ -89,9 +89,9 @@ int SDL_CondSignal(SDL_cond *cond)
SDL_LockMutex(cond->lock); SDL_LockMutex(cond->lock);
if (cond->waiting > cond->signals) { if (cond->waiting > cond->signals) {
++cond->signals; ++cond->signals;
SDL_SemPost(cond->wait_sem); SDL_PostSemaphore(cond->wait_sem);
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
SDL_SemWait(cond->wait_done); SDL_WaitSemaphore(cond->wait_done);
} else { } else {
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
} }
@ -100,7 +100,7 @@ int SDL_CondSignal(SDL_cond *cond)
} }
/* Restart all threads that are waiting on the condition variable */ /* Restart all threads that are waiting on the condition variable */
int SDL_CondBroadcast(SDL_cond *cond) int SDL_BroadcastCondition(SDL_cond *cond)
{ {
if (cond == NULL) { if (cond == NULL) {
return SDL_InvalidParamError("cond"); return SDL_InvalidParamError("cond");
@ -116,14 +116,14 @@ int SDL_CondBroadcast(SDL_cond *cond)
num_waiting = (cond->waiting - cond->signals); num_waiting = (cond->waiting - cond->signals);
cond->signals = cond->waiting; cond->signals = cond->waiting;
for (i = 0; i < num_waiting; ++i) { for (i = 0; i < num_waiting; ++i) {
SDL_SemPost(cond->wait_sem); SDL_PostSemaphore(cond->wait_sem);
} }
/* Now all released threads are blocked here, waiting for us. /* Now all released threads are blocked here, waiting for us.
Collect them all (and win fabulous prizes!) :-) Collect them all (and win fabulous prizes!) :-)
*/ */
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
for (i = 0; i < num_waiting; ++i) { for (i = 0; i < num_waiting; ++i) {
SDL_SemWait(cond->wait_done); SDL_WaitSemaphore(cond->wait_done);
} }
} else { } else {
SDL_UnlockMutex(cond->lock); SDL_UnlockMutex(cond->lock);
@ -141,7 +141,7 @@ Typical use:
Thread A: Thread A:
SDL_LockMutex(lock); SDL_LockMutex(lock);
while ( ! condition ) { while ( ! condition ) {
SDL_CondWait(cond, lock); SDL_WaitCondition(cond, lock);
} }
SDL_UnlockMutex(lock); SDL_UnlockMutex(lock);
@ -150,10 +150,10 @@ Thread B:
... ...
condition = true; condition = true;
... ...
SDL_CondSignal(cond); SDL_SignalCondition(cond);
SDL_UnlockMutex(lock); SDL_UnlockMutex(lock);
*/ */
int SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS) int SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
{ {
int retval; int retval;
@ -173,7 +173,7 @@ int SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
SDL_UnlockMutex(mutex); SDL_UnlockMutex(mutex);
/* Wait for a signal */ /* Wait for a signal */
retval = SDL_SemWaitTimeoutNS(cond->wait_sem, timeoutNS); retval = SDL_WaitSemaphoreTimeoutNS(cond->wait_sem, timeoutNS);
/* Let the signaler know we have completed the wait, otherwise /* Let the signaler know we have completed the wait, otherwise
the signaler can race ahead and get the condition semaphore the signaler can race ahead and get the condition semaphore
@ -185,10 +185,10 @@ int SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
if (cond->signals > 0) { if (cond->signals > 0) {
/* If we timed out, we need to eat a condition signal */ /* If we timed out, we need to eat a condition signal */
if (retval > 0) { if (retval > 0) {
SDL_SemWait(cond->wait_sem); SDL_WaitSemaphore(cond->wait_sem);
} }
/* We always notify the signal thread that we are done */ /* We always notify the signal thread that we are done */
SDL_SemPost(cond->wait_done); SDL_PostSemaphore(cond->wait_done);
/* Signal handshake complete */ /* Signal handshake complete */
--cond->signals; --cond->signals;

View file

@ -74,7 +74,7 @@ void SDL_DestroySemaphore(SDL_sem *sem)
* If the timeout is 0 then just poll the semaphore; if it's SDL_MUTEX_MAXWAIT, pass * If the timeout is 0 then just poll the semaphore; if it's SDL_MUTEX_MAXWAIT, pass
* NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout * NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout
* is specified, convert it to microseconds. */ * is specified, convert it to microseconds. */
int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS) int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
{ {
SceUInt timeoutUS; SceUInt timeoutUS;
SceUInt *pTimeout; SceUInt *pTimeout;
@ -111,7 +111,7 @@ int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
} }
/* Returns the current count of the semaphore */ /* Returns the current count of the semaphore */
Uint32 SDL_SemValue(SDL_sem *sem) Uint32 SDL_GetSemaphoreValue(SDL_sem *sem)
{ {
SceKernelSemaInfo info; SceKernelSemaInfo info;
info.size = sizeof(info); info.size = sizeof(info);
@ -128,7 +128,7 @@ Uint32 SDL_SemValue(SDL_sem *sem)
return 0; return 0;
} }
int SDL_SemPost(SDL_sem *sem) int SDL_PostSemaphore(SDL_sem *sem)
{ {
int res; int res;

View file

@ -23,19 +23,19 @@
#include "../generic/SDL_syscond_c.h" #include "../generic/SDL_syscond_c.h"
#include "SDL_sysmutex_c.h" #include "SDL_sysmutex_c.h"
typedef SDL_cond *(*pfnSDL_CreateCond)(void); typedef SDL_cond *(*pfnSDL_CreateCondition)(void);
typedef void (*pfnSDL_DestroyCond)(SDL_cond *); typedef void (*pfnSDL_DestroyCondition)(SDL_cond *);
typedef int (*pfnSDL_CondSignal)(SDL_cond *); typedef int (*pfnSDL_SignalCondition)(SDL_cond *);
typedef int (*pfnSDL_CondBroadcast)(SDL_cond *); typedef int (*pfnSDL_BroadcastCondition)(SDL_cond *);
typedef int (*pfnSDL_CondWaitTimeoutNS)(SDL_cond *, SDL_mutex *, Sint64); typedef int (*pfnSDL_WaitConditionTimeoutNS)(SDL_cond *, SDL_mutex *, Sint64);
typedef struct SDL_cond_impl_t typedef struct SDL_cond_impl_t
{ {
pfnSDL_CreateCond Create; pfnSDL_CreateCondition Create;
pfnSDL_DestroyCond Destroy; pfnSDL_DestroyCondition Destroy;
pfnSDL_CondSignal Signal; pfnSDL_SignalCondition Signal;
pfnSDL_CondBroadcast Broadcast; pfnSDL_BroadcastCondition Broadcast;
pfnSDL_CondWaitTimeoutNS WaitTimeoutNS; pfnSDL_WaitConditionTimeoutNS WaitTimeoutNS;
} SDL_cond_impl_t; } SDL_cond_impl_t;
/* Implementation will be chosen at runtime based on available Kernel features */ /* Implementation will be chosen at runtime based on available Kernel features */
@ -78,7 +78,7 @@ typedef struct SDL_cond_cv
CONDITION_VARIABLE cond; CONDITION_VARIABLE cond;
} SDL_cond_cv; } SDL_cond_cv;
static SDL_cond *SDL_CreateCond_cv(void) static SDL_cond *SDL_CreateCondition_cv(void)
{ {
SDL_cond_cv *cond; SDL_cond_cv *cond;
@ -91,7 +91,7 @@ static SDL_cond *SDL_CreateCond_cv(void)
return (SDL_cond *)cond; return (SDL_cond *)cond;
} }
static void SDL_DestroyCond_cv(SDL_cond *cond) static void SDL_DestroyCondition_cv(SDL_cond *cond)
{ {
if (cond != NULL) { if (cond != NULL) {
/* There are no kernel allocated resources */ /* There are no kernel allocated resources */
@ -99,7 +99,7 @@ static void SDL_DestroyCond_cv(SDL_cond *cond)
} }
} }
static int SDL_CondSignal_cv(SDL_cond *_cond) static int SDL_SignalCondition_cv(SDL_cond *_cond)
{ {
SDL_cond_cv *cond = (SDL_cond_cv *)_cond; SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
if (cond == NULL) { if (cond == NULL) {
@ -111,7 +111,7 @@ static int SDL_CondSignal_cv(SDL_cond *_cond)
return 0; return 0;
} }
static int SDL_CondBroadcast_cv(SDL_cond *_cond) static int SDL_BroadcastCondition_cv(SDL_cond *_cond)
{ {
SDL_cond_cv *cond = (SDL_cond_cv *)_cond; SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
if (cond == NULL) { if (cond == NULL) {
@ -123,7 +123,7 @@ static int SDL_CondBroadcast_cv(SDL_cond *_cond)
return 0; return 0;
} }
static int SDL_CondWaitTimeoutNS_cv(SDL_cond *_cond, SDL_mutex *_mutex, Sint64 timeoutNS) static int SDL_WaitConditionTimeoutNS_cv(SDL_cond *_cond, SDL_mutex *_mutex, Sint64 timeoutNS)
{ {
SDL_cond_cv *cond = (SDL_cond_cv *)_cond; SDL_cond_cv *cond = (SDL_cond_cv *)_cond;
DWORD timeout; DWORD timeout;
@ -187,27 +187,27 @@ static int SDL_CondWaitTimeoutNS_cv(SDL_cond *_cond, SDL_mutex *_mutex, Sint64 t
} }
static const SDL_cond_impl_t SDL_cond_impl_cv = { static const SDL_cond_impl_t SDL_cond_impl_cv = {
&SDL_CreateCond_cv, &SDL_CreateCondition_cv,
&SDL_DestroyCond_cv, &SDL_DestroyCondition_cv,
&SDL_CondSignal_cv, &SDL_SignalCondition_cv,
&SDL_CondBroadcast_cv, &SDL_BroadcastCondition_cv,
&SDL_CondWaitTimeoutNS_cv, &SDL_WaitConditionTimeoutNS_cv,
}; };
#ifndef __WINRT__ #ifndef __WINRT__
/* Generic Condition Variable implementation using SDL_mutex and SDL_sem */ /* Generic Condition Variable implementation using SDL_mutex and SDL_sem */
static const SDL_cond_impl_t SDL_cond_impl_generic = { static const SDL_cond_impl_t SDL_cond_impl_generic = {
&SDL_CreateCond_generic, &SDL_CreateCondition_generic,
&SDL_DestroyCond_generic, &SDL_DestroyCondition_generic,
&SDL_CondSignal_generic, &SDL_SignalCondition_generic,
&SDL_CondBroadcast_generic, &SDL_BroadcastCondition_generic,
&SDL_CondWaitTimeoutNS_generic, &SDL_WaitConditionTimeoutNS_generic,
}; };
#endif #endif
SDL_cond * SDL_cond *
SDL_CreateCond(void) SDL_CreateCondition(void)
{ {
if (SDL_cond_impl_active.Create == NULL) { if (SDL_cond_impl_active.Create == NULL) {
const SDL_cond_impl_t *impl = NULL; const SDL_cond_impl_t *impl = NULL;
@ -249,22 +249,22 @@ SDL_CreateCond(void)
return SDL_cond_impl_active.Create(); return SDL_cond_impl_active.Create();
} }
void SDL_DestroyCond(SDL_cond *cond) void SDL_DestroyCondition(SDL_cond *cond)
{ {
SDL_cond_impl_active.Destroy(cond); SDL_cond_impl_active.Destroy(cond);
} }
int SDL_CondSignal(SDL_cond *cond) int SDL_SignalCondition(SDL_cond *cond)
{ {
return SDL_cond_impl_active.Signal(cond); return SDL_cond_impl_active.Signal(cond);
} }
int SDL_CondBroadcast(SDL_cond *cond) int SDL_BroadcastCondition(SDL_cond *cond)
{ {
return SDL_cond_impl_active.Broadcast(cond); return SDL_cond_impl_active.Broadcast(cond);
} }
int SDL_CondWaitTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS) int SDL_WaitConditionTimeoutNS(SDL_cond *cond, SDL_mutex *mutex, Sint64 timeoutNS)
{ {
return SDL_cond_impl_active.WaitTimeoutNS(cond, mutex, timeoutNS); return SDL_cond_impl_active.WaitTimeoutNS(cond, mutex, timeoutNS);
} }

View file

@ -37,17 +37,17 @@
typedef SDL_sem *(*pfnSDL_CreateSemaphore)(Uint32); typedef SDL_sem *(*pfnSDL_CreateSemaphore)(Uint32);
typedef void (*pfnSDL_DestroySemaphore)(SDL_sem *); typedef void (*pfnSDL_DestroySemaphore)(SDL_sem *);
typedef int (*pfnSDL_SemWaitTimeoutNS)(SDL_sem *, Sint64); typedef int (*pfnSDL_WaitSemaphoreTimeoutNS)(SDL_sem *, Sint64);
typedef Uint32 (*pfnSDL_SemValue)(SDL_sem *); typedef Uint32 (*pfnSDL_GetSemaphoreValue)(SDL_sem *);
typedef int (*pfnSDL_SemPost)(SDL_sem *); typedef int (*pfnSDL_PostSemaphore)(SDL_sem *);
typedef struct SDL_semaphore_impl_t typedef struct SDL_semaphore_impl_t
{ {
pfnSDL_CreateSemaphore Create; pfnSDL_CreateSemaphore Create;
pfnSDL_DestroySemaphore Destroy; pfnSDL_DestroySemaphore Destroy;
pfnSDL_SemWaitTimeoutNS WaitTimeoutNS; pfnSDL_WaitSemaphoreTimeoutNS WaitTimeoutNS;
pfnSDL_SemValue Value; pfnSDL_GetSemaphoreValue Value;
pfnSDL_SemPost Post; pfnSDL_PostSemaphore Post;
} SDL_sem_impl_t; } SDL_sem_impl_t;
/* Implementation will be chosen at runtime based on available Kernel features */ /* Implementation will be chosen at runtime based on available Kernel features */
@ -98,7 +98,7 @@ static void SDL_DestroySemaphore_atom(SDL_sem *sem)
} }
} }
static int SDL_SemWaitTimeoutNS_atom(SDL_sem *_sem, Sint64 timeoutNS) static int SDL_WaitSemaphoreTimeoutNS_atom(SDL_sem *_sem, Sint64 timeoutNS)
{ {
SDL_sem_atom *sem = (SDL_sem_atom *)_sem; SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
LONG count; LONG count;
@ -172,7 +172,7 @@ static int SDL_SemWaitTimeoutNS_atom(SDL_sem *_sem, Sint64 timeoutNS)
} }
} }
static Uint32 SDL_SemValue_atom(SDL_sem *_sem) static Uint32 SDL_GetSemaphoreValue_atom(SDL_sem *_sem)
{ {
SDL_sem_atom *sem = (SDL_sem_atom *)_sem; SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
@ -184,7 +184,7 @@ static Uint32 SDL_SemValue_atom(SDL_sem *_sem)
return (Uint32)sem->count; return (Uint32)sem->count;
} }
static int SDL_SemPost_atom(SDL_sem *_sem) static int SDL_PostSemaphore_atom(SDL_sem *_sem)
{ {
SDL_sem_atom *sem = (SDL_sem_atom *)_sem; SDL_sem_atom *sem = (SDL_sem_atom *)_sem;
@ -201,9 +201,9 @@ static int SDL_SemPost_atom(SDL_sem *_sem)
static const SDL_sem_impl_t SDL_sem_impl_atom = { static const SDL_sem_impl_t SDL_sem_impl_atom = {
&SDL_CreateSemaphore_atom, &SDL_CreateSemaphore_atom,
&SDL_DestroySemaphore_atom, &SDL_DestroySemaphore_atom,
&SDL_SemWaitTimeoutNS_atom, &SDL_WaitSemaphoreTimeoutNS_atom,
&SDL_SemValue_atom, &SDL_GetSemaphoreValue_atom,
&SDL_SemPost_atom, &SDL_PostSemaphore_atom,
}; };
#endif /* !SDL_WINAPI_FAMILY_PHONE */ #endif /* !SDL_WINAPI_FAMILY_PHONE */
@ -256,7 +256,7 @@ static void SDL_DestroySemaphore_kern(SDL_sem *_sem)
} }
} }
static int SDL_SemWaitTimeoutNS_kern(SDL_sem *_sem, Sint64 timeoutNS) static int SDL_WaitSemaphoreTimeoutNS_kern(SDL_sem *_sem, Sint64 timeoutNS)
{ {
SDL_sem_kern *sem = (SDL_sem_kern *)_sem; SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
int retval; int retval;
@ -287,7 +287,7 @@ static int SDL_SemWaitTimeoutNS_kern(SDL_sem *_sem, Sint64 timeoutNS)
} }
/* Returns the current count of the semaphore */ /* Returns the current count of the semaphore */
static Uint32 SDL_SemValue_kern(SDL_sem *_sem) static Uint32 SDL_GetSemaphoreValue_kern(SDL_sem *_sem)
{ {
SDL_sem_kern *sem = (SDL_sem_kern *)_sem; SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (sem == NULL) { if (sem == NULL) {
@ -297,7 +297,7 @@ static Uint32 SDL_SemValue_kern(SDL_sem *_sem)
return (Uint32)sem->count; return (Uint32)sem->count;
} }
static int SDL_SemPost_kern(SDL_sem *_sem) static int SDL_PostSemaphore_kern(SDL_sem *_sem)
{ {
SDL_sem_kern *sem = (SDL_sem_kern *)_sem; SDL_sem_kern *sem = (SDL_sem_kern *)_sem;
if (sem == NULL) { if (sem == NULL) {
@ -319,9 +319,9 @@ static int SDL_SemPost_kern(SDL_sem *_sem)
static const SDL_sem_impl_t SDL_sem_impl_kern = { static const SDL_sem_impl_t SDL_sem_impl_kern = {
&SDL_CreateSemaphore_kern, &SDL_CreateSemaphore_kern,
&SDL_DestroySemaphore_kern, &SDL_DestroySemaphore_kern,
&SDL_SemWaitTimeoutNS_kern, &SDL_WaitSemaphoreTimeoutNS_kern,
&SDL_SemValue_kern, &SDL_GetSemaphoreValue_kern,
&SDL_SemPost_kern, &SDL_PostSemaphore_kern,
}; };
/** /**
@ -372,18 +372,18 @@ void SDL_DestroySemaphore(SDL_sem *sem)
SDL_sem_impl_active.Destroy(sem); SDL_sem_impl_active.Destroy(sem);
} }
int SDL_SemWaitTimeoutNS(SDL_sem *sem, Sint64 timeoutNS) int SDL_WaitSemaphoreTimeoutNS(SDL_sem *sem, Sint64 timeoutNS)
{ {
return SDL_sem_impl_active.WaitTimeoutNS(sem, timeoutNS); return SDL_sem_impl_active.WaitTimeoutNS(sem, timeoutNS);
} }
Uint32 Uint32
SDL_SemValue(SDL_sem *sem) SDL_GetSemaphoreValue(SDL_sem *sem)
{ {
return SDL_sem_impl_active.Value(sem); return SDL_sem_impl_active.Value(sem);
} }
int SDL_SemPost(SDL_sem *sem) int SDL_PostSemaphore(SDL_sem *sem)
{ {
return SDL_sem_impl_active.Post(sem); return SDL_sem_impl_active.Post(sem);
} }

View file

@ -197,7 +197,7 @@ static int SDLCALL SDL_TimerThread(void *_data)
That's okay, it just means we run through the loop a few That's okay, it just means we run through the loop a few
extra times. extra times.
*/ */
SDL_SemWaitTimeoutNS(data->sem, delay); SDL_WaitSemaphoreTimeoutNS(data->sem, delay);
} }
return 0; return 0;
} }
@ -242,7 +242,7 @@ void SDL_QuitTimers(void)
if (SDL_AtomicCAS(&data->active, 1, 0)) { /* active? Move to inactive. */ if (SDL_AtomicCAS(&data->active, 1, 0)) { /* active? Move to inactive. */
/* Shutdown the timer thread */ /* Shutdown the timer thread */
if (data->thread) { if (data->thread) {
SDL_SemPost(data->sem); SDL_PostSemaphore(data->sem);
SDL_WaitThread(data->thread, NULL); SDL_WaitThread(data->thread, NULL);
data->thread = NULL; data->thread = NULL;
} }
@ -329,7 +329,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para
SDL_AtomicUnlock(&data->lock); SDL_AtomicUnlock(&data->lock);
/* Wake up the timer thread if necessary */ /* Wake up the timer thread if necessary */
SDL_SemPost(data->sem); SDL_PostSemaphore(data->sem);
return entry->timerID; return entry->timerID;
} }

View file

@ -138,7 +138,7 @@ void Android_PumpEvents_Blocking(_THIS)
openslES_PauseDevices(); openslES_PauseDevices();
aaudio_PauseDevices(); aaudio_PauseDevices();
if (SDL_SemWait(Android_ResumeSem) == 0) { if (SDL_WaitSemaphore(Android_ResumeSem) == 0) {
videodata->isPaused = 0; videodata->isPaused = 0;
@ -166,7 +166,7 @@ void Android_PumpEvents_Blocking(_THIS)
} }
} }
} else { } else {
if (videodata->isPausing || SDL_SemTryWait(Android_PauseSem) == 0) { if (videodata->isPausing || SDL_TryWaitSemaphore(Android_PauseSem) == 0) {
/* Android_PauseSem was signaled */ /* Android_PauseSem was signaled */
if (videodata->isPausing == 0) { if (videodata->isPausing == 0) {
@ -178,7 +178,7 @@ void Android_PumpEvents_Blocking(_THIS)
/* We've been signaled to pause (potentially several times), but before we block ourselves, /* We've been signaled to pause (potentially several times), but before we block ourselves,
* we need to make sure that the very last event (of the first pause sequence, if several) * we need to make sure that the very last event (of the first pause sequence, if several)
* has reached the app */ * has reached the app */
if (SDL_NumberOfEvents(SDL_EVENT_DID_ENTER_BACKGROUND) > SDL_SemValue(Android_PauseSem)) { if (SDL_NumberOfEvents(SDL_EVENT_DID_ENTER_BACKGROUND) > SDL_GetSemaphoreValue(Android_PauseSem)) {
videodata->isPausing = 1; videodata->isPausing = 1;
} else { } else {
videodata->isPausing = 0; videodata->isPausing = 0;
@ -220,7 +220,7 @@ void Android_PumpEvents_NonBlocking(_THIS)
backup_context = 0; backup_context = 0;
} }
if (SDL_SemTryWait(Android_ResumeSem) == 0) { if (SDL_TryWaitSemaphore(Android_ResumeSem) == 0) {
videodata->isPaused = 0; videodata->isPaused = 0;
@ -250,7 +250,7 @@ void Android_PumpEvents_NonBlocking(_THIS)
} }
} }
} else { } else {
if (videodata->isPausing || SDL_SemTryWait(Android_PauseSem) == 0) { if (videodata->isPausing || SDL_TryWaitSemaphore(Android_PauseSem) == 0) {
/* Android_PauseSem was signaled */ /* Android_PauseSem was signaled */
if (videodata->isPausing == 0) { if (videodata->isPausing == 0) {
@ -262,7 +262,7 @@ void Android_PumpEvents_NonBlocking(_THIS)
/* We've been signaled to pause (potentially several times), but before we block ourselves, /* We've been signaled to pause (potentially several times), but before we block ourselves,
* we need to make sure that the very last event (of the first pause sequence, if several) * we need to make sure that the very last event (of the first pause sequence, if several)
* has reached the app */ * has reached the app */
if (SDL_NumberOfEvents(SDL_EVENT_DID_ENTER_BACKGROUND) > SDL_SemValue(Android_PauseSem)) { if (SDL_NumberOfEvents(SDL_EVENT_DID_ENTER_BACKGROUND) > SDL_GetSemaphoreValue(Android_PauseSem)) {
videodata->isPausing = 1; videodata->isPausing = 1;
} else { } else {
videodata->isPausing = 0; videodata->isPausing = 0;

View file

@ -68,7 +68,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
if (setting != 0) { /* nothing to do if vsync is disabled, don't even lock */ if (setting != 0) { /* nothing to do if vsync is disabled, don't even lock */
SDL_LockMutex(nscontext->swapIntervalMutex); SDL_LockMutex(nscontext->swapIntervalMutex);
SDL_AtomicAdd(&nscontext->swapIntervalsPassed, 1); SDL_AtomicAdd(&nscontext->swapIntervalsPassed, 1);
SDL_CondSignal(nscontext->swapIntervalCond); SDL_SignalCondition(nscontext->swapIntervalCond);
SDL_UnlockMutex(nscontext->swapIntervalMutex); SDL_UnlockMutex(nscontext->swapIntervalMutex);
} }
@ -87,7 +87,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
self->window = NULL; self->window = NULL;
SDL_AtomicSet(&self->swapIntervalSetting, 0); SDL_AtomicSet(&self->swapIntervalSetting, 0);
SDL_AtomicSet(&self->swapIntervalsPassed, 0); SDL_AtomicSet(&self->swapIntervalsPassed, 0);
self->swapIntervalCond = SDL_CreateCond(); self->swapIntervalCond = SDL_CreateCondition();
self->swapIntervalMutex = SDL_CreateMutex(); self->swapIntervalMutex = SDL_CreateMutex();
if (!self->swapIntervalCond || !self->swapIntervalMutex) { if (!self->swapIntervalCond || !self->swapIntervalMutex) {
return nil; return nil;
@ -214,7 +214,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
self->displayLink = nil; self->displayLink = nil;
} }
if (self->swapIntervalCond) { if (self->swapIntervalCond) {
SDL_DestroyCond(self->swapIntervalCond); SDL_DestroyCondition(self->swapIntervalCond);
self->swapIntervalCond = NULL; self->swapIntervalCond = NULL;
} }
if (self->swapIntervalMutex) { if (self->swapIntervalMutex) {
@ -498,14 +498,14 @@ int Cocoa_GL_SwapWindow(_THIS, SDL_Window *window)
} else if (setting < 0) { /* late swap tearing */ } else if (setting < 0) { /* late swap tearing */
SDL_LockMutex(nscontext->swapIntervalMutex); SDL_LockMutex(nscontext->swapIntervalMutex);
while (SDL_AtomicGet(&nscontext->swapIntervalsPassed) == 0) { while (SDL_AtomicGet(&nscontext->swapIntervalsPassed) == 0) {
SDL_CondWait(nscontext->swapIntervalCond, nscontext->swapIntervalMutex); SDL_WaitCondition(nscontext->swapIntervalCond, nscontext->swapIntervalMutex);
} }
SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0); SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0);
SDL_UnlockMutex(nscontext->swapIntervalMutex); SDL_UnlockMutex(nscontext->swapIntervalMutex);
} else { } else {
SDL_LockMutex(nscontext->swapIntervalMutex); SDL_LockMutex(nscontext->swapIntervalMutex);
do { /* always wait here so we know we just hit a swap interval. */ do { /* always wait here so we know we just hit a swap interval. */
SDL_CondWait(nscontext->swapIntervalCond, nscontext->swapIntervalMutex); SDL_WaitCondition(nscontext->swapIntervalCond, nscontext->swapIntervalMutex);
} while ((SDL_AtomicGet(&nscontext->swapIntervalsPassed) % setting) != 0); } while ((SDL_AtomicGet(&nscontext->swapIntervalsPassed) % setting) != 0);
SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0); SDL_AtomicSet(&nscontext->swapIntervalsPassed, 0);
SDL_UnlockMutex(nscontext->swapIntervalMutex); SDL_UnlockMutex(nscontext->swapIntervalMutex);

View file

@ -64,9 +64,9 @@ static struct
int EventUpdate(void *data) int EventUpdate(void *data)
{ {
while (running) { while (running) {
SDL_SemWait(event_sem); SDL_WaitSemaphore(event_sem);
sceHprmPeekCurrentKey((u32 *)&hprm); sceHprmPeekCurrentKey((u32 *)&hprm);
SDL_SemPost(event_sem); SDL_PostSemaphore(event_sem);
/* Delay 1/60th of a second */ /* Delay 1/60th of a second */
sceKernelDelayThread(1000000 / 60); sceKernelDelayThread(1000000 / 60);
} }
@ -80,9 +80,9 @@ void PSP_PumpEvents(_THIS)
enum PspHprmKeys changed; enum PspHprmKeys changed;
static enum PspHprmKeys old_keys = 0; static enum PspHprmKeys old_keys = 0;
SDL_SemWait(event_sem); SDL_WaitSemaphore(event_sem);
keys = hprm; keys = hprm;
SDL_SemPost(event_sem); SDL_PostSemaphore(event_sem);
/* HPRM Keyboard */ /* HPRM Keyboard */
changed = old_keys ^ keys; changed = old_keys ^ keys;

View file

@ -52,7 +52,7 @@ int RPI_GLES_SwapWindow(_THIS, SDL_Window *window)
* Run your SDL program with "SDL_RPI_DOUBLE_BUFFER=1 <program_name>" to enable this. */ * Run your SDL program with "SDL_RPI_DOUBLE_BUFFER=1 <program_name>" to enable this. */
if (wdata->double_buffer) { if (wdata->double_buffer) {
SDL_LockMutex(wdata->vsync_cond_mutex); SDL_LockMutex(wdata->vsync_cond_mutex);
SDL_CondWait(wdata->vsync_cond, wdata->vsync_cond_mutex); SDL_WaitCondition(wdata->vsync_cond, wdata->vsync_cond_mutex);
SDL_UnlockMutex(wdata->vsync_cond_mutex); SDL_UnlockMutex(wdata->vsync_cond_mutex);
} }

View file

@ -215,7 +215,7 @@ static void RPI_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data)
SDL_WindowData *wdata = (SDL_WindowData *)data; SDL_WindowData *wdata = (SDL_WindowData *)data;
SDL_LockMutex(wdata->vsync_cond_mutex); SDL_LockMutex(wdata->vsync_cond_mutex);
SDL_CondSignal(wdata->vsync_cond); SDL_SignalCondition(wdata->vsync_cond);
SDL_UnlockMutex(wdata->vsync_cond_mutex); SDL_UnlockMutex(wdata->vsync_cond_mutex);
} }
@ -296,7 +296,7 @@ int RPI_CreateWindow(_THIS, SDL_Window *window)
/* Start generating vsync callbacks if necesary */ /* Start generating vsync callbacks if necesary */
wdata->double_buffer = SDL_FALSE; wdata->double_buffer = SDL_FALSE;
if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) { if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) {
wdata->vsync_cond = SDL_CreateCond(); wdata->vsync_cond = SDL_CreateCondition();
wdata->vsync_cond_mutex = SDL_CreateMutex(); wdata->vsync_cond_mutex = SDL_CreateMutex();
wdata->double_buffer = SDL_TRUE; wdata->double_buffer = SDL_TRUE;
vc_dispmanx_vsync_callback(displaydata->dispman_display, RPI_vsync_callback, (void *)wdata); vc_dispmanx_vsync_callback(displaydata->dispman_display, RPI_vsync_callback, (void *)wdata);
@ -322,12 +322,12 @@ void RPI_DestroyWindow(_THIS, SDL_Window *window)
if (data->double_buffer) { if (data->double_buffer) {
/* Wait for vsync, and then stop vsync callbacks and destroy related stuff, if needed */ /* Wait for vsync, and then stop vsync callbacks and destroy related stuff, if needed */
SDL_LockMutex(data->vsync_cond_mutex); SDL_LockMutex(data->vsync_cond_mutex);
SDL_CondWait(data->vsync_cond, data->vsync_cond_mutex); SDL_WaitCondition(data->vsync_cond, data->vsync_cond_mutex);
SDL_UnlockMutex(data->vsync_cond_mutex); SDL_UnlockMutex(data->vsync_cond_mutex);
vc_dispmanx_vsync_callback(displaydata->dispman_display, NULL, NULL); vc_dispmanx_vsync_callback(displaydata->dispman_display, NULL, NULL);
SDL_DestroyCond(data->vsync_cond); SDL_DestroyCondition(data->vsync_cond);
SDL_DestroyMutex(data->vsync_cond_mutex); SDL_DestroyMutex(data->vsync_cond_mutex);
} }

View file

@ -78,11 +78,11 @@ static void WINRT_YieldXAMLThread()
_threadState = ThreadState_Yielding; _threadState = ThreadState_Yielding;
SDL_UnlockMutex(_mutex); SDL_UnlockMutex(_mutex);
SDL_CondSignal(_cond); SDL_SignalCondition(_cond);
SDL_LockMutex(_mutex); SDL_LockMutex(_mutex);
while (_threadState != ThreadState_Running) { while (_threadState != ThreadState_Running) {
SDL_CondWait(_cond, _mutex); SDL_WaitCondition(_cond, _mutex);
} }
SDL_UnlockMutex(_mutex); SDL_UnlockMutex(_mutex);
} }
@ -101,7 +101,7 @@ void WINRT_CycleXAMLThread(void)
switch (_threadState) { switch (_threadState) {
case ThreadState_NotLaunched: case ThreadState_NotLaunched:
{ {
_cond = SDL_CreateCond(); _cond = SDL_CreateCondition();
_mutex = SDL_CreateMutex(); _mutex = SDL_CreateMutex();
_threadState = ThreadState_Running; _threadState = ThreadState_Running;
@ -109,7 +109,7 @@ void WINRT_CycleXAMLThread(void)
SDL_LockMutex(_mutex); SDL_LockMutex(_mutex);
while (_threadState != ThreadState_Yielding) { while (_threadState != ThreadState_Yielding) {
SDL_CondWait(_cond, _mutex); SDL_WaitCondition(_cond, _mutex);
} }
SDL_UnlockMutex(_mutex); SDL_UnlockMutex(_mutex);
@ -129,11 +129,11 @@ void WINRT_CycleXAMLThread(void)
_threadState = ThreadState_Running; _threadState = ThreadState_Running;
SDL_UnlockMutex(_mutex); SDL_UnlockMutex(_mutex);
SDL_CondSignal(_cond); SDL_SignalCondition(_cond);
SDL_LockMutex(_mutex); SDL_LockMutex(_mutex);
while (_threadState != ThreadState_Yielding) { while (_threadState != ThreadState_Yielding) {
SDL_CondWait(_cond, _mutex); SDL_WaitCondition(_cond, _mutex);
} }
SDL_UnlockMutex(_mutex); SDL_UnlockMutex(_mutex);
} }

View file

@ -121,7 +121,7 @@ static int SDLCALL adder(void *junk)
bad -= CountInc; bad -= CountInc;
} }
SDL_AtomicAdd(&threadsRunning, -1); SDL_AtomicAdd(&threadsRunning, -1);
SDL_SemPost(threadDone); SDL_PostSemaphore(threadDone);
return 0; return 0;
} }
@ -141,7 +141,7 @@ static void runAdder(void)
} }
while (SDL_AtomicGet(&threadsRunning) > 0) { while (SDL_AtomicGet(&threadsRunning) > 0) {
SDL_SemWait(threadDone); SDL_WaitSemaphore(threadDone);
} }
SDL_DestroySemaphore(threadDone); SDL_DestroySemaphore(threadDone);

View file

@ -52,13 +52,13 @@ ThreadFuncRealWorld(void *data)
{ {
Thread_State *state = (Thread_State *)data; Thread_State *state = (Thread_State *)data;
while (alive) { while (alive) {
SDL_SemWait(sem); SDL_WaitSemaphore(sem);
SDL_Log("Thread number %d has got the semaphore (value = %" SDL_PRIu32 ")!\n", SDL_Log("Thread number %d has got the semaphore (value = %" SDL_PRIu32 ")!\n",
state->number, SDL_SemValue(sem)); state->number, SDL_GetSemaphoreValue(sem));
SDL_Delay(200); SDL_Delay(200);
SDL_SemPost(sem); SDL_PostSemaphore(sem);
SDL_Log("Thread number %d has released the semaphore (value = %" SDL_PRIu32 ")!\n", SDL_Log("Thread number %d has released the semaphore (value = %" SDL_PRIu32 ")!\n",
state->number, SDL_SemValue(sem)); state->number, SDL_GetSemaphoreValue(sem));
++state->loop_count; ++state->loop_count;
SDL_Delay(1); /* For the scheduler */ SDL_Delay(1); /* For the scheduler */
} }
@ -114,7 +114,7 @@ TestWaitTimeout(void)
SDL_Log("Waiting 2 seconds on semaphore\n"); SDL_Log("Waiting 2 seconds on semaphore\n");
start_ticks = SDL_GetTicks(); start_ticks = SDL_GetTicks();
retval = SDL_SemWaitTimeout(sem, 2000); retval = SDL_WaitSemaphoreTimeout(sem, 2000);
end_ticks = SDL_GetTicks(); end_ticks = SDL_GetTicks();
duration = end_ticks - start_ticks; duration = end_ticks - start_ticks;
@ -125,7 +125,7 @@ TestWaitTimeout(void)
/* Check to make sure the return value indicates timed out */ /* Check to make sure the return value indicates timed out */
if (retval != SDL_MUTEX_TIMEDOUT) { if (retval != SDL_MUTEX_TIMEDOUT) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n\n", retval, SDL_MUTEX_TIMEDOUT); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_WaitSemaphoreTimeout returned: %d; expected: %d\n\n", retval, SDL_MUTEX_TIMEDOUT);
} }
SDL_DestroySemaphore(sem); SDL_DestroySemaphore(sem);
@ -145,10 +145,10 @@ TestOverheadUncontended(void)
start_ticks = SDL_GetTicks(); start_ticks = SDL_GetTicks();
for (i = 0; i < NUM_OVERHEAD_OPS_MULT; i++) { for (i = 0; i < NUM_OVERHEAD_OPS_MULT; i++) {
for (j = 0; j < NUM_OVERHEAD_OPS; j++) { for (j = 0; j < NUM_OVERHEAD_OPS; j++) {
SDL_SemPost(sem); SDL_PostSemaphore(sem);
} }
for (j = 0; j < NUM_OVERHEAD_OPS; j++) { for (j = 0; j < NUM_OVERHEAD_OPS; j++) {
SDL_SemWait(sem); SDL_WaitSemaphore(sem);
} }
} }
end_ticks = SDL_GetTicks(); end_ticks = SDL_GetTicks();
@ -166,7 +166,7 @@ ThreadFuncOverheadContended(void *data)
if (state->flag) { if (state->flag) {
while (alive) { while (alive) {
if (SDL_SemTryWait(sem) == SDL_MUTEX_TIMEDOUT) { if (SDL_TryWaitSemaphore(sem) == SDL_MUTEX_TIMEDOUT) {
++state->content_count; ++state->content_count;
} }
++state->loop_count; ++state->loop_count;
@ -174,7 +174,7 @@ ThreadFuncOverheadContended(void *data)
} else { } else {
while (alive) { while (alive) {
/* Timeout needed to allow check on alive flag */ /* Timeout needed to allow check on alive flag */
if (SDL_SemWaitTimeout(sem, 50) == SDL_MUTEX_TIMEDOUT) { if (SDL_WaitSemaphoreTimeout(sem, 50) == SDL_MUTEX_TIMEDOUT) {
++state->content_count; ++state->content_count;
} }
++state->loop_count; ++state->loop_count;
@ -211,10 +211,10 @@ TestOverheadContended(SDL_bool try_wait)
start_ticks = SDL_GetTicks(); start_ticks = SDL_GetTicks();
for (i = 0; i < NUM_OVERHEAD_OPS_MULT; i++) { for (i = 0; i < NUM_OVERHEAD_OPS_MULT; i++) {
for (j = 0; j < NUM_OVERHEAD_OPS; j++) { for (j = 0; j < NUM_OVERHEAD_OPS; j++) {
SDL_SemPost(sem); SDL_PostSemaphore(sem);
} }
/* Make sure threads consumed everything */ /* Make sure threads consumed everything */
while (SDL_SemValue(sem)) { while (SDL_GetSemaphoreValue(sem)) {
/* Friendlier with cooperative threading models */ /* Friendlier with cooperative threading models */
SDL_DelayNS(1); SDL_DelayNS(1);
} }