4 * Exception / signal handlers.
6 #if defined(__MINGW32__)
8 unsigned long seh_excn_code; /* variable used to communicate what kind of exception we've caught;nice. */
11 catchDivZero(struct _EXCEPTION_RECORD* rec,
12 void* arg1 __attribute__((unused)),
13 struct _CONTEXT* ctxt __attribute__((unused)),
14 void* arg2 __attribute__((unused)))
16 if ((rec->ExceptionFlags & EH_UNWINDING) != 0) {
17 // When the system unwinds the SEH stack after having handled an excn,
18 // return immediately.
19 return ExceptionContinueSearch;
21 switch (rec->ExceptionCode) {
22 case EXCEPTION_FLT_DIVIDE_BY_ZERO:
23 case EXCEPTION_INT_DIVIDE_BY_ZERO:
25 longjmp(seh_unwind_to, rec->ExceptionCode);
26 return ExceptionContinueExecution;
27 case EXCEPTION_STACK_OVERFLOW:
29 longjmp(seh_unwind_to, rec->ExceptionCode);
30 return ExceptionContinueExecution;
31 case EXCEPTION_ACCESS_VIOLATION:
33 longjmp(seh_unwind_to, rec->ExceptionCode);
34 return ExceptionContinueExecution;
35 longjmp(seh_unwind_to, rec->ExceptionCode);
36 return ExceptionContinueExecution;
39 return ExceptionContinueSearch;