Mercurial > sdl-ios-xcode
diff src/cdrom/macosx/SDLOSXCAGuard.c @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | dc6b59e925a2 |
children | 99210400e8b9 |
line wrap: on
line diff
--- a/src/cdrom/macosx/SDLOSXCAGuard.c Thu Jul 06 18:01:37 2006 +0000 +++ b/src/cdrom/macosx/SDLOSXCAGuard.c Mon Jul 10 21:04:37 2006 +0000 @@ -91,14 +91,14 @@ SDLOSXCAGuard =============================================================================*/ -static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag) +static int +SDLOSXCAGuard_Lock(SDLOSXCAGuard * cag) { int theAnswer = 0; - - if(pthread_self() != cag->mOwner) - { + + if (pthread_self() != cag->mOwner) { OSStatus theError = pthread_mutex_lock(&cag->mMutex); - (void)theError; + (void) theError; assert(theError == 0); cag->mOwner = pthread_self(); theAnswer = 1; @@ -107,22 +107,24 @@ return theAnswer; } -static void SDLOSXCAGuard_Unlock(SDLOSXCAGuard *cag) +static void +SDLOSXCAGuard_Unlock(SDLOSXCAGuard * cag) { OSStatus theError; assert(pthread_self() == cag->mOwner); cag->mOwner = 0; theError = pthread_mutex_unlock(&cag->mMutex); - (void)theError; + (void) theError; assert(theError == 0); } -static int SDLOSXCAGuard_Try (SDLOSXCAGuard *cag, int *outWasLocked) +static int +SDLOSXCAGuard_Try(SDLOSXCAGuard * cag, int *outWasLocked) { int theAnswer = 0; *outWasLocked = 0; - + if (pthread_self() == cag->mOwner) { theAnswer = 1; *outWasLocked = 0; @@ -134,11 +136,12 @@ *outWasLocked = 1; } } - + return theAnswer; } -static void SDLOSXCAGuard_Wait(SDLOSXCAGuard *cag) +static void +SDLOSXCAGuard_Wait(SDLOSXCAGuard * cag) { OSStatus theError; assert(pthread_self() == cag->mOwner); @@ -146,54 +149,57 @@ cag->mOwner = 0; theError = pthread_cond_wait(&cag->mCondVar, &cag->mMutex); - (void)theError; + (void) theError; assert(theError == 0); cag->mOwner = pthread_self(); } -static void SDLOSXCAGuard_Notify(SDLOSXCAGuard *cag) +static void +SDLOSXCAGuard_Notify(SDLOSXCAGuard * cag) { OSStatus theError = pthread_cond_signal(&cag->mCondVar); - (void)theError; + (void) theError; assert(theError == 0); } -SDLOSXCAGuard *new_SDLOSXCAGuard(void) +SDLOSXCAGuard * +new_SDLOSXCAGuard(void) { OSStatus theError; - SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof (SDLOSXCAGuard)); + SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof(SDLOSXCAGuard)); if (cag == NULL) return NULL; - SDL_memset(cag, '\0', sizeof (*cag)); + SDL_memset(cag, '\0', sizeof(*cag)); - #define SET_SDLOSXCAGUARD_METHOD(m) cag->m = SDLOSXCAGuard_##m +#define SET_SDLOSXCAGUARD_METHOD(m) cag->m = SDLOSXCAGuard_##m SET_SDLOSXCAGUARD_METHOD(Lock); SET_SDLOSXCAGUARD_METHOD(Unlock); SET_SDLOSXCAGUARD_METHOD(Try); SET_SDLOSXCAGUARD_METHOD(Wait); SET_SDLOSXCAGUARD_METHOD(Notify); - #undef SET_SDLOSXCAGUARD_METHOD +#undef SET_SDLOSXCAGUARD_METHOD theError = pthread_mutex_init(&cag->mMutex, NULL); - (void)theError; + (void) theError; assert(theError == 0); - + theError = pthread_cond_init(&cag->mCondVar, NULL); - (void)theError; + (void) theError; assert(theError == 0); - + cag->mOwner = 0; return cag; } -void delete_SDLOSXCAGuard(SDLOSXCAGuard *cag) +void +delete_SDLOSXCAGuard(SDLOSXCAGuard * cag) { - if (cag != NULL) - { + if (cag != NULL) { pthread_mutex_destroy(&cag->mMutex); pthread_cond_destroy(&cag->mCondVar); SDL_free(cag); } } +/* vi: set ts=4 sw=4 expandtab: */