Mercurial > sdl-ios-xcode
diff src/thread/os2/SDL_syssem.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children |
line wrap: on
line diff
--- a/src/thread/os2/SDL_syssem.c Mon May 29 03:53:21 2006 +0000 +++ b/src/thread/os2/SDL_syssem.c Mon May 29 04:04:35 2006 +0000 @@ -42,105 +42,105 @@ /* Create a semaphore */ DECLSPEC SDL_sem *SDLCALL -SDL_CreateSemaphore (Uint32 initial_value) +SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem; ULONG ulrc; /* Allocate sem memory */ - sem = (SDL_sem *) SDL_malloc (sizeof (*sem)); + sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); if (sem) { /* Create the mutex semaphore */ - ulrc = DosCreateMutexSem (NULL, &(sem->id), 0, TRUE); + ulrc = DosCreateMutexSem(NULL, &(sem->id), 0, TRUE); if (ulrc) { - SDL_SetError ("Couldn't create semaphore"); - SDL_free (sem); + SDL_SetError("Couldn't create semaphore"); + SDL_free(sem); sem = NULL; } else { - DosCreateEventSem (NULL, &(sem->changed), 0, FALSE); + DosCreateEventSem(NULL, &(sem->changed), 0, FALSE); sem->value = initial_value; - DosReleaseMutexSem (sem->id); + DosReleaseMutexSem(sem->id); } } else { - SDL_OutOfMemory (); + SDL_OutOfMemory(); } return (sem); } /* Free the semaphore */ DECLSPEC void SDLCALL -SDL_DestroySemaphore (SDL_sem * sem) +SDL_DestroySemaphore(SDL_sem * sem) { if (sem) { if (sem->id) { - DosCloseEventSem (sem->changed); - DosCloseMutexSem (sem->id); + DosCloseEventSem(sem->changed); + DosCloseMutexSem(sem->id); sem->id = 0; } - SDL_free (sem); + SDL_free(sem); } } DECLSPEC int SDLCALL -SDL_SemWaitTimeout (SDL_sem * sem, Uint32 timeout) +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { ULONG ulrc; if (!sem) { - SDL_SetError ("Passed a NULL sem"); + SDL_SetError("Passed a NULL sem"); return -1; } if (timeout == SDL_MUTEX_MAXWAIT) { while (1) { - ulrc = DosRequestMutexSem (sem->id, SEM_INDEFINITE_WAIT); + ulrc = DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT); if (ulrc) { /* if error waiting mutex */ - SDL_SetError ("DosRequestMutexSem() failed"); + SDL_SetError("DosRequestMutexSem() failed"); return -1; } else if (sem->value) { sem->value--; - DosReleaseMutexSem (sem->id); + DosReleaseMutexSem(sem->id); return 0; } else { ULONG ulPostCount; - DosResetEventSem (sem->changed, &ulPostCount); - DosReleaseMutexSem (sem->id); + DosResetEventSem(sem->changed, &ulPostCount); + DosReleaseMutexSem(sem->id); /* continue waiting until somebody posts the semaphore */ - DosWaitEventSem (sem->changed, SEM_INDEFINITE_WAIT); + DosWaitEventSem(sem->changed, SEM_INDEFINITE_WAIT); } } } else if (timeout == 0) { - ulrc = DosRequestMutexSem (sem->id, SEM_INDEFINITE_WAIT); + ulrc = DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT); if (ulrc == NO_ERROR) { if (sem->value) { sem->value--; - DosReleaseMutexSem (sem->id); + DosReleaseMutexSem(sem->id); return 0; } else { - DosReleaseMutexSem (sem->id); + DosReleaseMutexSem(sem->id); return SDL_MUTEX_TIMEDOUT; } } else { - SDL_SetError ("DosRequestMutexSem() failed"); + SDL_SetError("DosRequestMutexSem() failed"); return -1; } } else { - ulrc = DosRequestMutexSem (sem->id, SEM_INDEFINITE_WAIT); + ulrc = DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT); if (ulrc) { /* if error waiting mutex */ - SDL_SetError ("DosRequestMutexSem() failed"); + SDL_SetError("DosRequestMutexSem() failed"); return -1; } else if (sem->value) { sem->value--; - DosReleaseMutexSem (sem->id); + DosReleaseMutexSem(sem->id); return 0; } else { ULONG ulPostCount; - DosResetEventSem (sem->changed, &ulPostCount); - DosReleaseMutexSem (sem->id); + DosResetEventSem(sem->changed, &ulPostCount); + DosReleaseMutexSem(sem->id); /* continue waiting until somebody posts the semaphore */ - ulrc = DosWaitEventSem (sem->changed, timeout); + ulrc = DosWaitEventSem(sem->changed, timeout); if (ulrc == NO_ERROR) return 0; else @@ -152,42 +152,42 @@ } DECLSPEC int SDLCALL -SDL_SemTryWait (SDL_sem * sem) +SDL_SemTryWait(SDL_sem * sem) { - return SDL_SemWaitTimeout (sem, 0); + return SDL_SemWaitTimeout(sem, 0); } DECLSPEC int SDLCALL -SDL_SemWait (SDL_sem * sem) +SDL_SemWait(SDL_sem * sem) { - return SDL_SemWaitTimeout (sem, SDL_MUTEX_MAXWAIT); + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); } /* Returns the current count of the semaphore */ DECLSPEC Uint32 SDLCALL -SDL_SemValue (SDL_sem * sem) +SDL_SemValue(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL sem"); + SDL_SetError("Passed a NULL sem"); return 0; } return sem->value; } DECLSPEC int SDLCALL -SDL_SemPost (SDL_sem * sem) +SDL_SemPost(SDL_sem * sem) { if (!sem) { - SDL_SetError ("Passed a NULL sem"); + SDL_SetError("Passed a NULL sem"); return -1; } - if (DosRequestMutexSem (sem->id, SEM_INDEFINITE_WAIT)) { - SDL_SetError ("DosRequestMutexSem() failed"); + if (DosRequestMutexSem(sem->id, SEM_INDEFINITE_WAIT)) { + SDL_SetError("DosRequestMutexSem() failed"); return -1; } sem->value++; - DosPostEventSem (sem->changed); - DosReleaseMutexSem (sem->id); + DosPostEventSem(sem->changed); + DosReleaseMutexSem(sem->id); return 0; }