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