blob: 5da7579b10df689c70b6a138bc64089a1fb153a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "seh_excn.h"
/*
* Exception / signal handlers.
*/
#if defined(__MINGW32__)
jmp_buf seh_unwind_to;
unsigned long seh_excn_code; /* variable used to communicate what kind of exception we've caught;nice. */
EXCEPTION_DISPOSITION
catchDivZero(struct _EXCEPTION_RECORD* rec,
void* arg1 __attribute__((unused)),
struct _CONTEXT* ctxt __attribute__((unused)),
void* arg2 __attribute__((unused)))
{
if ((rec->ExceptionFlags & EH_UNWINDING) != 0) {
// When the system unwinds the SEH stack after having handled an excn,
// return immediately.
return ExceptionContinueSearch;
}
switch (rec->ExceptionCode) {
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
case EXCEPTION_INT_DIVIDE_BY_ZERO:
seh_excn_code = 0;
longjmp(seh_unwind_to, rec->ExceptionCode);
return ExceptionContinueExecution;
case EXCEPTION_STACK_OVERFLOW:
seh_excn_code = 1;
longjmp(seh_unwind_to, rec->ExceptionCode);
return ExceptionContinueExecution;
case EXCEPTION_ACCESS_VIOLATION:
seh_excn_code = 2;
longjmp(seh_unwind_to, rec->ExceptionCode);
return ExceptionContinueExecution;
longjmp(seh_unwind_to, rec->ExceptionCode);
return ExceptionContinueExecution;
default: ;
}
return ExceptionContinueSearch;
}
#endif
|