Mercurial > sdl-ios-xcode
comparison src/SDL.c @ 1190:173c063d4f55
OS/2 port!
This was mostly, if not entirely, written by "Doodle" and "Caetano":
doodle@scenergy.dfmk.hu
daniel@caetano.eng.br
--ryan.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 23 Nov 2005 07:29:56 +0000 |
parents | b8d311d90021 |
children | c9b51268668f |
comparison
equal
deleted
inserted
replaced
1189:c96b326b90ba | 1190:173c063d4f55 |
---|---|
218 } | 218 } |
219 | 219 |
220 void SDL_Quit(void) | 220 void SDL_Quit(void) |
221 { | 221 { |
222 /* Quit all subsystems */ | 222 /* Quit all subsystems */ |
223 #ifdef DEBUG_BUILD | |
224 printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); fflush(stdout); | |
225 #endif | |
223 SDL_QuitSubSystem(SDL_INIT_EVERYTHING); | 226 SDL_QuitSubSystem(SDL_INIT_EVERYTHING); |
224 | 227 |
225 #ifdef CHECK_LEAKS | 228 #ifdef CHECK_LEAKS |
229 #ifdef DEBUG_BUILD | |
230 printf("[SDL_Quit] : CHECK_LEAKS\n"); fflush(stdout); | |
231 #endif | |
232 | |
226 /* Print the number of surfaces not freed */ | 233 /* Print the number of surfaces not freed */ |
227 if ( surfaces_allocated != 0 ) { | 234 if ( surfaces_allocated != 0 ) { |
228 fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n", | 235 fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n", |
229 surfaces_allocated); | 236 surfaces_allocated); |
230 } | 237 } |
231 #endif | 238 #endif |
239 #ifdef DEBUG_BUILD | |
240 printf("[SDL_Quit] : SDL_UninstallParachute()\n"); fflush(stdout); | |
241 #endif | |
232 | 242 |
233 /* Uninstall any parachute signal handlers */ | 243 /* Uninstall any parachute signal handlers */ |
234 SDL_UninstallParachute(); | 244 SDL_UninstallParachute(); |
235 | 245 |
236 #if !defined(DISABLE_THREADS) && defined(ENABLE_PTH) | 246 #if !defined(DISABLE_THREADS) && defined(ENABLE_PTH) |
237 pth_kill(); | 247 pth_kill(); |
238 #endif | 248 #endif |
249 #ifdef DEBUG_BUILD | |
250 printf("[SDL_Quit] : Returning!\n"); fflush(stdout); | |
251 #endif | |
252 | |
239 } | 253 } |
240 | 254 |
241 /* Return the library version number */ | 255 /* Return the library version number */ |
242 const SDL_version * SDL_Linked_Version(void) | 256 const SDL_version * SDL_Linked_Version(void) |
243 { | 257 { |
244 return(&version); | 258 return(&version); |
245 } | 259 } |
246 | 260 |
261 #ifndef __OS2__ | |
247 #if defined(_WIN32_WCE) || (defined(__WATCOMC__) && defined(BUILD_DLL)) | 262 #if defined(_WIN32_WCE) || (defined(__WATCOMC__) && defined(BUILD_DLL)) |
248 /* Need to include DllMain() on Windows CE and Watcom C for some reason.. */ | 263 /* Need to include DllMain() on Windows CE and Watcom C for some reason.. */ |
249 #include <windows.h> | 264 #include <windows.h> |
250 | 265 |
251 BOOL APIENTRY DllMain( HANDLE hModule, | 266 BOOL APIENTRY DllMain( HANDLE hModule, |
260 break; | 275 break; |
261 } | 276 } |
262 return TRUE; | 277 return TRUE; |
263 } | 278 } |
264 #endif /* _WIN32_WCE and building DLL with Watcom C */ | 279 #endif /* _WIN32_WCE and building DLL with Watcom C */ |
280 #else | |
281 // Building for OS/2 | |
282 #ifdef __WATCOMC__ | |
283 | |
284 #define INCL_DOSERRORS | |
285 #define INCL_DOSEXCEPTIONS | |
286 #include <os2.h> | |
287 | |
288 // Exception handler to prevent the Audio thread hanging, making a zombie process! | |
289 ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec, | |
290 PEXCEPTIONREGISTRATIONRECORD pERegRec, | |
291 PCONTEXTRECORD pCtxRec, | |
292 PVOID p) | |
293 { | |
294 if (pERepRec->fHandlerFlags & EH_EXIT_UNWIND) | |
295 return XCPT_CONTINUE_SEARCH; | |
296 if (pERepRec->fHandlerFlags & EH_UNWINDING) | |
297 return XCPT_CONTINUE_SEARCH; | |
298 if (pERepRec->fHandlerFlags & EH_NESTED_CALL) | |
299 return XCPT_CONTINUE_SEARCH; | |
300 | |
301 // Do cleanup at every fatal exception! | |
302 if (((pERepRec->ExceptionNum & XCPT_SEVERITY_CODE) == XCPT_FATAL_EXCEPTION) && | |
303 (pERepRec->ExceptionNum != XCPT_BREAKPOINT) && | |
304 (pERepRec->ExceptionNum != XCPT_SINGLE_STEP) | |
305 ) | |
306 { | |
307 if (SDL_initialized & SDL_INIT_AUDIO) | |
308 { | |
309 // This removes the zombie audio thread in case of emergency. | |
310 #ifdef DEBUG_BUILD | |
311 printf("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n"); | |
312 #endif | |
313 SDL_CloseAudio(); | |
314 } | |
315 } | |
316 return (XCPT_CONTINUE_SEARCH); | |
317 } | |
318 | |
319 | |
320 EXCEPTIONREGISTRATIONRECORD SDL_Main_xcpthand = {0, SDL_Main_ExceptionHandler}; | |
321 | |
322 // The main DLL entry for DLL Initialization and Uninitialization: | |
323 unsigned _System LibMain(unsigned hmod, unsigned termination) | |
324 { | |
325 if (termination) | |
326 { | |
327 #ifdef DEBUG_BUILD | |
328 // printf("[SDL DLL Unintialization] : Removing exception handler\n"); | |
329 #endif | |
330 DosUnsetExceptionHandler(&SDL_Main_xcpthand); | |
331 return 1; | |
332 } else | |
333 { | |
334 #ifdef DEBUG_BUILD | |
335 // Make stdout and stderr unbuffered! | |
336 setbuf(stdout, NULL); | |
337 setbuf(stderr, NULL); | |
338 #endif | |
339 // Fire up exception handler | |
340 #ifdef DEBUG_BUILD | |
341 // printf("[SDL DLL Initialization] : Setting exception handler\n"); | |
342 #endif | |
343 // Set exception handler | |
344 DosSetExceptionHandler(&SDL_Main_xcpthand); | |
345 | |
346 return 1; | |
347 } | |
348 } | |
349 | |
350 #endif | |
351 #endif |