From 9a1385b61398d6feceb7bedba4e7b490330e1df9 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 7 Mar 2013 20:12:40 -0800 Subject: [PATCH] Changed the name of SDL_mutexP() SDL_mutexV() --- include/SDL_mutex.h | 8 ++++---- src/atomic/SDL_spinlock.c | 6 +++--- src/audio/SDL_audio.c | 12 ++++++------ src/audio/baudio/SDL_beaudio.cc | 8 ++++---- src/audio/coreaudio/SDL_coreaudio.c | 4 ++-- src/events/SDL_events.c | 12 ++++++------ src/joystick/windows/SDL_dxjoystick.c | 4 ++-- src/thread/SDL_thread.c | 6 +++--- src/thread/generic/SDL_sysmutex.c | 2 +- src/thread/generic/SDL_syssem.c | 4 ++-- src/thread/nds/SDL_sysmutex.c | 4 ++-- src/thread/nds/SDL_syssem.c | 4 ++-- src/thread/pthread/SDL_sysmutex.c | 4 ++-- src/thread/windows/SDL_sysmutex.c | 4 ++-- src/timer/SDL_timer.c | 8 ++++---- test/testatomic.c | 8 ++++---- test/testlock.c | 4 ++-- 17 files changed, 51 insertions(+), 51 deletions(-) diff --git a/include/SDL_mutex.h b/include/SDL_mutex.h index 7ef294e1a..30519b87f 100644 --- a/include/SDL_mutex.h +++ b/include/SDL_mutex.h @@ -70,8 +70,8 @@ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); * * \return 0, or -1 on error. */ -#define SDL_LockMutex(m) SDL_mutexP(m) -extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex * mutex); +#define SDL_mutexP(m) SDL_LockMutex(m) +extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); /** * Try to lock the mutex @@ -88,8 +88,8 @@ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); * \warning It is an error to unlock a mutex that has not been locked by * the current thread, and doing so results in undefined behavior. */ -#define SDL_UnlockMutex(m) SDL_mutexV(m) -extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex * mutex); +#define SDL_mutexV(m) SDL_UnlockMutex(m) +extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); /** * Destroy a mutex. diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index 3bb319e9c..12c06a33e 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -41,13 +41,13 @@ SDL_AtomicTryLock(SDL_SpinLock *lock) /* Race condition on first lock... */ _spinlock_mutex = SDL_CreateMutex(); } - SDL_mutexP(_spinlock_mutex); + SDL_LockMutex(_spinlock_mutex); if (*lock == 0) { *lock = 1; - SDL_mutexV(_spinlock_mutex); + SDL_UnlockMutex(_spinlock_mutex); return SDL_TRUE; } else { - SDL_mutexV(_spinlock_mutex); + SDL_UnlockMutex(_spinlock_mutex); return SDL_FALSE; } diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 090e0144b..6e87e1a5a 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -200,7 +200,7 @@ SDL_AudioLockDevice_Default(SDL_AudioDevice * device) if (device->thread && (SDL_ThreadID() == device->threadid)) { return; } - SDL_mutexP(device->mixer_lock); + SDL_LockMutex(device->mixer_lock); } static void @@ -209,7 +209,7 @@ SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device) if (device->thread && (SDL_ThreadID() == device->threadid)) { return; } - SDL_mutexV(device->mixer_lock); + SDL_UnlockMutex(device->mixer_lock); } @@ -407,9 +407,9 @@ SDL_RunAudio(void *devicep) } /* Read from the callback into the _input_ stream */ - SDL_mutexP(device->mixer_lock); + SDL_LockMutex(device->mixer_lock); (*fill) (udata, istream, istream_len); - SDL_mutexV(device->mixer_lock); + SDL_UnlockMutex(device->mixer_lock); /* Convert the audio if necessary and write to the streamer */ if (device->convert.needed) { @@ -480,9 +480,9 @@ SDL_RunAudio(void *devicep) } } - SDL_mutexP(device->mixer_lock); + SDL_LockMutex(device->mixer_lock); (*fill) (udata, stream, stream_len); - SDL_mutexV(device->mixer_lock); + SDL_UnlockMutex(device->mixer_lock); /* Convert the audio if necessary */ if (device->convert.needed) { diff --git a/src/audio/baudio/SDL_beaudio.cc b/src/audio/baudio/SDL_beaudio.cc index 20396f31a..2a25cf0d2 100644 --- a/src/audio/baudio/SDL_beaudio.cc +++ b/src/audio/baudio/SDL_beaudio.cc @@ -54,18 +54,18 @@ FillSound(void *device, void *stream, size_t len, if (!audio->paused) { if (audio->convert.needed) { - SDL_mutexP(audio->mixer_lock); + SDL_LockMutex(audio->mixer_lock); (*audio->spec.callback) (audio->spec.userdata, (Uint8 *) audio->convert.buf, audio->convert.len); - SDL_mutexV(audio->mixer_lock); + SDL_UnlockMutex(audio->mixer_lock); SDL_ConvertAudio(&audio->convert); SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt); } else { - SDL_mutexP(audio->mixer_lock); + SDL_LockMutex(audio->mixer_lock); (*audio->spec.callback) (audio->spec.userdata, (Uint8 *) stream, len); - SDL_mutexV(audio->mixer_lock); + SDL_UnlockMutex(audio->mixer_lock); } } } diff --git a/src/audio/coreaudio/SDL_coreaudio.c b/src/audio/coreaudio/SDL_coreaudio.c index 533dcfdca..31eb32615 100644 --- a/src/audio/coreaudio/SDL_coreaudio.c +++ b/src/audio/coreaudio/SDL_coreaudio.c @@ -280,10 +280,10 @@ outputCallback(void *inRefCon, while (remaining > 0) { if (this->hidden->bufferOffset >= this->hidden->bufferSize) { /* Generate the data */ - SDL_mutexP(this->mixer_lock); + SDL_LockMutex(this->mixer_lock); (*this->spec.callback)(this->spec.userdata, this->hidden->buffer, this->hidden->bufferSize); - SDL_mutexV(this->mixer_lock); + SDL_UnlockMutex(this->mixer_lock); this->hidden->bufferOffset = 0; } diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 149add196..b608590c4 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -212,7 +212,7 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, } /* Lock the event queue */ used = 0; - if (!SDL_EventQ.lock || SDL_mutexP(SDL_EventQ.lock) == 0) { + if (!SDL_EventQ.lock || SDL_LockMutex(SDL_EventQ.lock) == 0) { if (action == SDL_ADDEVENT) { for (i = 0; i < numevents; ++i) { used += SDL_AddEvent(&events[i]); @@ -242,7 +242,7 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, } } } - SDL_mutexV(SDL_EventQ.lock); + SDL_UnlockMutex(SDL_EventQ.lock); } else { SDL_SetError("Couldn't lock event queue"); used = -1; @@ -285,7 +285,7 @@ SDL_FlushEvents(Uint32 minType, Uint32 maxType) #endif /* Lock the event queue */ - if (SDL_mutexP(SDL_EventQ.lock) == 0) { + if (SDL_LockMutex(SDL_EventQ.lock) == 0) { int spot = SDL_EventQ.head; while (spot != SDL_EventQ.tail) { Uint32 type = SDL_EventQ.event[spot].type; @@ -295,7 +295,7 @@ SDL_FlushEvents(Uint32 minType, Uint32 maxType) spot = (spot + 1) % MAXEVENTS; } } - SDL_mutexV(SDL_EventQ.lock); + SDL_UnlockMutex(SDL_EventQ.lock); } } @@ -446,7 +446,7 @@ SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) void SDL_FilterEvents(SDL_EventFilter filter, void *userdata) { - if (SDL_mutexP(SDL_EventQ.lock) == 0) { + if (SDL_LockMutex(SDL_EventQ.lock) == 0) { int spot; spot = SDL_EventQ.head; @@ -458,7 +458,7 @@ SDL_FilterEvents(SDL_EventFilter filter, void *userdata) } } } - SDL_mutexV(SDL_EventQ.lock); + SDL_UnlockMutex(SDL_EventQ.lock); } Uint8 diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c index 9c493cb20..6493388f3 100644 --- a/src/joystick/windows/SDL_dxjoystick.c +++ b/src/joystick/windows/SDL_dxjoystick.c @@ -819,7 +819,7 @@ void SDL_SYS_JoystickDetect() pCurList = SYS_Joystick; SYS_Joystick = NULL; s_iNewGUID = 0; - SDL_mutexP( s_mutexJoyStickEnum ); + SDL_LockMutex( s_mutexJoyStickEnum ); if ( !s_pKnownJoystickGUIDs ) s_pKnownJoystickGUIDs = SDL_malloc( sizeof(GUID)*MAX_JOYSTICKS ); @@ -832,7 +832,7 @@ void SDL_SYS_JoystickDetect() EnumJoysticksCallback, &pCurList, DIEDFL_ATTACHEDONLY); - SDL_mutexV( s_mutexJoyStickEnum ); + SDL_UnlockMutex( s_mutexJoyStickEnum ); } if ( pCurList ) diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index 99258a4cd..e20f672ff 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -85,7 +85,7 @@ SDL_AddThread(SDL_Thread * thread) return; } } - SDL_mutexP(thread_lock); + SDL_LockMutex(thread_lock); /* Expand the list of threads, if necessary */ #ifdef DEBUG_THREADS @@ -118,7 +118,7 @@ SDL_DelThread(SDL_Thread * thread) if (!thread_lock) { return; } - SDL_mutexP(thread_lock); + SDL_LockMutex(thread_lock); for (i = 0; i < SDL_numthreads; ++i) { if (thread == SDL_Threads[i]) { break; @@ -164,7 +164,7 @@ SDL_GetErrBuf(void) SDL_threadID this_thread; this_thread = SDL_ThreadID(); - SDL_mutexP(thread_lock); + SDL_LockMutex(thread_lock); for (i = 0; i < SDL_numthreads; ++i) { if (this_thread == SDL_Threads[i]->threadid) { errbuf = &SDL_Threads[i]->errbuf; diff --git a/src/thread/generic/SDL_sysmutex.c b/src/thread/generic/SDL_sysmutex.c index 6cc32ec70..4954f48e8 100644 --- a/src/thread/generic/SDL_sysmutex.c +++ b/src/thread/generic/SDL_sysmutex.c @@ -70,7 +70,7 @@ SDL_DestroyMutex(SDL_mutex * mutex) /* Lock the mutex */ int -SDL_mutexP(SDL_mutex * mutex) +SDL_LockMutex(SDL_mutex * mutex) { #if SDL_THREADS_DISABLED return 0; diff --git a/src/thread/generic/SDL_syssem.c b/src/thread/generic/SDL_syssem.c index 365c7872c..474c44662 100644 --- a/src/thread/generic/SDL_syssem.c +++ b/src/thread/generic/SDL_syssem.c @@ -123,8 +123,8 @@ SDL_DestroySemaphore(SDL_sem * sem) } SDL_DestroyCond(sem->count_nonzero); if (sem->count_lock) { - SDL_mutexP(sem->count_lock); - SDL_mutexV(sem->count_lock); + SDL_LockMutex(sem->count_lock); + SDL_UnlockMutex(sem->count_lock); SDL_DestroyMutex(sem->count_lock); } SDL_free(sem); diff --git a/src/thread/nds/SDL_sysmutex.c b/src/thread/nds/SDL_sysmutex.c index ec940dd24..ffdecc808 100644 --- a/src/thread/nds/SDL_sysmutex.c +++ b/src/thread/nds/SDL_sysmutex.c @@ -78,7 +78,7 @@ SDL_DestroyMutex(SDL_mutex * mutex) /* Lock the mutex */ int -SDL_mutexP(SDL_mutex * mutex) +SDL_LockMutex(SDL_mutex * mutex) { #ifdef DISABLE_THREADS return 0; @@ -143,7 +143,7 @@ SDL_TryLockMutex(SDL_mutex * mutex) /* Unlock the mutex */ int -SDL_mutexV(SDL_mutex * mutex) +SDL_UnlockMutex(SDL_mutex * mutex) { #ifdef DISABLE_THREADS return 0; diff --git a/src/thread/nds/SDL_syssem.c b/src/thread/nds/SDL_syssem.c index 015f9c9d8..788fc9223 100644 --- a/src/thread/nds/SDL_syssem.c +++ b/src/thread/nds/SDL_syssem.c @@ -129,8 +129,8 @@ SDL_DestroySemaphore(SDL_sem * sem) SDL_Delay(10); } SDL_DestroyCond(sem->count_nonzero); - SDL_mutexP(sem->count_lock); - SDL_mutexV(sem->count_lock); + SDL_LockMutex(sem->count_lock); + SDL_UnlockMutex(sem->count_lock); SDL_DestroyMutex(sem->count_lock); free(sem); } diff --git a/src/thread/pthread/SDL_sysmutex.c b/src/thread/pthread/SDL_sysmutex.c index 6d1a1d92e..f67cdf6c4 100644 --- a/src/thread/pthread/SDL_sysmutex.c +++ b/src/thread/pthread/SDL_sysmutex.c @@ -79,7 +79,7 @@ SDL_DestroyMutex(SDL_mutex * mutex) /* Lock the mutex */ int -SDL_mutexP(SDL_mutex * mutex) +SDL_LockMutex(SDL_mutex * mutex) { int retval; #if FAKE_RECURSIVE_MUTEX @@ -165,7 +165,7 @@ SDL_TryLockMutex(SDL_mutex * mutex) } int -SDL_mutexV(SDL_mutex * mutex) +SDL_UnlockMutex(SDL_mutex * mutex) { int retval; diff --git a/src/thread/windows/SDL_sysmutex.c b/src/thread/windows/SDL_sysmutex.c index 78730ff64..6455cbeab 100644 --- a/src/thread/windows/SDL_sysmutex.c +++ b/src/thread/windows/SDL_sysmutex.c @@ -64,7 +64,7 @@ SDL_DestroyMutex(SDL_mutex * mutex) /* Lock the mutex */ int -SDL_mutexP(SDL_mutex * mutex) +SDL_LockMutex(SDL_mutex * mutex) { if (mutex == NULL) { SDL_SetError("Passed a NULL mutex"); @@ -93,7 +93,7 @@ SDL_TryLockMutex(SDL_mutex * mutex) /* Unlock the mutex */ int -SDL_mutexV(SDL_mutex * mutex) +SDL_UnlockMutex(SDL_mutex * mutex) { if (mutex == NULL) { SDL_SetError("Passed a NULL mutex"); diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index f30410aa1..60b3bdb12 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -334,10 +334,10 @@ SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param) entry->timer = timer; entry->timerID = timer->timerID; - SDL_mutexP(data->timermap_lock); + SDL_LockMutex(data->timermap_lock); entry->next = data->timermap; data->timermap = entry; - SDL_mutexV(data->timermap_lock); + SDL_UnlockMutex(data->timermap_lock); /* Add the timer to the pending list for the timer thread */ SDL_AtomicLock(&data->lock); @@ -359,7 +359,7 @@ SDL_RemoveTimer(SDL_TimerID id) SDL_bool canceled = SDL_FALSE; /* Find the timer */ - SDL_mutexP(data->timermap_lock); + SDL_LockMutex(data->timermap_lock); prev = NULL; for (entry = data->timermap; entry; prev = entry, entry = entry->next) { if (entry->timerID == id) { @@ -371,7 +371,7 @@ SDL_RemoveTimer(SDL_TimerID id) break; } } - SDL_mutexV(data->timermap_lock); + SDL_UnlockMutex(data->timermap_lock); if (entry) { if (!entry->timer->canceled) { diff --git a/test/testatomic.c b/test/testatomic.c index a05834080..7bcceb559 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -412,7 +412,7 @@ static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event int delta; SDL_bool status = SDL_FALSE; - SDL_mutexP(queue->mutex); + SDL_LockMutex(queue->mutex); queue_pos = (unsigned)queue->enqueue_pos.value; entry = &queue->entries[queue_pos & WRAP_MASK]; @@ -432,7 +432,7 @@ static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event printf("ERROR: mutex failed!\n"); } - SDL_mutexV(queue->mutex); + SDL_UnlockMutex(queue->mutex); return status; } @@ -445,7 +445,7 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event) int delta; SDL_bool status = SDL_FALSE; - SDL_mutexP(queue->mutex); + SDL_LockMutex(queue->mutex); queue_pos = (unsigned)queue->dequeue_pos.value; entry = &queue->entries[queue_pos & WRAP_MASK]; @@ -465,7 +465,7 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event) printf("ERROR: mutex failed!\n"); } - SDL_mutexV(queue->mutex); + SDL_UnlockMutex(queue->mutex); return status; } diff --git a/test/testlock.c b/test/testlock.c index 362d687cf..04abf3d7f 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -69,14 +69,14 @@ Run(void *data) signal(SIGTERM, closemutex); while (!doterminate) { printf("Process %lu ready to work\n", SDL_ThreadID()); - if (SDL_mutexP(mutex) < 0) { + if (SDL_LockMutex(mutex) < 0) { fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError()); exit(1); } printf("Process %lu, working!\n", SDL_ThreadID()); SDL_Delay(1 * 1000); printf("Process %lu, done!\n", SDL_ThreadID()); - if (SDL_mutexV(mutex) < 0) { + if (SDL_UnlockMutex(mutex) < 0) { fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError()); exit(1); }