Reactos
at master 159 lines 4.4 kB view raw
1/** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the w64 mingw-runtime package. 4 * No warranty is given; refer to the file DISCLAIMER within this package. 5 */ 6#ifndef _INC_EXCPT 7#define _INC_EXCPT 8 9#include <vcruntime.h> 10 11#if !defined(RC_INVOKED) 12#include <pseh/pseh2.h> 13#endif 14 15#pragma pack(push,_CRT_PACKING) 16 17#ifdef __cplusplus 18extern "C" { 19#endif 20 21typedef enum _EXCEPTION_DISPOSITION 22{ 23 ExceptionContinueExecution, 24 ExceptionContinueSearch, 25 ExceptionNestedException, 26 ExceptionCollidedUnwind, 27} EXCEPTION_DISPOSITION; 28 29#if (defined(_X86_) && !defined(__x86_64)) 30 struct _EXCEPTION_RECORD; 31 struct _CONTEXT; 32 33 EXCEPTION_DISPOSITION 34 __cdecl 35 _except_handler( 36 _In_ struct _EXCEPTION_RECORD *_ExceptionRecord, 37 _In_ void *_EstablisherFrame, 38 _Inout_ struct _CONTEXT *_ContextRecord, 39 _Inout_ void *_DispatcherContext); 40 41#elif defined(__ia64__) 42 43 typedef struct _EXCEPTION_POINTERS *Exception_info_ptr; 44 struct _EXCEPTION_RECORD; 45 struct _CONTEXT; 46 struct _DISPATCHER_CONTEXT; 47 48 __MINGW_EXTENSION 49 _CRTIMP 50 EXCEPTION_DISPOSITION 51 __cdecl 52 __C_specific_handler( 53 _In_ struct _EXCEPTION_RECORD *_ExceptionRecord, 54 _In_ unsigned __int64 _MemoryStackFp, 55 _In_ unsigned __int64 _BackingStoreFp, 56 _Inout_ struct _CONTEXT *_ContextRecord, 57 _Inout_ struct _DISPATCHER_CONTEXT *_DispatcherContext, 58 _In_ unsigned __int64 _GlobalPointer); 59 60#elif defined(__x86_64) || defined(_M_ARM) || defined(_M_ARM64) 61 62 struct _EXCEPTION_RECORD; 63 struct _CONTEXT; 64 struct _DISPATCHER_CONTEXT; 65 66 _CRTIMP 67 EXCEPTION_DISPOSITION 68 __cdecl 69 __C_specific_handler( 70 _In_ struct _EXCEPTION_RECORD *_ExceptionRecord, 71 _In_ void *_EstablisherFrame, 72 _Inout_ struct _CONTEXT *_ContextRecord, 73 _Inout_ struct _DISPATCHER_CONTEXT *_DispatcherContext); 74 75#endif 76 77#if (defined(_MSC_VER) || (defined(__clang__) && defined(__SEH__))) && !defined(_exception_code) 78 unsigned long __cdecl _exception_code(void); 79 void *__cdecl _exception_info(void); 80 int __cdecl _abnormal_termination(void); 81#endif 82 83#define GetExceptionCode _exception_code 84#define exception_code _exception_code 85#define GetExceptionInformation (struct _EXCEPTION_POINTERS *)_exception_info 86#define exception_info (struct _EXCEPTION_POINTERS *)_exception_info 87#define AbnormalTermination _abnormal_termination 88#define abnormal_termination _abnormal_termination 89 90#define EXCEPTION_EXECUTE_HANDLER 1 91#define EXCEPTION_CONTINUE_SEARCH 0 92#define EXCEPTION_CONTINUE_EXECUTION -1 93 94#if 0 95 /* CRT stuff */ 96 typedef void (__cdecl * _PHNDLR)(int); 97 98 struct _XCPT_ACTION { 99 unsigned long XcptNum; 100 int SigNum; 101 _PHNDLR XcptAction; 102 }; 103 104 extern struct _XCPT_ACTION _XcptActTab[]; 105 extern int _XcptActTabCount; 106 extern int _XcptActTabSize; 107 extern int _First_FPE_Indx; 108 extern int _Num_FPE; 109 110 int __cdecl __CppXcptFilter(unsigned long _ExceptionNum,struct _EXCEPTION_POINTERS * _ExceptionPtr); 111 int __cdecl _XcptFilter(unsigned long _ExceptionNum,struct _EXCEPTION_POINTERS * _ExceptionPtr); 112 113 /* 114 * The type of function that is expected as an exception handler to be 115 * installed with _try1. 116 */ 117 typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER)(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*); 118 119#ifndef HAVE_NO_SEH 120 /* 121 * This is not entirely necessary, but it is the structure installed by 122 * the _try1 primitive below. 123 */ 124 typedef struct _EXCEPTION_REGISTRATION { 125 struct _EXCEPTION_REGISTRATION *prev; 126 EXCEPTION_DISPOSITION (*handler)(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*); 127 } EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION; 128 129 typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD; 130 typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD; 131#endif 132 133#if (defined(_X86_) && !defined(__x86_64)) 134#define __try1(pHandler) \ 135 __asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler)); 136 137#define __except1 \ 138 __asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \ 139 : : : "%eax"); 140#elif defined(__x86_64) 141#define __try1(pHandler) \ 142 __asm__ ("pushq %0;pushq %%gs:0;movq %%rsp,%%gs:0;" : : "g" (pHandler)); 143 144#define __except1 \ 145 __asm__ ("movq (%%rsp),%%rax;movq %%rax,%%gs:0;addq $16,%%rsp;" \ 146 : : : "%rax"); 147#else 148#define __try1(pHandler) 149#define __except1 150#endif 151 152#endif // 0 153 154#ifdef __cplusplus 155} 156#endif 157 158#pragma pack(pop) 159#endif