Mercurial > sdl-ios-xcode
diff src/cdrom/macosx/SDLOSXCAGuard.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | dc6b59e925a2 |
children | 4da1ee79c9af |
line wrap: on
line diff
--- a/src/cdrom/macosx/SDLOSXCAGuard.c Sun May 21 17:27:13 2006 +0000 +++ b/src/cdrom/macosx/SDLOSXCAGuard.c Sun May 28 13:04:16 2006 +0000 @@ -91,109 +91,116 @@ SDLOSXCAGuard =============================================================================*/ -static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag) +static int +SDLOSXCAGuard_Lock (SDLOSXCAGuard * cag) { int theAnswer = 0; - - if(pthread_self() != cag->mOwner) - { - OSStatus theError = pthread_mutex_lock(&cag->mMutex); - (void)theError; - assert(theError == 0); - cag->mOwner = pthread_self(); + + if (pthread_self () != cag->mOwner) { + OSStatus theError = pthread_mutex_lock (&cag->mMutex); + (void) theError; + assert (theError == 0); + cag->mOwner = pthread_self (); theAnswer = 1; } return theAnswer; } -static void SDLOSXCAGuard_Unlock(SDLOSXCAGuard *cag) +static void +SDLOSXCAGuard_Unlock (SDLOSXCAGuard * cag) { OSStatus theError; - assert(pthread_self() == cag->mOwner); + assert (pthread_self () == cag->mOwner); cag->mOwner = 0; - theError = pthread_mutex_unlock(&cag->mMutex); - (void)theError; - assert(theError == 0); + theError = pthread_mutex_unlock (&cag->mMutex); + (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) { + + if (pthread_self () == cag->mOwner) { theAnswer = 1; *outWasLocked = 0; } else { - OSStatus theError = pthread_mutex_trylock(&cag->mMutex); + OSStatus theError = pthread_mutex_trylock (&cag->mMutex); if (theError == 0) { - cag->mOwner = pthread_self(); + cag->mOwner = pthread_self (); theAnswer = 1; *outWasLocked = 1; } } - + return theAnswer; } -static void SDLOSXCAGuard_Wait(SDLOSXCAGuard *cag) +static void +SDLOSXCAGuard_Wait (SDLOSXCAGuard * cag) { OSStatus theError; - assert(pthread_self() == cag->mOwner); + assert (pthread_self () == cag->mOwner); cag->mOwner = 0; - theError = pthread_cond_wait(&cag->mCondVar, &cag->mMutex); - (void)theError; - assert(theError == 0); - cag->mOwner = pthread_self(); + theError = pthread_cond_wait (&cag->mCondVar, &cag->mMutex); + (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; - assert(theError == 0); + OSStatus theError = pthread_cond_signal (&cag->mCondVar); + (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 - SET_SDLOSXCAGUARD_METHOD(Lock); - SET_SDLOSXCAGUARD_METHOD(Unlock); - SET_SDLOSXCAGUARD_METHOD(Try); - SET_SDLOSXCAGUARD_METHOD(Wait); - SET_SDLOSXCAGUARD_METHOD(Notify); - #undef SET_SDLOSXCAGUARD_METHOD +#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 - theError = pthread_mutex_init(&cag->mMutex, NULL); - (void)theError; - assert(theError == 0); - - theError = pthread_cond_init(&cag->mCondVar, NULL); - (void)theError; - assert(theError == 0); - + theError = pthread_mutex_init (&cag->mMutex, NULL); + (void) theError; + assert (theError == 0); + + theError = pthread_cond_init (&cag->mCondVar, NULL); + (void) theError; + assert (theError == 0); + cag->mOwner = 0; return cag; } -void delete_SDLOSXCAGuard(SDLOSXCAGuard *cag) +void +delete_SDLOSXCAGuard (SDLOSXCAGuard * cag) { - if (cag != NULL) - { - pthread_mutex_destroy(&cag->mMutex); - pthread_cond_destroy(&cag->mCondVar); - SDL_free(cag); + if (cag != NULL) { + pthread_mutex_destroy (&cag->mMutex); + pthread_cond_destroy (&cag->mCondVar); + SDL_free (cag); } } +/* vi: set ts=4 sw=4 expandtab: */