Changed the name of SDL_mutexP() SDL_mutexV()

This commit is contained in:
Sam Lantinga 2013-03-07 20:12:40 -08:00
parent 0707530b35
commit c6388c87c1
17 changed files with 51 additions and 51 deletions

View File

@ -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.

View File

@ -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;
}

View File

@ -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) {

View File

@ -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);
}
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -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 )

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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");

View File

@ -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) {

View File

@ -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;
}

View File

@ -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);
}