SDL_SemWaitTimeout(...) fix.

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
anhanguera
Posts: 31
Joined: Thu Aug 26, 2004 4:20 pm

SDL_SemWaitTimeout(...) fix.

Post by anhanguera »

hi,

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&#58;25&#58;52 2005
+++ SDL_syssem.c        Wed Oct  5 10&#58;39&#58;29 2005
@@ -85,7 +85,7 @@
 int SDL_SemWaitTimeout&#40;SDL_sem *sem, Uint32 timeout&#41;
 &#123;
        Uint32 *pTimeout;
-       int res;
+       unsigned int res;

        if &#40;sem == NULL&#41; &#123;
                SDL_SetError&#40;"Passed a NULL sem"&#41;;
@@ -108,16 +108,15 @@
        &#125;

        res = sceKernelWaitSema&#40;sem->semid, 1, pTimeout&#41;;
-       if &#40;res < 0&#41; &#123;
-               SDL_SetError&#40;"WaitForSingleObject&#40;&#41; failed"&#41;;
-               return -1;
-       &#125;
-
-       if &#40;pTimeout != NULL && *pTimeout == SCE_KERNEL_ERROR_WAIT_TIMEOUT&#41; &#123;
-               return SDL_MUTEX_TIMEDOUT;
+       switch &#40;res&#41; &#123;
+               case SCE_KERNEL_ERROR_OK&#58;
+                       return 0;
+               case SCE_KERNEL_ERROR_WAIT_TIMEOUT&#58;
+                       return SDL_MUTEX_TIMEDOUT;
+               default&#58;
+                       SDL_SetError&#40;"WaitForSingleObject&#40;&#41; failed"&#41;;
+                       return -1;
        &#125;
-
-       return 0;
 &#125;

 int SDL_SemTryWait&#40;SDL_sem *sem&#41;
alper "anhanguera" akcan.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Applied in rev 1119, thanks.
Post Reply