src/SDL.c
changeset 1487 dc6b59e925a2
parent 1465 8dfa9a6d69a5
child 1662 782fd950bd46
child 1895 c121d94672cb
child 3975 e85e65aec22f
equal deleted inserted replaced
1486:9d77fc9d0ace 1487:dc6b59e925a2
   251 {
   251 {
   252 	return(&version);
   252 	return(&version);
   253 }
   253 }
   254 
   254 
   255 #if defined(__OS2__)
   255 #if defined(__OS2__)
   256 // Building for OS/2
   256 /* Building for OS/2 */
   257 #ifdef __WATCOMC__
   257 #ifdef __WATCOMC__
   258 
   258 
   259 #define INCL_DOSERRORS
   259 #define INCL_DOSERRORS
   260 #define INCL_DOSEXCEPTIONS
   260 #define INCL_DOSEXCEPTIONS
   261 #include <os2.h>
   261 #include <os2.h>
   262 
   262 
   263 // Exception handler to prevent the Audio thread hanging, making a zombie process!
   263 /* Exception handler to prevent the Audio thread hanging, making a zombie process! */
   264 ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
   264 ULONG _System SDL_Main_ExceptionHandler(PEXCEPTIONREPORTRECORD pERepRec,
   265                                         PEXCEPTIONREGISTRATIONRECORD pERegRec,
   265                                         PEXCEPTIONREGISTRATIONRECORD pERegRec,
   266                                         PCONTEXTRECORD pCtxRec,
   266                                         PCONTEXTRECORD pCtxRec,
   267                                         PVOID p)
   267                                         PVOID p)
   268 {
   268 {
   271   if (pERepRec->fHandlerFlags & EH_UNWINDING)
   271   if (pERepRec->fHandlerFlags & EH_UNWINDING)
   272     return XCPT_CONTINUE_SEARCH;
   272     return XCPT_CONTINUE_SEARCH;
   273   if (pERepRec->fHandlerFlags & EH_NESTED_CALL)
   273   if (pERepRec->fHandlerFlags & EH_NESTED_CALL)
   274     return XCPT_CONTINUE_SEARCH;
   274     return XCPT_CONTINUE_SEARCH;
   275 
   275 
   276   // Do cleanup at every fatal exception!
   276   /* Do cleanup at every fatal exception! */
   277   if (((pERepRec->ExceptionNum & XCPT_SEVERITY_CODE) == XCPT_FATAL_EXCEPTION) &&
   277   if (((pERepRec->ExceptionNum & XCPT_SEVERITY_CODE) == XCPT_FATAL_EXCEPTION) &&
   278       (pERepRec->ExceptionNum != XCPT_BREAKPOINT) &&
   278       (pERepRec->ExceptionNum != XCPT_BREAKPOINT) &&
   279       (pERepRec->ExceptionNum != XCPT_SINGLE_STEP)
   279       (pERepRec->ExceptionNum != XCPT_SINGLE_STEP)
   280      )
   280      )
   281   {
   281   {
   282     if (SDL_initialized & SDL_INIT_AUDIO)
   282     if (SDL_initialized & SDL_INIT_AUDIO)
   283     {
   283     {
   284       // This removes the zombie audio thread in case of emergency.
   284       /* This removes the zombie audio thread in case of emergency. */
   285 #ifdef DEBUG_BUILD
   285 #ifdef DEBUG_BUILD
   286       printf("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n");
   286       printf("[SDL_Main_ExceptionHandler] : Calling SDL_CloseAudio()!\n");
   287 #endif
   287 #endif
   288       SDL_CloseAudio();
   288       SDL_CloseAudio();
   289     }
   289     }
   292 }
   292 }
   293 
   293 
   294 
   294 
   295 EXCEPTIONREGISTRATIONRECORD SDL_Main_xcpthand = {0, SDL_Main_ExceptionHandler};
   295 EXCEPTIONREGISTRATIONRECORD SDL_Main_xcpthand = {0, SDL_Main_ExceptionHandler};
   296 
   296 
   297 // The main DLL entry for DLL Initialization and Uninitialization:
   297 /* The main DLL entry for DLL Initialization and Uninitialization: */
   298 unsigned _System LibMain(unsigned hmod, unsigned termination)
   298 unsigned _System LibMain(unsigned hmod, unsigned termination)
   299 {
   299 {
   300   if (termination)
   300   if (termination)
   301   {
   301   {
   302 #ifdef DEBUG_BUILD
   302 #ifdef DEBUG_BUILD
   303 //    printf("[SDL DLL Unintialization] : Removing exception handler\n");
   303 /*    printf("[SDL DLL Unintialization] : Removing exception handler\n"); */
   304 #endif
   304 #endif
   305     DosUnsetExceptionHandler(&SDL_Main_xcpthand);
   305     DosUnsetExceptionHandler(&SDL_Main_xcpthand);
   306     return 1;
   306     return 1;
   307   } else
   307   } else
   308   {
   308   {
   309 #ifdef DEBUG_BUILD
   309 #ifdef DEBUG_BUILD
   310     // Make stdout and stderr unbuffered!
   310     /* Make stdout and stderr unbuffered! */
   311     setbuf(stdout, NULL);
   311     setbuf(stdout, NULL);
   312     setbuf(stderr, NULL);
   312     setbuf(stderr, NULL);
   313 #endif
   313 #endif
   314     // Fire up exception handler
   314     /* Fire up exception handler */
   315 #ifdef DEBUG_BUILD
   315 #ifdef DEBUG_BUILD
   316 //    printf("[SDL DLL Initialization] : Setting exception handler\n");
   316 /*    printf("[SDL DLL Initialization] : Setting exception handler\n"); */
   317 #endif
   317 #endif
   318     // Set exception handler
   318     /* Set exception handler */
   319     DosSetExceptionHandler(&SDL_Main_xcpthand);
   319     DosSetExceptionHandler(&SDL_Main_xcpthand);
   320 
   320 
   321     return 1;
   321     return 1;
   322   }
   322   }
   323 }
   323 }