comparison src/cdrom/macosx/SDLOSXCAGuard.c @ 1487:dc6b59e925a2

Cleaning up warnings on MacOS X
author Sam Lantinga <slouken@libsdl.org>
date Thu, 09 Mar 2006 06:33:21 +0000
parents d910939febfa
children 782fd950bd46 c121d94672cb a1b03ba2fcd0
comparison
equal deleted inserted replaced
1486:9d77fc9d0ace 1487:dc6b59e925a2
64 /*============================================================================= 64 /*=============================================================================
65 CAGuard.cp 65 CAGuard.cp
66 66
67 =============================================================================*/ 67 =============================================================================*/
68 68
69 //============================================================================= 69 /*=============================================================================
70 // Includes 70 Includes
71 //============================================================================= 71 =============================================================================*/
72 72
73 /* 73 /*
74 #include <stdio.h> 74 #include <stdio.h>
75 #include <stdlib.h> 75 #include <stdlib.h>
76 #include <string.h> 76 #include <string.h>
77 */ 77 */
78 #include "SDL_stdinc.h" 78 #include "SDL_stdinc.h"
79 79
80 //#define NDEBUG 1 80 /*#define NDEBUG 1*/
81 /* 81 /*
82 #include <assert.h> 82 #include <assert.h>
83 */ 83 */
84 #define assert(X) 84 #define assert(X)
85 85
86 86
87 #include "SDLOSXCAGuard.h" 87 #include "SDLOSXCAGuard.h"
88 88
89 //#warning Need a try-based Locker too 89 /*#warning Need a try-based Locker too*/
90 //============================================================================= 90 /*=============================================================================
91 // SDLOSXCAGuard 91 SDLOSXCAGuard
92 //============================================================================= 92 =============================================================================*/
93 93
94 static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag) 94 static int SDLOSXCAGuard_Lock(SDLOSXCAGuard *cag)
95 { 95 {
96 int theAnswer = 0; 96 int theAnswer = 0;
97 97
98 if(pthread_self() != cag->mOwner) 98 if(pthread_self() != cag->mOwner)
99 { 99 {
100 OSStatus theError = pthread_mutex_lock(&cag->mMutex); 100 OSStatus theError = pthread_mutex_lock(&cag->mMutex);
101 (void)theError;
101 assert(theError == 0); 102 assert(theError == 0);
102 cag->mOwner = pthread_self(); 103 cag->mOwner = pthread_self();
103 theAnswer = 1; 104 theAnswer = 1;
104 } 105 }
105 106
106 return theAnswer; 107 return theAnswer;
107 } 108 }
108 109
109 static void SDLOSXCAGuard_Unlock(SDLOSXCAGuard *cag) 110 static void SDLOSXCAGuard_Unlock(SDLOSXCAGuard *cag)
110 { 111 {
112 OSStatus theError;
111 assert(pthread_self() == cag->mOwner); 113 assert(pthread_self() == cag->mOwner);
112 114
113 cag->mOwner = 0; 115 cag->mOwner = 0;
114 OSStatus theError = pthread_mutex_unlock(&cag->mMutex); 116 theError = pthread_mutex_unlock(&cag->mMutex);
117 (void)theError;
115 assert(theError == 0); 118 assert(theError == 0);
116 } 119 }
117 120
118 static int SDLOSXCAGuard_Try (SDLOSXCAGuard *cag, int *outWasLocked) 121 static int SDLOSXCAGuard_Try (SDLOSXCAGuard *cag, int *outWasLocked)
119 { 122 {
135 return theAnswer; 138 return theAnswer;
136 } 139 }
137 140
138 static void SDLOSXCAGuard_Wait(SDLOSXCAGuard *cag) 141 static void SDLOSXCAGuard_Wait(SDLOSXCAGuard *cag)
139 { 142 {
143 OSStatus theError;
140 assert(pthread_self() == cag->mOwner); 144 assert(pthread_self() == cag->mOwner);
141 145
142 cag->mOwner = 0; 146 cag->mOwner = 0;
143 147
144 OSStatus theError = pthread_cond_wait(&cag->mCondVar, &cag->mMutex); 148 theError = pthread_cond_wait(&cag->mCondVar, &cag->mMutex);
149 (void)theError;
145 assert(theError == 0); 150 assert(theError == 0);
146 cag->mOwner = pthread_self(); 151 cag->mOwner = pthread_self();
147 } 152 }
148 153
149 static void SDLOSXCAGuard_Notify(SDLOSXCAGuard *cag) 154 static void SDLOSXCAGuard_Notify(SDLOSXCAGuard *cag)
150 { 155 {
151 OSStatus theError = pthread_cond_signal(&cag->mCondVar); 156 OSStatus theError = pthread_cond_signal(&cag->mCondVar);
157 (void)theError;
152 assert(theError == 0); 158 assert(theError == 0);
153 } 159 }
154 160
155 161
156 SDLOSXCAGuard *new_SDLOSXCAGuard(void) 162 SDLOSXCAGuard *new_SDLOSXCAGuard(void)
157 { 163 {
164 OSStatus theError;
158 SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof (SDLOSXCAGuard)); 165 SDLOSXCAGuard *cag = (SDLOSXCAGuard *) SDL_malloc(sizeof (SDLOSXCAGuard));
159 if (cag == NULL) 166 if (cag == NULL)
160 return NULL; 167 return NULL;
161 SDL_memset(cag, '\0', sizeof (*cag)); 168 SDL_memset(cag, '\0', sizeof (*cag));
162 169
166 SET_SDLOSXCAGUARD_METHOD(Try); 173 SET_SDLOSXCAGUARD_METHOD(Try);
167 SET_SDLOSXCAGUARD_METHOD(Wait); 174 SET_SDLOSXCAGUARD_METHOD(Wait);
168 SET_SDLOSXCAGUARD_METHOD(Notify); 175 SET_SDLOSXCAGUARD_METHOD(Notify);
169 #undef SET_SDLOSXCAGUARD_METHOD 176 #undef SET_SDLOSXCAGUARD_METHOD
170 177
171 OSStatus theError = pthread_mutex_init(&cag->mMutex, NULL); 178 theError = pthread_mutex_init(&cag->mMutex, NULL);
179 (void)theError;
172 assert(theError == 0); 180 assert(theError == 0);
173 181
174 theError = pthread_cond_init(&cag->mCondVar, NULL); 182 theError = pthread_cond_init(&cag->mCondVar, NULL);
183 (void)theError;
175 assert(theError == 0); 184 assert(theError == 0);
176 185
177 cag->mOwner = 0; 186 cag->mOwner = 0;
178 return cag; 187 return cag;
179 } 188 }