Changed the name of SDL_mutexP() SDL_mutexV()
authorSam Lantinga <slouken@libsdl.org>
Thu, 07 Mar 2013 20:12:40 -0800
changeset 6977 b73d51026c68
parent 6976 177d1dc3dba6
child 6978 e851407e9294
Changed the name of SDL_mutexP() SDL_mutexV()
include/SDL_mutex.h
src/atomic/SDL_spinlock.c
src/audio/SDL_audio.c
src/audio/baudio/SDL_beaudio.cc
src/audio/coreaudio/SDL_coreaudio.c
src/events/SDL_events.c
src/joystick/windows/SDL_dxjoystick.c
src/thread/SDL_thread.c
src/thread/generic/SDL_sysmutex.c
src/thread/generic/SDL_syssem.c
src/thread/nds/SDL_sysmutex.c
src/thread/nds/SDL_syssem.c
src/thread/pthread/SDL_sysmutex.c
src/thread/windows/SDL_sysmutex.c
src/timer/SDL_timer.c
test/testatomic.c
test/testlock.c
--- a/include/SDL_mutex.h	Thu Mar 07 15:37:08 2013 -0800
+++ b/include/SDL_mutex.h	Thu Mar 07 20:12:40 2013 -0800
@@ -70,8 +70,8 @@
  *  
  *  \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 @@
  *  \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.
--- a/src/atomic/SDL_spinlock.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/atomic/SDL_spinlock.c	Thu Mar 07 20:12:40 2013 -0800
@@ -41,13 +41,13 @@
         /* 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;
     }
 
--- a/src/audio/SDL_audio.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/audio/SDL_audio.c	Thu Mar 07 20:12:40 2013 -0800
@@ -200,7 +200,7 @@
     if (device->thread && (SDL_ThreadID() == device->threadid)) {
         return;
     }
-    SDL_mutexP(device->mixer_lock);
+    SDL_LockMutex(device->mixer_lock);
 }
 
 static void
@@ -209,7 +209,7 @@
     if (device->thread && (SDL_ThreadID() == device->threadid)) {
         return;
     }
-    SDL_mutexV(device->mixer_lock);
+    SDL_UnlockMutex(device->mixer_lock);
 }
 
 
@@ -407,9 +407,9 @@
                 }
 
                 /* 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_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) {
--- a/src/audio/baudio/SDL_beaudio.cc	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/audio/baudio/SDL_beaudio.cc	Thu Mar 07 20:12:40 2013 -0800
@@ -54,18 +54,18 @@
 
     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);
         }
     }
 }
--- a/src/audio/coreaudio/SDL_coreaudio.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/audio/coreaudio/SDL_coreaudio.c	Thu Mar 07 20:12:40 2013 -0800
@@ -280,10 +280,10 @@
         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;
             }
 
--- a/src/events/SDL_events.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/events/SDL_events.c	Thu Mar 07 20:12:40 2013 -0800
@@ -212,7 +212,7 @@
     }
     /* 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_mutexV(SDL_EventQ.lock);
+        SDL_UnlockMutex(SDL_EventQ.lock);
     } else {
         SDL_SetError("Couldn't lock event queue");
         used = -1;
@@ -285,7 +285,7 @@
 #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 @@
                 spot = (spot + 1) % MAXEVENTS;
             }
         }
-        SDL_mutexV(SDL_EventQ.lock);
+        SDL_UnlockMutex(SDL_EventQ.lock);
     }
 }
 
@@ -446,7 +446,7 @@
 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_mutexV(SDL_EventQ.lock);
+    SDL_UnlockMutex(SDL_EventQ.lock);
 }
 
 Uint8
--- a/src/joystick/windows/SDL_dxjoystick.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/joystick/windows/SDL_dxjoystick.c	Thu Mar 07 20:12:40 2013 -0800
@@ -819,7 +819,7 @@
 		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 @@
 			EnumJoysticksCallback,
 			&pCurList, DIEDFL_ATTACHEDONLY);
 
-		SDL_mutexV( s_mutexJoyStickEnum );
+		SDL_UnlockMutex( s_mutexJoyStickEnum );
 	}
 
 	if ( pCurList )
--- a/src/thread/SDL_thread.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/thread/SDL_thread.c	Thu Mar 07 20:12:40 2013 -0800
@@ -85,7 +85,7 @@
             return;
         }
     }
-    SDL_mutexP(thread_lock);
+    SDL_LockMutex(thread_lock);
 
     /* Expand the list of threads, if necessary */
 #ifdef DEBUG_THREADS
