excpt.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #include <_mingw.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. #if (defined(_X86_) && !defined(__x86_64))
  22. struct _EXCEPTION_RECORD;
  23. struct _CONTEXT;
  24. EXCEPTION_DISPOSITION __cdecl _except_handler(struct _EXCEPTION_RECORD *_ExceptionRecord,void *_EstablisherFrame,struct _CONTEXT *_ContextRecord,void *_DispatcherContext);
  25. #elif defined(__ia64__)
  26. typedef struct _EXCEPTION_POINTERS *Exception_info_ptr;
  27. struct _EXCEPTION_RECORD;
  28. struct _CONTEXT;
  29. struct _DISPATCHER_CONTEXT;
  30. _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);
  31. #elif defined(__x86_64)
  32. struct _EXCEPTION_RECORD;
  33. struct _CONTEXT;
  34. #endif
  35. #define GetExceptionCode _exception_code
  36. #define exception_code _exception_code
  37. #define GetExceptionInformation (struct _EXCEPTION_POINTERS *)_exception_info
  38. #define exception_info (struct _EXCEPTION_POINTERS *)_exception_info
  39. #define AbnormalTermination _abnormal_termination
  40. #define abnormal_termination _abnormal_termination
  41. unsigned long __cdecl _exception_code(void);
  42. void *__cdecl _exception_info(void);
  43. int __cdecl _abnormal_termination(void);
  44. #define EXCEPTION_EXECUTE_HANDLER 1
  45. #define EXCEPTION_CONTINUE_SEARCH 0
  46. #define EXCEPTION_CONTINUE_EXECUTION -1
  47. /* CRT stuff */
  48. typedef void (__cdecl * _PHNDLR)(int);
  49. struct _XCPT_ACTION {
  50. unsigned long XcptNum;
  51. int SigNum;
  52. _PHNDLR XcptAction;
  53. };
  54. extern struct _XCPT_ACTION _XcptActTab[];
  55. extern int _XcptActTabCount;
  56. extern int _XcptActTabSize;
  57. extern int _First_FPE_Indx;
  58. extern int _Num_FPE;
  59. int __cdecl __CppXcptFilter(unsigned long _ExceptionNum,struct _EXCEPTION_POINTERS * _ExceptionPtr);
  60. int __cdecl _XcptFilter(unsigned long _ExceptionNum,struct _EXCEPTION_POINTERS * _ExceptionPtr);
  61. /*
  62. * The type of function that is expected as an exception handler to be
  63. * installed with _try1.
  64. */
  65. typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER)(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
  66. #ifndef HAVE_NO_SEH
  67. /*
  68. * This is not entirely necessary, but it is the structure installed by
  69. * the _try1 primitive below.
  70. */
  71. typedef struct _EXCEPTION_REGISTRATION {
  72. struct _EXCEPTION_REGISTRATION *prev;
  73. EXCEPTION_DISPOSITION (*handler)(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
  74. } EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION;
  75. typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD;
  76. typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD;
  77. #endif
  78. #if (defined(_X86_) && !defined(__x86_64))
  79. #define __try1(pHandler) \
  80. __asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler));
  81. #define __except1 \
  82. __asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \
  83. : : : "%eax");
  84. #elif defined(__x86_64)
  85. #define __try1(pHandler) \
  86. __asm__ ("pushq %0;pushq %%gs:0;movq %%rsp,%%gs:0;" : : "g" (pHandler));
  87. #define __except1 \
  88. __asm__ ("movq (%%rsp),%%rax;movq %%rax,%%gs:0;addq $16,%%rsp;" \
  89. : : : "%rax");
  90. #else
  91. #define __try1(pHandler)
  92. #define __except1
  93. #endif
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #pragma pack(pop)
  98. #endif