excpt.h 4.3 KB

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