Leaked source code of windows server 2003
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.

373 lines
11 KiB

  1. /***
  2. *setjmp.h - definitions/declarations for setjmp/longjmp routines
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file defines the machine-dependent buffer used by
  8. * setjmp/longjmp to save and restore the program state, and
  9. * declarations for those routines.
  10. * [ANSI/System V]
  11. *
  12. * [Public]
  13. *
  14. *Revision History:
  15. * 12-11-87 JCR Added "_loadds" functionality
  16. * 12-18-87 JCR Added _FAR_ to declarations
  17. * 02-10-88 JCR Cleaned up white space
  18. * 05-03-89 JCR Added _INTERNAL_IFSTRIP for relinc usage
  19. * 08-15-89 GJF Cleanup, now specific to OS/2 2.0 (i.e., 386 flat model)
  20. * 10-30-89 GJF Fixed copyright
  21. * 11-02-89 JCR Changed "DLL" to "_DLL"
  22. * 03-01-90 GJF Added #ifndef _INC_SETJMP and #include <cruntime.h>
  23. * stuff. Also, removed some (now) useless preprocessor
  24. * directives.
  25. * 04-10-90 GJF Replaced _cdecl with _CALLTYPE1.
  26. * 05-18-90 GJF Revised for SEH.
  27. * 10-30-90 GJF Moved definition of _JBLEN into cruntime.h.
  28. * 02-25-91 SRW Moved definition of _JBLEN back here [_WIN32_]
  29. * 04-09-91 PNT Added _MAC_ definitions
  30. * 04-17-91 SRW Fixed definition of _JBLEN for i386 and MIPS to not
  31. * include the * sizeof(int) factor [_WIN32_]
  32. * 05-09-91 GJF Moved _JBLEN defs back to cruntime.h. Also, turn on
  33. * intrinsic _setjmp for Dosx32.
  34. * 08-27-91 GJF #ifdef out everything for C++.
  35. * 08-29-91 JCR ANSI naming
  36. * 11-01-91 GDP MIPS compiler support -- Moved _JBLEN back here
  37. * 01-16-92 GJF Fixed _JBLEN and map to _setjmp intrinsic for i386
  38. * target [_WIN32_].
  39. * 05-08-92 GJF Changed _JBLEN to support C8-32 (support for C6-386 has
  40. * been dropped).
  41. * 08-06-92 GJF Function calling type and variable type macros. Revised
  42. * use of compiler/target processor macros.
  43. * 11-09-92 GJF Fixed some preprocessing conditionals.
  44. * 01-03-93 SRW Fold in ALPHA changes
  45. * 01-09-93 SRW Remove usage of MIPS and ALPHA to conform to ANSI
  46. * Use _MIPS_ and _ALPHA_ instead.
  47. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  48. * 02-20-93 GJF Per ChuckG and MartinO, setjmp/longjmp to used in
  49. * C++ programs.
  50. * 03-23-93 SRW Change _JBLEN for MIPS in preparation for SetJmpEx
  51. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  52. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  53. * 04-13-93 SKS Remove _CRTIMP from _setjmp() -- it's an intrinsic
  54. * 04-23-93 SRW Added _JBTYPE and finalized setjmpex support.
  55. * 06-09-93 SRW Missing one line in previous merge.
  56. * 10-04-93 SRW Fix ifdefs for MIPS and ALPHA to only check for
  57. * _M_?????? defines
  58. * 10-11-93 GJF Merged NT and Cuda versions.
  59. * 01-12-93 PML Increased x86 _JBLEN from 8 to 16. Added new fields
  60. * to _JUMP_BUFFER for use with C9.0.
  61. * 06-16-94 GJF Fix for MIPS from Steve Hanson (Dolphin bug #13818)
  62. * 10-02-94 BWT Add PPC support.
  63. * 11-03-94 GJF Ensure 8 byte alignment.
  64. * 12-29-94 JCF Merged with mac header.
  65. * 01-13-95 JWM Added NLG prototypes.
  66. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  67. * 02-14-95 CFW Clean up Mac merge.
  68. * 06-23-95 JPM Use _setjmp with PowerPC VC compiler
  69. * 12-14-95 JWM Add "#pragma once".
  70. * 04-15-95 BWT Add _setjmpVfp (setjmp with Virtual Frame Pointer) for MIPS
  71. * 08-13-96 BWT Redefine _setjmp to _setjmp on MIPS also
  72. * 02-21-97 GJF Cleaned out obsolete support for _NTSDK. Also,
  73. * detab-ed.
  74. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  75. * 10-07-97 RDL Added IA64.
  76. * 10-02-97 RDL IA64 - 16-byte align jmp_buf and _JUMP_BUFFER.
  77. * 05-13-99 PML Remove _CRTAPI1
  78. * 05-17-99 PML Remove all Macintosh support.
  79. * 10-25-99 PML Temporarily issue error on _M_CEE (VS7#54572).
  80. * 02-25-00 PML Remove _M_CEE error (VS7#81945).
  81. * 11-08-00 PML Remove IA64 FPSR storage, rename reserveds (vs7#182574)
  82. * 11-17-00 PML Put back IA64 FPSR (backing out vs7#182574)
  83. * 03-19-01 BWT Add AMD64 definitions
  84. * 06-13-01 PML Compile clean -Za -W4 -Tc (vs7#267063)
  85. * 07-15-01 PML Remove all ALPHA, MIPS, and PPC code
  86. *
  87. ****/
  88. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  89. #pragma once
  90. #endif
  91. #ifndef _INC_SETJMP
  92. #define _INC_SETJMP
  93. #if !defined(_WIN32)
  94. #error ERROR: Only Win32 target supported!
  95. #endif
  96. #ifndef _CRTBLD
  97. /* This version of the header files is NOT for user programs.
  98. * It is intended for use when building the C runtimes ONLY.
  99. * The version intended for public use will not have this message.
  100. */
  101. #error ERROR: Use of C runtime library internal header file.
  102. #endif /* _CRTBLD */
  103. #ifdef _MSC_VER
  104. /*
  105. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  106. * alignment.
  107. */
  108. #pragma pack(push,8)
  109. #endif /* _MSC_VER */
  110. #ifdef __cplusplus
  111. extern "C" {
  112. #endif
  113. #ifndef _INTERNAL_IFSTRIP_
  114. #include <cruntime.h>
  115. #endif /* _INTERNAL_IFSTRIP_ */
  116. /* Define _CRTIMP */
  117. #ifndef _CRTIMP
  118. #ifdef CRTDLL
  119. #define _CRTIMP __declspec(dllexport)
  120. #else /* ndef CRTDLL */
  121. #ifdef _DLL
  122. #define _CRTIMP __declspec(dllimport)
  123. #else /* ndef _DLL */
  124. #define _CRTIMP
  125. #endif /* _DLL */
  126. #endif /* CRTDLL */
  127. #endif /* _CRTIMP */
  128. /* Define __cdecl for non-Microsoft compilers */
  129. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  130. #define __cdecl
  131. #endif
  132. /*
  133. * Definitions specific to particular setjmp implementations.
  134. */
  135. #if defined(_M_IX86)
  136. /*
  137. * MS compiler for x86
  138. */
  139. #ifndef _INC_SETJMPEX
  140. #define setjmp _setjmp
  141. #endif
  142. #define _JBLEN 16
  143. #define _JBTYPE int
  144. /*
  145. * Define jump buffer layout for x86 setjmp/longjmp.
  146. */
  147. typedef struct __JUMP_BUFFER {
  148. unsigned long Ebp;
  149. unsigned long Ebx;
  150. unsigned long Edi;
  151. unsigned long Esi;
  152. unsigned long Esp;
  153. unsigned long Eip;
  154. unsigned long Registration;
  155. unsigned long TryLevel;
  156. unsigned long Cookie;
  157. unsigned long UnwindFunc;
  158. unsigned long UnwindData[6];
  159. } _JUMP_BUFFER;
  160. #ifndef _INTERNAL_IFSTRIP_
  161. #ifdef __cplusplus
  162. extern "C"
  163. #endif
  164. void __stdcall _NLG_Notify(unsigned long);
  165. #ifdef __cplusplus
  166. extern "C"
  167. #endif
  168. void __stdcall _NLG_Return();
  169. #endif
  170. #elif defined(_M_IA64)
  171. /*
  172. * Minimum length is 528 bytes
  173. * Since this is allocated as an array of "SETJMP_FLOAT128", the
  174. * number of entries required is 33 (16-byte aligned).
  175. */
  176. /* Avoid conflicts with winnt.h FLOAT128 by giving the typedef another name. */
  177. typedef __declspec(align(16)) struct _SETJMP_FLOAT128 {
  178. __int64 LowPart;
  179. __int64 HighPart;
  180. } SETJMP_FLOAT128;
  181. #define _JBLEN 33
  182. typedef SETJMP_FLOAT128 _JBTYPE;
  183. #ifndef _INC_SETJMPEX
  184. #define setjmp _setjmp
  185. #endif
  186. /*
  187. * Define jump buffer layout for IA64 setjmp/longjmp.
  188. */
  189. typedef struct __JUMP_BUFFER {
  190. /*
  191. * x86 reserved.
  192. */
  193. unsigned long iAReserved[6];
  194. /*
  195. * x86 C9.0 compatibility
  196. */
  197. unsigned long Registration; /* point to the UnwindData field. */
  198. unsigned long TryLevel; /* ignored by setjmp */
  199. unsigned long Cookie; /* set to "VC20" by setjmp */
  200. unsigned long UnwindFunc; /* set to EM longjmp() by setjmp */
  201. /*
  202. * First dword is zero to indicate it's an exception registration
  203. * record prepared by EM setjmp function.
  204. * Second dword is set to 0 for unsafe EM setjmp, and 1 for safe
  205. * EM setjmp.
  206. * Third dword is set to the setjmp site memory stack frame pointer.
  207. * Fourth dword is set to the setjmp site backing store frame pointer.
  208. */
  209. unsigned long UnwindData[6];
  210. /*
  211. * floating point status register,
  212. * and preserved floating point registers fs0 - fs19
  213. */
  214. SETJMP_FLOAT128 FltS0;
  215. SETJMP_FLOAT128 FltS1;
  216. SETJMP_FLOAT128 FltS2;
  217. SETJMP_FLOAT128 FltS3;
  218. SETJMP_FLOAT128 FltS4;
  219. SETJMP_FLOAT128 FltS5;
  220. SETJMP_FLOAT128 FltS6;
  221. SETJMP_FLOAT128 FltS7;
  222. SETJMP_FLOAT128 FltS8;
  223. SETJMP_FLOAT128 FltS9;
  224. SETJMP_FLOAT128 FltS10;
  225. SETJMP_FLOAT128 FltS11;
  226. SETJMP_FLOAT128 FltS12;
  227. SETJMP_FLOAT128 FltS13;
  228. SETJMP_FLOAT128 FltS14;
  229. SETJMP_FLOAT128 FltS15;
  230. SETJMP_FLOAT128 FltS16;
  231. SETJMP_FLOAT128 FltS17;
  232. SETJMP_FLOAT128 FltS18;
  233. SETJMP_FLOAT128 FltS19;
  234. __int64 FPSR;
  235. /*
  236. * return link and preserved branch registers bs0 - bs4
  237. */
  238. __int64 StIIP; /* continuation address */
  239. __int64 BrS0;
  240. __int64 BrS1;
  241. __int64 BrS2;
  242. __int64 BrS3;
  243. __int64 BrS4;
  244. /*
  245. * preserved general registers s0 - s3, sp, nats
  246. */
  247. __int64 IntS0;
  248. __int64 IntS1;
  249. __int64 IntS2;
  250. __int64 IntS3;
  251. /*
  252. * bsp, pfs, unat, lc
  253. */
  254. __int64 RsBSP;
  255. __int64 RsPFS; /* previous frame marker (cfm of setjmp's caller) */
  256. __int64 ApUNAT; /* User Nat collection register (preserved) */
  257. __int64 ApLC; /* loop counter */
  258. __int64 IntSp; /* memory stack pointer */
  259. __int64 IntNats; /* Nat bits of preserved integer regs s0 - s3 */
  260. __int64 Preds; /* predicates */
  261. } _JUMP_BUFFER;
  262. #elif defined(_M_AMD64)
  263. typedef struct __declspec(align(16)) _SETJMP_FLOAT128 {
  264. unsigned __int64 Part[2];
  265. } SETJMP_FLOAT128;
  266. #define _JBLEN 16
  267. typedef SETJMP_FLOAT128 _JBTYPE;
  268. #ifndef _INC_SETJMPEX
  269. #define setjmp _setjmp
  270. #endif
  271. typedef struct _JUMP_BUFFER {
  272. unsigned __int64 Frame;
  273. unsigned __int64 Rbx;
  274. unsigned __int64 Rsp;
  275. unsigned __int64 Rbp;
  276. unsigned __int64 Rsi;
  277. unsigned __int64 Rdi;
  278. unsigned __int64 R12;
  279. unsigned __int64 R13;
  280. unsigned __int64 R14;
  281. unsigned __int64 R15;
  282. unsigned __int64 Rip;
  283. unsigned __int64 Spare;
  284. SETJMP_FLOAT128 Xmm6;
  285. SETJMP_FLOAT128 Xmm7;
  286. SETJMP_FLOAT128 Xmm8;
  287. SETJMP_FLOAT128 Xmm9;
  288. SETJMP_FLOAT128 Xmm10;
  289. SETJMP_FLOAT128 Xmm11;
  290. SETJMP_FLOAT128 Xmm12;
  291. SETJMP_FLOAT128 Xmm13;
  292. SETJMP_FLOAT128 Xmm14;
  293. SETJMP_FLOAT128 Xmm15;
  294. } _JUMP_BUFFER;
  295. #endif
  296. /* Define the buffer type for holding the state information */
  297. #ifndef _JMP_BUF_DEFINED
  298. typedef _JBTYPE jmp_buf[_JBLEN];
  299. #define _JMP_BUF_DEFINED
  300. #endif
  301. /* Function prototypes */
  302. int __cdecl setjmp(jmp_buf);
  303. #if _MSC_VER >= 1200 /*IFSTRIP=IGN*/
  304. _CRTIMP __declspec(noreturn) void __cdecl longjmp(jmp_buf, int);
  305. #else
  306. _CRTIMP void __cdecl longjmp(jmp_buf, int);
  307. #endif
  308. #ifdef __cplusplus
  309. }
  310. #endif
  311. #ifdef _MSC_VER
  312. #pragma pack(pop)
  313. #endif /* _MSC_VER */
  314. #endif /* _INC_SETJMP */