From a7c019201799af0026b5768e9020753edf9cb14b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 24 Jul 2024 12:39:30 -0700 Subject: [PATCH] Renamed SDL_PostSemaphore() to SDL_SignalSemphore() --- build-scripts/SDL_migration.cocci | 2 +- docs/README-migration.md | 2 +- include/SDL3/SDL_mutex.h | 10 +++++----- include/SDL3/SDL_oldnames.h | 4 ++-- src/audio/aaudio/SDL_aaudio.c | 4 ++-- src/audio/coreaudio/SDL_coreaudio.m | 4 ++-- src/audio/openslES/SDL_openslES.c | 6 +++--- src/audio/pulseaudio/SDL_pulseaudio.c | 2 +- src/audio/wasapi/SDL_wasapi.c | 6 +++--- src/audio/wasapi/SDL_wasapi_winrt.cpp | 4 ++-- src/core/android/SDL_android.c | 6 +++--- src/dynapi/SDL_dynapi.sym | 6 +++--- src/dynapi/SDL_dynapi_overrides.h | 6 +++--- src/dynapi/SDL_dynapi_procs.h | 6 +++--- src/joystick/hidapi/SDL_hidapi_rumble.c | 4 ++-- src/sensor/android/SDL_androidsensor.c | 2 +- src/thread/generic/SDL_syscond.c | 6 +++--- src/thread/generic/SDL_sysmutex.c | 2 +- src/thread/generic/SDL_syssem.c | 4 ++-- src/thread/n3ds/SDL_syssem.c | 2 +- src/thread/ngage/SDL_syssem.cpp | 2 +- src/thread/ps2/SDL_syssem.c | 2 +- src/thread/psp/SDL_syssem.c | 2 +- src/thread/pthread/SDL_syssem.c | 2 +- src/thread/vita/SDL_syssem.c | 2 +- src/thread/windows/SDL_syssem.c | 14 +++++++------- src/timer/SDL_timer.c | 4 ++-- src/video/psp/SDL_pspevents.c | 4 ++-- test/testatomic.c | 2 +- test/testgles2.c | 4 ++-- test/testsem.c | 6 +++--- 31 files changed, 66 insertions(+), 66 deletions(-) diff --git a/build-scripts/SDL_migration.cocci b/build-scripts/SDL_migration.cocci index dd2fee730..1ad2294cf 100644 --- a/build-scripts/SDL_migration.cocci +++ b/build-scripts/SDL_migration.cocci @@ -2511,7 +2511,7 @@ typedef SDL_atomic_t, SDL_AtomicInt; @@ @@ - SDL_SemPost -+ SDL_PostSemaphore ++ SDL_SignalSemaphore (...) @@ @@ diff --git a/docs/README-migration.md b/docs/README-migration.md index caf5cab33..53bc9ef38 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -1110,7 +1110,7 @@ The following functions have been renamed: * SDL_CondWaitTimeout() => SDL_WaitConditionTimeout() * SDL_CreateCond() => SDL_CreateCondition() * SDL_DestroyCond() => SDL_DestroyCondition() -* SDL_SemPost() => SDL_PostSemaphore() +* SDL_SemPost() => SDL_SignalSemaphore() * SDL_SemTryWait() => SDL_TryWaitSemaphore() * SDL_SemValue() => SDL_GetSemaphoreValue() * SDL_SemWait() => SDL_WaitSemaphore() diff --git a/include/SDL3/SDL_mutex.h b/include/SDL3/SDL_mutex.h index aed836dc4..eea003092 100644 --- a/include/SDL3/SDL_mutex.h +++ b/include/SDL3/SDL_mutex.h @@ -544,7 +544,7 @@ typedef struct SDL_Semaphore SDL_Semaphore; * \since This function is available since SDL 3.0.0. * * \sa SDL_DestroySemaphore - * \sa SDL_PostSemaphore + * \sa SDL_SignalSemaphore * \sa SDL_TryWaitSemaphore * \sa SDL_GetSemaphoreValue * \sa SDL_WaitSemaphore @@ -583,7 +583,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_Semaphore *sem); * * \since This function is available since SDL 3.0.0. * - * \sa SDL_PostSemaphore + * \sa SDL_SignalSemaphore * \sa SDL_TryWaitSemaphore * \sa SDL_WaitSemaphoreTimeout */ @@ -604,7 +604,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_WaitSemaphore(SDL_Semaphore *sem); * * \since This function is available since SDL 3.0.0. * - * \sa SDL_PostSemaphore + * \sa SDL_SignalSemaphore * \sa SDL_WaitSemaphore * \sa SDL_WaitSemaphoreTimeout */ @@ -626,7 +626,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_TryWaitSemaphore(SDL_Semaphore *sem); * * \since This function is available since SDL 3.0.0. * - * \sa SDL_PostSemaphore + * \sa SDL_SignalSemaphore * \sa SDL_TryWaitSemaphore * \sa SDL_WaitSemaphore */ @@ -645,7 +645,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_WaitSemaphoreTimeout(SDL_Semaphore *sem, Sin * \sa SDL_WaitSemaphore * \sa SDL_WaitSemaphoreTimeout */ -extern SDL_DECLSPEC int SDLCALL SDL_PostSemaphore(SDL_Semaphore *sem); +extern SDL_DECLSPEC int SDLCALL SDL_SignalSemaphore(SDL_Semaphore *sem); /** * Get the current value of a semaphore. diff --git a/include/SDL3/SDL_oldnames.h b/include/SDL3/SDL_oldnames.h index f1b31adeb..cd895d5ea 100644 --- a/include/SDL3/SDL_oldnames.h +++ b/include/SDL3/SDL_oldnames.h @@ -444,7 +444,7 @@ #define SDL_CondWaitTimeout SDL_WaitConditionTimeout #define SDL_CreateCond SDL_CreateCondition #define SDL_DestroyCond SDL_DestroyCondition -#define SDL_SemPost SDL_PostSemaphore +#define SDL_SemPost SDL_SignalSemaphore #define SDL_SemTryWait SDL_TryWaitSemaphore #define SDL_SemValue SDL_GetSemaphoreValue #define SDL_SemWait SDL_WaitSemaphore @@ -1065,7 +1065,7 @@ #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_SemPost SDL_SemPost_renamed_SDL_SignalSemaphore #define SDL_SemTryWait SDL_SemTryWait_renamed_SDL_TryWaitSemaphore #define SDL_SemValue SDL_SemValue_renamed_SDL_GetSemaphoreValue #define SDL_SemWait SDL_SemWait_renamed_SDL_WaitSemaphore diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c index 76080fb58..0053cbd70 100644 --- a/src/audio/aaudio/SDL_aaudio.c +++ b/src/audio/aaudio/SDL_aaudio.c @@ -85,7 +85,7 @@ static void AAUDIO_errorCallback(AAudioStream *stream, void *userData, aaudio_re // Just flag the device so we can kill it in PlayDevice instead. SDL_AudioDevice *device = (SDL_AudioDevice *) userData; SDL_AtomicSet(&device->hidden->error_callback_triggered, (int) error); // AAUDIO_OK is zero, so !triggered means no error. - SDL_PostSemaphore(device->hidden->semaphore); // in case we're blocking in WaitDevice. + SDL_SignalSemaphore(device->hidden->semaphore); // in case we're blocking in WaitDevice. } static aaudio_data_callback_result_t AAUDIO_dataCallback(AAudioStream *stream, void *userData, void *audioData, int32_t numFrames) @@ -149,7 +149,7 @@ static aaudio_data_callback_result_t AAUDIO_dataCallback(AAudioStream *stream, v size_t new_buffer_index = hidden->callback_bytes / device->buffer_size; while (old_buffer_index < new_buffer_index) { // Trigger audio processing - SDL_PostSemaphore(hidden->semaphore); + SDL_SignalSemaphore(hidden->semaphore); ++old_buffer_index; } diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m index 0a1bfe186..aacae90e5 100644 --- a/src/audio/coreaudio/SDL_coreaudio.m +++ b/src/audio/coreaudio/SDL_coreaudio.m @@ -831,12 +831,12 @@ static int AudioQueueThreadEntry(void *arg) if (PrepareAudioQueue(device) < 0) { device->hidden->thread_error = SDL_strdup(SDL_GetError()); - SDL_PostSemaphore(device->hidden->ready_semaphore); + SDL_SignalSemaphore(device->hidden->ready_semaphore); return 0; } // init was successful, alert parent thread and start running... - SDL_PostSemaphore(device->hidden->ready_semaphore); + SDL_SignalSemaphore(device->hidden->ready_semaphore); // This would be WaitDevice/WaitRecordingDevice in the normal SDL audio thread, but we get *BufferReadyCallback calls here to know when to iterate. while (!SDL_AtomicGet(&device->shutdown)) { diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c index 3d1d0b75a..cfbf0a3b0 100644 --- a/src/audio/openslES/SDL_openslES.c +++ b/src/audio/openslES/SDL_openslES.c @@ -194,7 +194,7 @@ static void bqRecorderCallback(SLAndroidSimpleBufferQueueItf bq, void *context) struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context; LOGV("SLES: Recording Callback"); - SDL_PostSemaphore(audiodata->playsem); + SDL_SignalSemaphore(audiodata->playsem); } static void OPENSLES_DestroyPCMRecorder(SDL_AudioDevice *device) @@ -390,7 +390,7 @@ static void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context) struct SDL_PrivateAudioData *audiodata = (struct SDL_PrivateAudioData *)context; LOGV("SLES: Playback Callback"); - SDL_PostSemaphore(audiodata->playsem); + SDL_SignalSemaphore(audiodata->playsem); } static void OPENSLES_DestroyPCMPlayer(SDL_AudioDevice *device) @@ -673,7 +673,7 @@ static int OPENSLES_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int // If Enqueue fails, callback won't be called. // Post the semaphore, not to run out of buffer if (SL_RESULT_SUCCESS != result) { - SDL_PostSemaphore(audiodata->playsem); + SDL_SignalSemaphore(audiodata->playsem); } return 0; diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 6a9681fd5..b373ffb70 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -921,7 +921,7 @@ static int SDLCALL HotplugThread(void *data) // don't WaitForPulseOperation on the subscription; when it's done we'll be able to get hotplug events, but waiting doesn't changing anything. op = PULSEAUDIO_pa_context_subscribe(pulseaudio_context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE | PA_SUBSCRIPTION_MASK_SERVER, NULL, NULL); - SDL_PostSemaphore((SDL_Semaphore *) data); + SDL_SignalSemaphore((SDL_Semaphore *) data); while (SDL_AtomicGet(&pulseaudio_hotplug_thread_active)) { PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index b133b1665..003d3ba26 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -83,7 +83,7 @@ static void ManagementThreadMainloop(void) task->result = task->fn(task->userdata); // run this task. if (task->task_complete_sem) { // something waiting on result? task->errorstr = SDL_strdup(SDL_GetError()); - SDL_PostSemaphore(task->task_complete_sem); + SDL_SignalSemaphore(task->task_complete_sem); } else { // nothing waiting, we're done, free it. SDL_free(task); } @@ -190,11 +190,11 @@ static int ManagementThreadEntry(void *userdata) if (ManagementThreadPrepare() < 0) { data->errorstr = SDL_strdup(SDL_GetError()); - SDL_PostSemaphore(data->ready_sem); // unblock calling thread. + SDL_SignalSemaphore(data->ready_sem); // unblock calling thread. return 0; } - SDL_PostSemaphore(data->ready_sem); // unblock calling thread. + SDL_SignalSemaphore(data->ready_sem); // unblock calling thread. ManagementThreadMainloop(); WASAPI_PlatformDeinit(); diff --git a/src/audio/wasapi/SDL_wasapi_winrt.cpp b/src/audio/wasapi/SDL_wasapi_winrt.cpp index 5c954ac80..4300cc1b6 100644 --- a/src/audio/wasapi/SDL_wasapi_winrt.cpp +++ b/src/audio/wasapi/SDL_wasapi_winrt.cpp @@ -186,7 +186,7 @@ void SDL_WasapiDeviceEventHandler::OnEnumerationCompleted(DeviceWatcher ^ sender { SDL_assert(sender == this->watcher); if (this->completed_semaphore) { - SDL_PostSemaphore(this->completed_semaphore); + SDL_SignalSemaphore(this->completed_semaphore); } } @@ -283,7 +283,7 @@ HRESULT SDL_WasapiActivationHandler::ActivateCompleted(IActivateAudioInterfaceAsyncOperation *async) { // Just set a flag, since we're probably in a different thread. We'll pick it up and init everything on our own thread to prevent races. - SDL_PostSemaphore(completion_semaphore); + SDL_SignalSemaphore(completion_semaphore); return S_OK; } diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 40f43cc2d..f6d48425c 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -1370,7 +1370,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSendQuit)( } /* Resume the event loop so that the app can catch SDL_EVENT_QUIT which * should now be the top event in the event queue. */ - SDL_PostSemaphore(Android_ResumeSem); + SDL_SignalSemaphore(Android_ResumeSem); } /* Activity ends */ @@ -1412,7 +1412,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)( /* 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. */ - SDL_PostSemaphore(Android_PauseSem); + SDL_SignalSemaphore(Android_PauseSem); } /* Resume */ @@ -1425,7 +1425,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 * and this function will be called from the Java thread instead. */ - SDL_PostSemaphore(Android_ResumeSem); + SDL_SignalSemaphore(Android_ResumeSem); } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeFocusChanged)( diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index 44487f783..b8771177c 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -582,12 +582,12 @@ SDL3_0.0.0 { SDL_Metal_GetLayer; SDL_MinimizeWindow; SDL_MixAudio; - SDL_OnApplicationDidEnterForeground; SDL_OnApplicationDidChangeStatusBarOrientation; SDL_OnApplicationDidEnterBackground; + SDL_OnApplicationDidEnterForeground; SDL_OnApplicationDidReceiveMemoryWarning; - SDL_OnApplicationWillEnterForeground; SDL_OnApplicationWillEnterBackground; + SDL_OnApplicationWillEnterForeground; SDL_OnApplicationWillTerminate; SDL_OpenAudioDevice; SDL_OpenAudioDeviceStream; @@ -612,7 +612,6 @@ SDL3_0.0.0 { SDL_PenConnected; SDL_PlayHapticRumble; SDL_PollEvent; - SDL_PostSemaphore; SDL_PremultiplyAlpha; SDL_PremultiplySurfaceAlpha; SDL_PumpEvents; @@ -809,6 +808,7 @@ SDL3_0.0.0 { SDL_ShowWindow; SDL_ShowWindowSystemMenu; SDL_SignalCondition; + SDL_SignalSemaphore; SDL_StartTextInput; SDL_StepUTF8; SDL_StopHapticEffect; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index 7e7a42f91..3db9caa9f 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -607,12 +607,12 @@ #define SDL_Metal_GetLayer SDL_Metal_GetLayer_REAL #define SDL_MinimizeWindow SDL_MinimizeWindow_REAL #define SDL_MixAudio SDL_MixAudio_REAL -#define SDL_OnApplicationDidEnterForeground SDL_OnApplicationDidEnterForeground_REAL #define SDL_OnApplicationDidChangeStatusBarOrientation SDL_OnApplicationDidChangeStatusBarOrientation_REAL #define SDL_OnApplicationDidEnterBackground SDL_OnApplicationDidEnterBackground_REAL +#define SDL_OnApplicationDidEnterForeground SDL_OnApplicationDidEnterForeground_REAL #define SDL_OnApplicationDidReceiveMemoryWarning SDL_OnApplicationDidReceiveMemoryWarning_REAL -#define SDL_OnApplicationWillEnterForeground SDL_OnApplicationWillEnterForeground_REAL #define SDL_OnApplicationWillEnterBackground SDL_OnApplicationWillEnterBackground_REAL +#define SDL_OnApplicationWillEnterForeground SDL_OnApplicationWillEnterForeground_REAL #define SDL_OnApplicationWillTerminate SDL_OnApplicationWillTerminate_REAL #define SDL_OpenAudioDevice SDL_OpenAudioDevice_REAL #define SDL_OpenAudioDeviceStream SDL_OpenAudioDeviceStream_REAL @@ -637,7 +637,6 @@ #define SDL_PenConnected SDL_PenConnected_REAL #define SDL_PlayHapticRumble SDL_PlayHapticRumble_REAL #define SDL_PollEvent SDL_PollEvent_REAL -#define SDL_PostSemaphore SDL_PostSemaphore_REAL #define SDL_PremultiplyAlpha SDL_PremultiplyAlpha_REAL #define SDL_PremultiplySurfaceAlpha SDL_PremultiplySurfaceAlpha_REAL #define SDL_PumpEvents SDL_PumpEvents_REAL @@ -834,6 +833,7 @@ #define SDL_ShowWindow SDL_ShowWindow_REAL #define SDL_ShowWindowSystemMenu SDL_ShowWindowSystemMenu_REAL #define SDL_SignalCondition SDL_SignalCondition_REAL +#define SDL_SignalSemaphore SDL_SignalSemaphore_REAL #define SDL_StartTextInput SDL_StartTextInput_REAL #define SDL_StepUTF8 SDL_StepUTF8_REAL #define SDL_StopHapticEffect SDL_StopHapticEffect_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 0d3049496..05bab9386 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -618,12 +618,12 @@ SDL_DYNAPI_PROC(void,SDL_Metal_DestroyView,(SDL_MetalView a),(a),) SDL_DYNAPI_PROC(void*,SDL_Metal_GetLayer,(SDL_MetalView a),(a),return) SDL_DYNAPI_PROC(int,SDL_MinimizeWindow,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_MixAudio,(Uint8 *a, const Uint8 *b, SDL_AudioFormat c, Uint32 d, float e),(a,b,c,d,e),return) -SDL_DYNAPI_PROC(void,SDL_OnApplicationDidEnterForeground,(void),(),) SDL_DYNAPI_PROC(void,SDL_OnApplicationDidChangeStatusBarOrientation,(void),(),) SDL_DYNAPI_PROC(void,SDL_OnApplicationDidEnterBackground,(void),(),) +SDL_DYNAPI_PROC(void,SDL_OnApplicationDidEnterForeground,(void),(),) SDL_DYNAPI_PROC(void,SDL_OnApplicationDidReceiveMemoryWarning,(void),(),) -SDL_DYNAPI_PROC(void,SDL_OnApplicationWillEnterForeground,(void),(),) SDL_DYNAPI_PROC(void,SDL_OnApplicationWillEnterBackground,(void),(),) +SDL_DYNAPI_PROC(void,SDL_OnApplicationWillEnterForeground,(void),(),) SDL_DYNAPI_PROC(void,SDL_OnApplicationWillTerminate,(void),(),) SDL_DYNAPI_PROC(SDL_AudioDeviceID,SDL_OpenAudioDevice,(SDL_AudioDeviceID a, const SDL_AudioSpec *b),(a,b),return) SDL_DYNAPI_PROC(SDL_AudioStream*,SDL_OpenAudioDeviceStream,(SDL_AudioDeviceID a, const SDL_AudioSpec *b, SDL_AudioStreamCallback c, void *d),(a,b,c,d),return) @@ -648,7 +648,6 @@ SDL_DYNAPI_PROC(int,SDL_PeepEvents,(SDL_Event *a, int b, SDL_EventAction c, Uint SDL_DYNAPI_PROC(SDL_bool,SDL_PenConnected,(SDL_PenID a),(a),return) SDL_DYNAPI_PROC(int,SDL_PlayHapticRumble,(SDL_Haptic *a, float b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_bool,SDL_PollEvent,(SDL_Event *a),(a),return) -SDL_DYNAPI_PROC(int,SDL_PostSemaphore,(SDL_Semaphore *a),(a),return) SDL_DYNAPI_PROC(int,SDL_PremultiplyAlpha,(int a, int b, SDL_PixelFormat c, const void *d, int e, SDL_PixelFormat f, void *g, int h, SDL_bool i),(a,b,c,d,e,f,g,h,i),return) SDL_DYNAPI_PROC(int,SDL_PremultiplySurfaceAlpha,(SDL_Surface *a, SDL_bool b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_PumpEvents,(void),(),) @@ -844,6 +843,7 @@ SDL_DYNAPI_PROC(int,SDL_ShowSimpleMessageBox,(SDL_MessageBoxFlags a, const char SDL_DYNAPI_PROC(int,SDL_ShowWindow,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_ShowWindowSystemMenu,(SDL_Window *a, int b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_SignalCondition,(SDL_Condition *a),(a),return) +SDL_DYNAPI_PROC(int,SDL_SignalSemaphore,(SDL_Semaphore *a),(a),return) SDL_DYNAPI_PROC(int,SDL_StartTextInput,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(Uint32,SDL_StepUTF8,(const char **a, size_t *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_StopHapticEffect,(SDL_Haptic *a, int b),(a,b),return) diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c index a63982363..f33f96ba4 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -107,7 +107,7 @@ static void SDL_HIDAPI_StopRumbleThread(SDL_HIDAPI_RumbleContext *ctx) if (ctx->thread) { int result; - SDL_PostSemaphore(ctx->request_sem); + SDL_SignalSemaphore(ctx->request_sem); SDL_WaitThread(ctx->thread, &result); 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 */ SDL_HIDAPI_UnlockRumble(); - SDL_PostSemaphore(ctx->request_sem); + SDL_SignalSemaphore(ctx->request_sem); return size; } diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c index b832974e9..12ecaac88 100644 --- a/src/sensor/android/SDL_androidsensor.c +++ b/src/sensor/android/SDL_androidsensor.c @@ -65,7 +65,7 @@ static int SDLCALL SDL_ANDROID_SensorThread(void *data) SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH); SDL_sensor_looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); - SDL_PostSemaphore(ctx->sem); + SDL_SignalSemaphore(ctx->sem); while (SDL_AtomicGet(&ctx->running)) { Uint64 timestamp = SDL_GetTicksNS(); diff --git a/src/thread/generic/SDL_syscond.c b/src/thread/generic/SDL_syscond.c index d9cf41a90..9d73650b3 100644 --- a/src/thread/generic/SDL_syscond.c +++ b/src/thread/generic/SDL_syscond.c @@ -103,7 +103,7 @@ int SDL_SignalCondition_generic(SDL_Condition *_cond) SDL_LockMutex(cond->lock); if (cond->waiting > cond->signals) { ++cond->signals; - SDL_PostSemaphore(cond->wait_sem); + SDL_SignalSemaphore(cond->wait_sem); SDL_UnlockMutex(cond->lock); SDL_WaitSemaphore(cond->wait_done); } else { @@ -133,7 +133,7 @@ int SDL_BroadcastCondition_generic(SDL_Condition *_cond) num_waiting = (cond->waiting - cond->signals); cond->signals = cond->waiting; for (i = 0; i < num_waiting; ++i) { - SDL_PostSemaphore(cond->wait_sem); + SDL_SignalSemaphore(cond->wait_sem); } /* Now all released threads are blocked here, waiting for us. Collect them all (and win fabulous prizes!) :-) @@ -208,7 +208,7 @@ int SDL_WaitConditionTimeoutNS_generic(SDL_Condition *_cond, SDL_Mutex *mutex, S SDL_WaitSemaphore(cond->wait_sem); } /* We always notify the signal thread that we are done */ - SDL_PostSemaphore(cond->wait_done); + SDL_SignalSemaphore(cond->wait_done); /* Signal handshake complete */ --cond->signals; diff --git a/src/thread/generic/SDL_sysmutex.c b/src/thread/generic/SDL_sysmutex.c index b4d3068e6..cb5d77bd5 100644 --- a/src/thread/generic/SDL_sysmutex.c +++ b/src/thread/generic/SDL_sysmutex.c @@ -124,7 +124,7 @@ void SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang d then release the lock semaphore. */ mutex->owner = 0; - SDL_PostSemaphore(mutex->sem); + SDL_SignalSemaphore(mutex->sem); } } #endif // SDL_THREADS_DISABLED diff --git a/src/thread/generic/SDL_syssem.c b/src/thread/generic/SDL_syssem.c index 8ae532435..d8398120e 100644 --- a/src/thread/generic/SDL_syssem.c +++ b/src/thread/generic/SDL_syssem.c @@ -46,7 +46,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) return 0; } -int SDL_PostSemaphore(SDL_Semaphore *sem) +int SDL_SignalSemaphore(SDL_Semaphore *sem) { return SDL_SetError("SDL not built with thread support"); } @@ -153,7 +153,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) return value; } -int SDL_PostSemaphore(SDL_Semaphore *sem) +int SDL_SignalSemaphore(SDL_Semaphore *sem) { if (!sem) { return SDL_InvalidParamError("sem"); diff --git a/src/thread/n3ds/SDL_syssem.c b/src/thread/n3ds/SDL_syssem.c index 025aec3b7..70c48f6f3 100644 --- a/src/thread/n3ds/SDL_syssem.c +++ b/src/thread/n3ds/SDL_syssem.c @@ -105,7 +105,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) return sem->semaphore.current_count; } -int SDL_PostSemaphore(SDL_Semaphore *sem) +int SDL_SignalSemaphore(SDL_Semaphore *sem) { if (!sem) { return SDL_InvalidParamError("sem"); diff --git a/src/thread/ngage/SDL_syssem.cpp b/src/thread/ngage/SDL_syssem.cpp index 081d27870..4a2d9f4ca 100644 --- a/src/thread/ngage/SDL_syssem.cpp +++ b/src/thread/ngage/SDL_syssem.cpp @@ -147,7 +147,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) return sem->count; } -int SDL_PostSemaphore(SDL_Semaphore *sem) +int SDL_SignalSemaphore(SDL_Semaphore *sem) { if (!sem) { return SDL_InvalidParamError("sem"); diff --git a/src/thread/ps2/SDL_syssem.c b/src/thread/ps2/SDL_syssem.c index 2cd939731..a368f6962 100644 --- a/src/thread/ps2/SDL_syssem.c +++ b/src/thread/ps2/SDL_syssem.c @@ -121,7 +121,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) return 0; } -int SDL_PostSemaphore(SDL_Semaphore *sem) +int SDL_SignalSemaphore(SDL_Semaphore *sem) { int res; diff --git a/src/thread/psp/SDL_syssem.c b/src/thread/psp/SDL_syssem.c index 9d6065306..d4fcf6617 100644 --- a/src/thread/psp/SDL_syssem.c +++ b/src/thread/psp/SDL_syssem.c @@ -124,7 +124,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) return 0; } -int SDL_PostSemaphore(SDL_Semaphore *sem) +int SDL_SignalSemaphore(SDL_Semaphore *sem) { int res; diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index fcc287e80..a0a3829da 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -162,7 +162,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) return (Uint32)ret; } -int SDL_PostSemaphore(SDL_Semaphore *sem) +int SDL_SignalSemaphore(SDL_Semaphore *sem) { int retval; diff --git a/src/thread/vita/SDL_syssem.c b/src/thread/vita/SDL_syssem.c index 1075c528c..d37b9b33c 100644 --- a/src/thread/vita/SDL_syssem.c +++ b/src/thread/vita/SDL_syssem.c @@ -126,7 +126,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) return 0; } -int SDL_PostSemaphore(SDL_Semaphore *sem) +int SDL_SignalSemaphore(SDL_Semaphore *sem) { int res; diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c index b231a65b1..d0456a6a1 100644 --- a/src/thread/windows/SDL_syssem.c +++ b/src/thread/windows/SDL_syssem.c @@ -39,7 +39,7 @@ typedef SDL_Semaphore *(*pfnSDL_CreateSemaphore)(Uint32); typedef void (*pfnSDL_DestroySemaphore)(SDL_Semaphore *); typedef int (*pfnSDL_WaitSemaphoreTimeoutNS)(SDL_Semaphore *, Sint64); typedef Uint32 (*pfnSDL_GetSemaphoreValue)(SDL_Semaphore *); -typedef int (*pfnSDL_PostSemaphore)(SDL_Semaphore *); +typedef int (*pfnSDL_SignalSemaphore)(SDL_Semaphore *); typedef struct SDL_semaphore_impl_t { @@ -47,7 +47,7 @@ typedef struct SDL_semaphore_impl_t pfnSDL_DestroySemaphore Destroy; pfnSDL_WaitSemaphoreTimeoutNS WaitTimeoutNS; pfnSDL_GetSemaphoreValue Value; - pfnSDL_PostSemaphore Post; + pfnSDL_SignalSemaphore Post; } SDL_sem_impl_t; /* Implementation will be chosen at runtime based on available Kernel features */ @@ -180,7 +180,7 @@ static Uint32 SDL_GetSemaphoreValue_atom(SDL_Semaphore *_sem) return (Uint32)sem->count; } -static int SDL_PostSemaphore_atom(SDL_Semaphore *_sem) +static int SDL_SignalSemaphore_atom(SDL_Semaphore *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; @@ -199,7 +199,7 @@ static const SDL_sem_impl_t SDL_sem_impl_atom = { &SDL_DestroySemaphore_atom, &SDL_WaitSemaphoreTimeoutNS_atom, &SDL_GetSemaphoreValue_atom, - &SDL_PostSemaphore_atom, + &SDL_SignalSemaphore_atom, }; #endif /* !SDL_WINAPI_FAMILY_PHONE */ @@ -292,7 +292,7 @@ static Uint32 SDL_GetSemaphoreValue_kern(SDL_Semaphore *_sem) return (Uint32)sem->count; } -static int SDL_PostSemaphore_kern(SDL_Semaphore *_sem) +static int SDL_SignalSemaphore_kern(SDL_Semaphore *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; if (!sem) { @@ -316,7 +316,7 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = { &SDL_DestroySemaphore_kern, &SDL_WaitSemaphoreTimeoutNS_kern, &SDL_GetSemaphoreValue_kern, - &SDL_PostSemaphore_kern, + &SDL_SignalSemaphore_kern, }; /** @@ -376,7 +376,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) return SDL_sem_impl_active.Value(sem); } -int SDL_PostSemaphore(SDL_Semaphore *sem) +int SDL_SignalSemaphore(SDL_Semaphore *sem) { return SDL_sem_impl_active.Post(sem); } diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 4c5bd018c..20050952b 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -243,7 +243,7 @@ void SDL_QuitTimers(void) if (SDL_AtomicCompareAndSwap(&data->active, 1, 0)) { /* active? Move to inactive. */ /* Shutdown the timer thread */ if (data->thread) { - SDL_PostSemaphore(data->sem); + SDL_SignalSemaphore(data->sem); SDL_WaitThread(data->thread, NULL); data->thread = NULL; } @@ -334,7 +334,7 @@ static SDL_TimerID SDL_CreateTimer(Uint64 interval, SDL_TimerCallback callback_m SDL_UnlockSpinlock(&data->lock); /* Wake up the timer thread if necessary */ - SDL_PostSemaphore(data->sem); + SDL_SignalSemaphore(data->sem); return entry->timerID; } diff --git a/src/video/psp/SDL_pspevents.c b/src/video/psp/SDL_pspevents.c index 1876b3f06..0ba7c67ee 100644 --- a/src/video/psp/SDL_pspevents.c +++ b/src/video/psp/SDL_pspevents.c @@ -66,7 +66,7 @@ int EventUpdate(void *data) while (running) { SDL_WaitSemaphore(event_sem); sceHprmPeekCurrentKey((u32 *)&hprm); - SDL_PostSemaphore(event_sem); + SDL_SignalSemaphore(event_sem); /* Delay 1/60th of a second */ sceKernelDelayThread(1000000 / 60); } @@ -82,7 +82,7 @@ void PSP_PumpEvents(SDL_VideoDevice *_this) SDL_WaitSemaphore(event_sem); keys = hprm; - SDL_PostSemaphore(event_sem); + SDL_SignalSemaphore(event_sem); /* HPRM Keyboard */ changed = old_keys ^ keys; diff --git a/test/testatomic.c b/test/testatomic.c index a6266859f..e2c3dda2b 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -121,7 +121,7 @@ static int SDLCALL adder(void *junk) bad -= CountInc; } SDL_AtomicAdd(&threadsRunning, -1); - SDL_PostSemaphore(threadDone); + SDL_SignalSemaphore(threadDone); return 0; } diff --git a/test/testgles2.c b/test/testgles2.c index 89546ca13..4c4bcc709 100644 --- a/test/testgles2.c +++ b/test/testgles2.c @@ -609,7 +609,7 @@ loop_threaded(void) tdata = GetThreadDataForWindow(event.window.windowID); if (tdata) { if (SDL_AtomicSet(&tdata->suspended, WAIT_STATE_GO) == WAIT_STATE_WAITING_ON_SEM) { - SDL_PostSemaphore(tdata->suspend_sem); + SDL_SignalSemaphore(tdata->suspend_sem); } } } else if (event.type == SDL_EVENT_WINDOW_CLOSE_REQUESTED) { @@ -619,7 +619,7 @@ loop_threaded(void) tdata->done = 1; if (tdata->thread) { SDL_AtomicSet(&tdata->suspended, WAIT_STATE_GO); - SDL_PostSemaphore(tdata->suspend_sem); + SDL_SignalSemaphore(tdata->suspend_sem); SDL_WaitThread(tdata->thread, NULL); tdata->thread = NULL; SDL_DestroySemaphore(tdata->suspend_sem); diff --git a/test/testsem.c b/test/testsem.c index e041b7645..e7f0dd0eb 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -56,7 +56,7 @@ ThreadFuncRealWorld(void *data) SDL_Log("Thread number %d has got the semaphore (value = %" SDL_PRIu32 ")!\n", state->number, SDL_GetSemaphoreValue(sem)); SDL_Delay(200); - SDL_PostSemaphore(sem); + SDL_SignalSemaphore(sem); SDL_Log("Thread number %d has released the semaphore (value = %" SDL_PRIu32 ")!\n", state->number, SDL_GetSemaphoreValue(sem)); ++state->loop_count; @@ -145,7 +145,7 @@ TestOverheadUncontended(void) start_ticks = SDL_GetTicks(); for (i = 0; i < NUM_OVERHEAD_OPS_MULT; i++) { for (j = 0; j < NUM_OVERHEAD_OPS; j++) { - SDL_PostSemaphore(sem); + SDL_SignalSemaphore(sem); } for (j = 0; j < NUM_OVERHEAD_OPS; j++) { SDL_WaitSemaphore(sem); @@ -211,7 +211,7 @@ TestOverheadContended(SDL_bool try_wait) start_ticks = SDL_GetTicks(); for (i = 0; i < NUM_OVERHEAD_OPS_MULT; i++) { for (j = 0; j < NUM_OVERHEAD_OPS; j++) { - SDL_PostSemaphore(sem); + SDL_SignalSemaphore(sem); } /* Make sure threads consumed everything */ while (SDL_GetSemaphoreValue(sem)) {