@@ -118,7 +118,7 @@
     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_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;
--- a/src/thread/generic/SDL_sysmutex.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/thread/generic/SDL_sysmutex.c	Thu Mar 07 20:12:40 2013 -0800
@@ -70,7 +70,7 @@
 
 /* Lock the mutex */
 int
-SDL_mutexP(SDL_mutex * mutex)
+SDL_LockMutex(SDL_mutex * mutex)
 {
 #if SDL_THREADS_DISABLED
     return 0;
--- a/src/thread/generic/SDL_syssem.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/thread/generic/SDL_syssem.c	Thu Mar 07 20:12:40 2013 -0800
@@ -123,8 +123,8 @@
         }
         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);
--- a/src/thread/nds/SDL_sysmutex.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/thread/nds/SDL_sysmutex.c	Thu Mar 07 20:12:40 2013 -0800
@@ -78,7 +78,7 @@
 
 /* Lock the mutex */
 int
-SDL_mutexP(SDL_mutex * mutex)
+SDL_LockMutex(SDL_mutex * mutex)
 {
 #ifdef DISABLE_THREADS
     return 0;
@@ -143,7 +143,7 @@
 
 /* Unlock the mutex */
 int
-SDL_mutexV(SDL_mutex * mutex)
+SDL_UnlockMutex(SDL_mutex * mutex)
 {
 #ifdef DISABLE_THREADS
     return 0;
--- a/src/thread/nds/SDL_syssem.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/thread/nds/SDL_syssem.c	Thu Mar 07 20:12:40 2013 -0800
@@ -129,8 +129,8 @@
             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);
     }
--- a/src/thread/pthread/SDL_sysmutex.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/thread/pthread/SDL_sysmutex.c	Thu Mar 07 20:12:40 2013 -0800
@@ -79,7 +79,7 @@
 
 /* Lock the mutex */
 int
-SDL_mutexP(SDL_mutex * mutex)
+SDL_LockMutex(SDL_mutex * mutex)
 {
     int retval;
 #if FAKE_RECURSIVE_MUTEX
@@ -165,7 +165,7 @@
 }
 
 int
-SDL_mutexV(SDL_mutex * mutex)
+SDL_UnlockMutex(SDL_mutex * mutex)
 {
     int retval;
 
--- a/src/thread/windows/SDL_sysmutex.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/thread/windows/SDL_sysmutex.c	Thu Mar 07 20:12:40 2013 -0800
@@ -64,7 +64,7 @@
 
 /* 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 @@
 
 /* Unlock the mutex */
 int
-SDL_mutexV(SDL_mutex * mutex)
+SDL_UnlockMutex(SDL_mutex * mutex)
 {
     if (mutex == NULL) {
         SDL_SetError("Passed a NULL mutex");
--- a/src/timer/SDL_timer.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/src/timer/SDL_timer.c	Thu Mar 07 20:12:40 2013 -0800
@@ -334,10 +334,10 @@
     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_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 @@
             break;
         }
     }
-    SDL_mutexV(data->timermap_lock);
+    SDL_UnlockMutex(data->timermap_lock);
 
     if (entry) {
         if (!entry->timer->canceled) {
--- a/test/testatomic.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/test/testatomic.c	Thu Mar 07 20:12:40 2013 -0800
@@ -412,7 +412,7 @@
     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 @@
         printf("ERROR: mutex failed!\n");
     }
 
-    SDL_mutexV(queue->mutex);
+    SDL_UnlockMutex(queue->mutex);
 
     return status;
 }
@@ -445,7 +445,7 @@
     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 @@
         printf("ERROR: mutex failed!\n");
     }
 
-    SDL_mutexV(queue->mutex);
+    SDL_UnlockMutex(queue->mutex);
 
     return status;
 }
--- a/test/testlock.c	Thu Mar 07 15:37:08 2013 -0800
+++ b/test/testlock.c	Thu Mar 07 20:12:40 2013 -0800
@@ -69,14 +69,14 @@
         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);
         }