home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / crt / src / excpt.h < prev    next >
C/C++ Source or Header  |  1998-06-17  |  6KB  |  233 lines

  1. /***
  2. *excpt.h - defines exception values, types and routines
  3. *
  4. *       Copyright (c) 1990-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *       This file contains the definitions and prototypes for the compiler-
  8. *       dependent intrinsics, support functions and keywords which implement
  9. *       the structured exception handling extensions.
  10. *
  11. *       [Public]
  12. *
  13. ****/
  14.  
  15. #if _MSC_VER > 1000
  16. #pragma once
  17. #endif  /* _MSC_VER > 1000 */
  18.  
  19. #ifndef _INC_EXCPT
  20. #define _INC_EXCPT
  21.  
  22. #if !defined (_WIN32) && !defined (_MAC)
  23. #error ERROR: Only Mac or Win32 targets supported!
  24. #endif  /* !defined (_WIN32) && !defined (_MAC) */
  25.  
  26. #ifndef _CRTBLD
  27. /* This version of the header files is NOT for user programs.
  28.  * It is intended for use when building the C runtimes ONLY.
  29.  * The version intended for public use will not have this message.
  30.  */
  31. #error ERROR: Use of C runtime library internal header file.
  32. #endif  /* _CRTBLD */
  33.  
  34. #ifdef _MSC_VER
  35. /*
  36.  * Currently, all MS C compilers for Win32 platforms default to 8 byte
  37.  * alignment.
  38.  */
  39. #pragma pack(push,8)
  40. #endif  /* _MSC_VER */
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif  /* __cplusplus */
  45.  
  46. #ifndef _INTERNAL_IFSTRIP_
  47. #include <cruntime.h>
  48. #endif  /* _INTERNAL_IFSTRIP_ */
  49.  
  50.  
  51. /* Define _CRTIMP */
  52.  
  53. #ifndef _CRTIMP
  54. #ifdef CRTDLL
  55. #define _CRTIMP __declspec(dllexport)
  56. #else  /* CRTDLL */
  57. #ifdef _DLL
  58. #define _CRTIMP __declspec(dllimport)
  59. #else  /* _DLL */
  60. #define _CRTIMP
  61. #endif  /* _DLL */
  62. #endif  /* CRTDLL */
  63. #endif  /* _CRTIMP */
  64.  
  65.  
  66. /* Define __cdecl for non-Microsoft compilers */
  67.  
  68. #if (!defined (_MSC_VER) && !defined (__cdecl))
  69. #define __cdecl
  70. #endif  /* (!defined (_MSC_VER) && !defined (__cdecl)) */
  71.  
  72. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  73.  
  74. #ifndef _CRTAPI1
  75. #if _MSC_VER >= 800 && _M_IX86 >= 300
  76. #define _CRTAPI1 __cdecl
  77. #else  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  78. #define _CRTAPI1
  79. #endif  /* _MSC_VER >= 800 && _M_IX86 >= 300 */
  80. #endif  /* _CRTAPI1 */
  81.  
  82.  
  83. /*
  84.  * Exception disposition return values.
  85.  */
  86. typedef enum _EXCEPTION_DISPOSITION {
  87.     ExceptionContinueExecution,
  88.     ExceptionContinueSearch,
  89.     ExceptionNestedException,
  90.     ExceptionCollidedUnwind
  91. } EXCEPTION_DISPOSITION;
  92.  
  93.  
  94. /*
  95.  * Prototype for SEH support function.
  96.  */
  97.  
  98. #ifdef _M_IX86
  99.  
  100. /*
  101.  * Declarations to keep MS C 8 (386/486) compiler happy
  102.  */
  103. struct _EXCEPTION_RECORD;
  104. struct _CONTEXT;
  105.  
  106. EXCEPTION_DISPOSITION __cdecl _except_handler (
  107.     struct _EXCEPTION_RECORD *ExceptionRecord,
  108.     void * EstablisherFrame,
  109.     struct _CONTEXT *ContextRecord,
  110.     void * DispatcherContext
  111.     );
  112.  
  113. #elif defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC)
  114.  
  115. /*
  116.  * Declarations to keep MIPS, ALPHA, and PPC compiler happy
  117.  */
  118. typedef struct _EXCEPTION_POINTERS *Exception_info_ptr;
  119. struct _EXCEPTION_RECORD;
  120. struct _CONTEXT;
  121. struct _DISPATCHER_CONTEXT;
  122.  
  123.  
  124. _CRTIMP EXCEPTION_DISPOSITION __C_specific_handler (
  125.     struct _EXCEPTION_RECORD *ExceptionRecord,
  126.     void *EstablisherFrame,
  127.     struct _CONTEXT *ContextRecord,
  128.     struct _DISPATCHER_CONTEXT *DispatcherContext
  129.     );
  130.  
  131. #endif  /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
  132.  
  133.  
  134. /*
  135.  * Keywords and intrinsics for SEH
  136.  */
  137.  
  138. #ifdef _MSC_VER
  139.  
  140. #define GetExceptionCode            _exception_code
  141. #define exception_code              _exception_code
  142. #define GetExceptionInformation     (struct _EXCEPTION_POINTERS *)_exception_info
  143. #define exception_info              (struct _EXCEPTION_POINTERS *)_exception_info
  144. #define AbnormalTermination         _abnormal_termination
  145. #define abnormal_termination        _abnormal_termination
  146.  
  147. unsigned long __cdecl _exception_code(void);
  148. void *        __cdecl _exception_info(void);
  149. int           __cdecl _abnormal_termination(void);
  150.  
  151. #endif  /* _MSC_VER */
  152.  
  153.  
  154. /*
  155.  * Legal values for expression in except().
  156.  */
  157.  
  158. #define EXCEPTION_EXECUTE_HANDLER       1
  159. #define EXCEPTION_CONTINUE_SEARCH       0
  160. #define EXCEPTION_CONTINUE_EXECUTION    -1
  161.  
  162.  
  163. #ifndef _INTERNAL_IFSTRIP_
  164. /*
  165.  * for convenience, define a type name for a pointer to signal-handler
  166.  */
  167.  
  168. typedef void (__cdecl * _PHNDLR)(int);
  169.  
  170. /*
  171.  * Exception-action table used by the C runtime to identify and dispose of
  172.  * exceptions corresponding to C runtime errors or C signals.
  173.  */
  174. struct _XCPT_ACTION {
  175.  
  176.     /*
  177.      * exception code or number. defined by the host OS.
  178.      */
  179.     unsigned long XcptNum;
  180.  
  181.     /*
  182.      * signal code or number. defined by the C runtime.
  183.      */
  184.     int SigNum;
  185.  
  186.     /*
  187.      * exception action code. either a special code or the address of
  188.      * a handler function. always determines how the exception filter
  189.      * should dispose of the exception.
  190.      */
  191.     _PHNDLR XcptAction;
  192. };
  193.  
  194. extern struct _XCPT_ACTION _XcptActTab[];
  195.  
  196. /*
  197.  * number of entries in the exception-action table
  198.  */
  199. extern int _XcptActTabCount;
  200.  
  201. /*
  202.  * size of exception-action table (in bytes)
  203.  */
  204. extern int _XcptActTabSize;
  205.  
  206. /*
  207.  * index of the first floating point exception entry
  208.  */
  209. extern int _First_FPE_Indx;
  210.  
  211. /*
  212.  * number of FPE entries
  213.  */
  214. extern int _Num_FPE;
  215.  
  216. /*
  217.  * return values and prototype for the exception filter function used in the
  218.  * C startup
  219.  */
  220. int __cdecl _XcptFilter(unsigned long, struct _EXCEPTION_POINTERS *);
  221.  
  222. #endif  /* _INTERNAL_IFSTRIP_ */
  223.  
  224. #ifdef __cplusplus
  225. }
  226. #endif  /* __cplusplus */
  227.  
  228. #ifdef _MSC_VER
  229. #pragma pack(pop)
  230. #endif  /* _MSC_VER */
  231.  
  232. #endif  /* _INC_EXCPT */
  233.