forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SDL_SemWaitTimeout(...) fix.

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
anhanguera



Joined: 26 Aug 2004
Posts: 31

PostPosted: Wed Oct 05, 2005 5:36 pm    Post subject: SDL_SemWaitTimeout(...) fix. Reply with quote

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:

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


alper "anhanguera" akcan.
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Wed Oct 05, 2005 6:25 pm    Post subject: Reply with quote

Applied in rev 1119, thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group