Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

274 lines
7.4 KiB

  1. /***
  2. *excpt.h - defines exception values, types and routines
  3. *
  4. * Copyright (c) 1990-2001, 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. *Revision History:
  14. * 11-01-91 GJF Module created. Basically a synthesis of except.h
  15. * and excpt.h and intended as a replacement for
  16. * both.
  17. * 12-13-91 GJF Fixed build for Win32.
  18. * 05-05-92 SRW C8 wants C6 style names for now.
  19. * 07-20-92 SRW Moved from winxcpt.h to excpt.h
  20. * 08-06-92 GJF Function calling type and variable type macros. Also
  21. * revised compiler/target processor macro usage.
  22. * 11-09-92 GJF Fixed preprocessing conditionals for MIPS. Also,
  23. * fixed some compiler warning (fix from/for RichardS).
  24. * 01-03-93 SRW Fold in ALPHA changes
  25. * 01-04-93 SRW Add leave keyword for x86
  26. * 01-09-93 SRW Remove usage of MIPS and ALPHA to conform to ANSI
  27. * Use _MIPS_ and _ALPHA_ instead.
  28. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  29. * 02-18-93 GJF Changed _try to __try, etc.
  30. * 03-31-93 CFW Removed #define try, except, leave, finally for x86.
  31. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  32. * 07-29-93 GJF Added declarations for _First_FPE_Indx and _Num_FPE.
  33. * 09-01-93 GJF Merged Cuda and NT SDK versions.
  34. * 10-04-93 SRW Fix ifdefs for MIPS and ALPHA to only check for _M_??????
  35. * defines
  36. * 10-12-93 GJF Merged again.
  37. * 10-19-93 GJF MS/MIPS compiler gets most of the same SEH defs and
  38. * decls as the MS compiler for the X86.
  39. * 10-29-93 GJF Don't #define try, et al, when compiling C++ app!
  40. * 12-09-93 GJF Alpha compiler now has MS front-end and implements
  41. * the same SEH names.
  42. * 11-03-94 GJF Ensure 8 byte alignment.
  43. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  44. * 02-14-95 CFW Clean up Mac merge.
  45. * 12-14-95 JWM Add "#pragma once".
  46. * 02-21-97 GJF Cleaned out obsolete support for _CRTAPI* and _NTSDK.
  47. * Also, detab-ed.
  48. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  49. * 10-07-97 RDL Added IA64.
  50. * 11-12-97 RDL __C_specific_handler() prototype change from SC.
  51. * 05-13-99 PML Remove _CRTAPI1
  52. * 05-17-99 PML Remove all Macintosh support.
  53. *
  54. ****/
  55. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  56. #pragma once
  57. #endif
  58. #ifndef _INC_EXCPT
  59. #define _INC_EXCPT
  60. #if !defined(_WIN32)
  61. #error ERROR: Only Win32 target supported!
  62. #endif
  63. #ifndef _CRTBLD
  64. /* This version of the header files is NOT for user programs.
  65. * It is intended for use when building the C runtimes ONLY.
  66. * The version intended for public use will not have this message.
  67. */
  68. #error ERROR: Use of C runtime library internal header file.
  69. #endif /* _CRTBLD */
  70. #ifdef _MSC_VER
  71. /*
  72. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  73. * alignment.
  74. */
  75. #pragma pack(push,8)
  76. #endif /* _MSC_VER */
  77. #ifdef __cplusplus
  78. extern "C" {
  79. #endif
  80. #ifndef _INTERNAL_IFSTRIP_
  81. #include <cruntime.h>
  82. #endif /* _INTERNAL_IFSTRIP_ */
  83. /* Define _CRTIMP */
  84. #ifndef _CRTIMP
  85. #ifdef CRTDLL
  86. #define _CRTIMP __declspec(dllexport)
  87. #else /* ndef CRTDLL */
  88. #ifdef _DLL
  89. #define _CRTIMP __declspec(dllimport)
  90. #else /* ndef _DLL */
  91. #define _CRTIMP
  92. #endif /* _DLL */
  93. #endif /* CRTDLL */
  94. #endif /* _CRTIMP */
  95. /* Define __cdecl for non-Microsoft compilers */
  96. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  97. #define __cdecl
  98. #endif
  99. /*
  100. * Exception disposition return values.
  101. */
  102. typedef enum _EXCEPTION_DISPOSITION {
  103. ExceptionContinueExecution,
  104. ExceptionContinueSearch,
  105. ExceptionNestedException,
  106. ExceptionCollidedUnwind
  107. } EXCEPTION_DISPOSITION;
  108. /*
  109. * Prototype for SEH support function.
  110. */
  111. #ifdef _M_IX86
  112. /*
  113. * Declarations to keep MS C 8 (386/486) compiler happy
  114. */
  115. struct _EXCEPTION_RECORD;
  116. struct _CONTEXT;
  117. EXCEPTION_DISPOSITION __cdecl _except_handler (
  118. struct _EXCEPTION_RECORD *ExceptionRecord,
  119. void * EstablisherFrame,
  120. struct _CONTEXT *ContextRecord,
  121. void * DispatcherContext
  122. );
  123. #elif defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64)
  124. /*
  125. * Declarations to keep MIPS, ALPHA, and PPC compiler happy
  126. */
  127. typedef struct _EXCEPTION_POINTERS *Exception_info_ptr;
  128. struct _EXCEPTION_RECORD;
  129. struct _CONTEXT;
  130. struct _DISPATCHER_CONTEXT;
  131. #if defined(_M_IA64)
  132. _CRTIMP EXCEPTION_DISPOSITION __C_specific_handler (
  133. struct _EXCEPTION_RECORD *ExceptionRecord,
  134. unsigned __int64 MemoryStackFp,
  135. unsigned __int64 BackingStoreFp,
  136. struct _CONTEXT *ContextRecord,
  137. struct _DISPATCHER_CONTEXT *DispatcherContext,
  138. unsigned __int64 GlobalPointer
  139. );
  140. #else
  141. _CRTIMP EXCEPTION_DISPOSITION __C_specific_handler (
  142. struct _EXCEPTION_RECORD *ExceptionRecord,
  143. void *EstablisherFrame,
  144. struct _CONTEXT *ContextRecord,
  145. struct _DISPATCHER_CONTEXT *DispatcherContext
  146. );
  147. #endif // defined(_M_IA64)
  148. #endif
  149. /*
  150. * Keywords and intrinsics for SEH
  151. */
  152. #ifdef _MSC_VER
  153. #define GetExceptionCode _exception_code
  154. #define exception_code _exception_code
  155. #define GetExceptionInformation (struct _EXCEPTION_POINTERS *)_exception_info
  156. #define exception_info (struct _EXCEPTION_POINTERS *)_exception_info
  157. #define AbnormalTermination _abnormal_termination
  158. #define abnormal_termination _abnormal_termination
  159. unsigned long __cdecl _exception_code(void);
  160. void * __cdecl _exception_info(void);
  161. int __cdecl _abnormal_termination(void);
  162. #endif
  163. /*
  164. * Legal values for expression in except().
  165. */
  166. #define EXCEPTION_EXECUTE_HANDLER 1
  167. #define EXCEPTION_CONTINUE_SEARCH 0
  168. #define EXCEPTION_CONTINUE_EXECUTION -1
  169. #ifndef _INTERNAL_IFSTRIP_
  170. /*
  171. * for convenience, define a type name for a pointer to signal-handler
  172. */
  173. typedef void (__cdecl * _PHNDLR)(int);
  174. /*
  175. * Exception-action table used by the C runtime to identify and dispose of
  176. * exceptions corresponding to C runtime errors or C signals.
  177. */
  178. struct _XCPT_ACTION {
  179. /*
  180. * exception code or number. defined by the host OS.
  181. */
  182. unsigned long XcptNum;
  183. /*
  184. * signal code or number. defined by the C runtime.
  185. */
  186. int SigNum;
  187. /*
  188. * exception action code. either a special code or the address of
  189. * a handler function. always determines how the exception filter
  190. * should dispose of the exception.
  191. */
  192. _PHNDLR XcptAction;
  193. };
  194. extern struct _XCPT_ACTION _XcptActTab[];
  195. /*
  196. * number of entries in the exception-action table
  197. */
  198. extern int _XcptActTabCount;
  199. /*
  200. * size of exception-action table (in bytes)
  201. */
  202. extern int _XcptActTabSize;
  203. /*
  204. * index of the first floating point exception entry
  205. */
  206. extern int _First_FPE_Indx;
  207. /*
  208. * number of FPE entries
  209. */
  210. extern int _Num_FPE;
  211. /*
  212. * return values and prototype for the exception filter function used in the
  213. * C startup
  214. */
  215. int __cdecl _XcptFilter(unsigned long, struct _EXCEPTION_POINTERS *);
  216. #endif /* _INTERNAL_IFSTRIP_ */
  217. #ifdef __cplusplus
  218. }
  219. #endif
  220. #ifdef _MSC_VER
  221. #pragma pack(pop)
  222. #endif /* _MSC_VER */
  223. #endif /* _INC_EXCPT */