src/thread/win32/SDL_syssem.c
changeset 3069 caefe2344f65
parent 2859 99210400e8b9
child 3071 6f3308d4b6cd
--- a/src/thread/win32/SDL_syssem.c	Tue Feb 17 05:17:51 2009 +0000
+++ b/src/thread/win32/SDL_syssem.c	Tue Feb 17 05:39:18 2009 +0000
@@ -109,7 +109,7 @@
     switch (WaitForSingleObject(sem->id, dwMilliseconds)) {
 #endif
     case WAIT_OBJECT_0:
-        --sem->count;
+        InterlockedDecrement(&sem->count);
         retval = 0;
         break;
     case WAIT_TIMEOUT:
@@ -158,13 +158,13 @@
      * immediately get destroyed by another thread which
      * is waiting for this semaphore.
      */
-    ++sem->count;
+    InterlockedIncrement(&sem->count);
 #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
     if (ReleaseSemaphoreCE(sem->id, 1, NULL) == FALSE) {
 #else
     if (ReleaseSemaphore(sem->id, 1, NULL) == FALSE) {
 #endif
-        --sem->count;           /* restore */
+        InterlockedDecrement(&sem->count);           /* restore */
         SDL_SetError("ReleaseSemaphore() failed");
         return -1;
     }