1/**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the mingw-w64 runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6#ifndef _INC_EXCPT
7#define _INC_EXCPT
8
9#include <crtdefs.h>
10
11#pragma pack(push,_CRT_PACKING)
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17 struct _EXCEPTION_POINTERS;
18
19typedef enum _EXCEPTION_DISPOSITION {
20 ExceptionContinueExecution = 0,
21 ExceptionContinueSearch = 1,
22 ExceptionNestedException = 2,
23 ExceptionCollidedUnwind = 3
24} EXCEPTION_DISPOSITION;
25
26#if (defined(_X86_) && !defined(__x86_64))
27 struct _EXCEPTION_RECORD;
28 struct _CONTEXT;
29
30 EXCEPTION_DISPOSITION __cdecl _except_handler(struct _EXCEPTION_RECORD *_ExceptionRecord,void *_EstablisherFrame,struct _CONTEXT *_ContextRecord,void *_DispatcherContext);
31#elif defined(__ia64__)
32
33 typedef struct _EXCEPTION_POINTERS *Exception_info_ptr;
34 struct _EXCEPTION_RECORD;
35 struct _CONTEXT;
36 struct _DISPATCHER_CONTEXT;
37
38 __MINGW_EXTENSION _CRTIMP EXCEPTION_DISPOSITION __cdecl __C_specific_handler (struct _EXCEPTION_RECORD *_ExceptionRecord,unsigned __int64 _MemoryStackFp,unsigned __int64 _BackingStoreFp,struct _CONTEXT *_ContextRecord,struct _DISPATCHER_CONTEXT *_DispatcherContext,unsigned __int64 _GlobalPointer);
39#elif defined(__x86_64) || defined(__arm__) || defined(__aarch64__)
40
41 struct _EXCEPTION_RECORD;
42 struct _CONTEXT;
43 struct _DISPATCHER_CONTEXT;
44
45 __MINGW_EXTENSION _CRTIMP EXCEPTION_DISPOSITION __cdecl __C_specific_handler (struct _EXCEPTION_RECORD *_ExceptionRecord, void *_EstablisherFrame, struct _CONTEXT *_ContextRecord, struct _DISPATCHER_CONTEXT *_DispatcherContext);
46#endif
47
48#define GetExceptionCode _exception_code
49#define exception_code _exception_code
50#define GetExceptionInformation() ((struct _EXCEPTION_POINTERS *)_exception_info())
51#define exception_info() ((struct _EXCEPTION_POINTERS *)_exception_info())
52#define AbnormalTermination _abnormal_termination
53#define abnormal_termination _abnormal_termination
54
55 unsigned long __cdecl _exception_code(void);
56 void *__cdecl _exception_info(void);
57 int __cdecl _abnormal_termination(void);
58
59#define EXCEPTION_EXECUTE_HANDLER 1
60#define EXCEPTION_CONTINUE_SEARCH 0
61#define EXCEPTION_CONTINUE_EXECUTION -1
62
63 /* CRT stuff */
64 typedef void (__cdecl * _PHNDLR)(int);
65
66 struct _XCPT_ACTION {
67 unsigned long XcptNum;
68 int SigNum;
69 _PHNDLR XcptAction;
70 };
71
72 extern struct _XCPT_ACTION _XcptActTab[];
73 extern int _XcptActTabCount;
74 extern int _XcptActTabSize;
75 extern int _First_FPE_Indx;
76 extern int _Num_FPE;
77
78 int __cdecl __CppXcptFilter(unsigned long _ExceptionNum,struct _EXCEPTION_POINTERS * _ExceptionPtr);
79 int __cdecl _XcptFilter(unsigned long _ExceptionNum,struct _EXCEPTION_POINTERS * _ExceptionPtr);
80
81 /*
82 * The type of function that is expected as an exception handler to be
83 * installed with __try1.
84 */
85 typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER)(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
86
87#if !defined (HAVE_NO_SEH) && defined (__MINGW_EXCPT_DEFINE_PSDK)
88 /*
89 * This is not entirely necessary, but it is the structure installed by
90 * the __try1 primitive below.
91 */
92 typedef struct _EXCEPTION_REGISTRATION {
93 struct _EXCEPTION_REGISTRATION *prev;
94 EXCEPTION_DISPOSITION (*handler)(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
95 } EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION;
96
97 typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD;
98 typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD;
99#endif
100
101#if (defined(_X86_) && !defined(__x86_64))
102#define __try1(pHandler) \
103 __asm__ __volatile__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler));
104
105#define __except1 \
106 __asm__ __volatile__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \
107 : : : "%eax");
108#elif defined(__x86_64)
109#define __try1(pHandler) \
110 __asm__ __volatile__ ("\t.l_startw:\n" \
111 "\t.seh_handler __C_specific_handler, @except\n" \
112 "\t.seh_handlerdata\n" \
113 "\t.long 1\n" \
114 "\t.rva .l_startw, .l_endw, " __MINGW64_STRINGIFY(__MINGW_USYMBOL(pHandler)) " ,.l_endw\n" \
115 "\t.text" \
116 );
117#define __except1 \
118 asm ("\tnop\n" \
119 "\t.l_endw: nop\n");
120#else
121#define __try1(pHandler)
122#define __except1
123#endif
124
125#ifdef __cplusplus
126}
127#endif
128
129#pragma pack(pop)
130#endif