on timeout sceKernelWaitSema() returns SCE_KERNEL_ERROR_WAIT_TIMEOUT, not -1. and (int) SCE_KERNEL_ERROR_WAIT_TIMEOUT is < 0. anyway here is the patch.
Code: Select all
--- SDL_syssem.org.c    Wed Oct  5 10:25:52 2005
+++ SDL_syssem.c        Wed Oct  5 10:39:29 2005
@@ -85,7 +85,7 @@
 int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
 {
        Uint32 *pTimeout;
-       int res;
+       unsigned int res;
        if (sem == NULL) {
                SDL_SetError("Passed a NULL sem");
@@ -108,16 +108,15 @@
        }
        res = sceKernelWaitSema(sem->semid, 1, pTimeout);
-       if (res < 0) {
-               SDL_SetError("WaitForSingleObject() failed");
-               return -1;
-       }
-
-       if (pTimeout != NULL && *pTimeout == SCE_KERNEL_ERROR_WAIT_TIMEOUT) {
-               return SDL_MUTEX_TIMEDOUT;
+       switch (res) {
+               case SCE_KERNEL_ERROR_OK:
+                       return 0;
+               case SCE_KERNEL_ERROR_WAIT_TIMEOUT:
+                       return SDL_MUTEX_TIMEDOUT;
+               default:
+                       SDL_SetError("WaitForSingleObject() failed");
+                       return -1;
        }
-
-       return 0;
 }
 int SDL_SemTryWait(SDL_sem *sem)