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.

413 lines
8.4 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. ****/
  15. #if _MSC_VER > 1000
  16. #pragma once
  17. #endif
  18. #ifndef _INC_SETJMP
  19. #define _INC_SETJMP
  20. #if !defined(_WIN32)
  21. #error ERROR: Only Win32 target supported!
  22. #endif
  23. #ifdef _MSC_VER
  24. /*
  25. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  26. * alignment.
  27. */
  28. #pragma pack(push,8)
  29. #endif /* _MSC_VER */
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /* Define _CRTIMP */
  34. #ifndef _CRTIMP
  35. #ifdef _DLL
  36. #define _CRTIMP __declspec(dllimport)
  37. #else /* ndef _DLL */
  38. #define _CRTIMP
  39. #endif /* _DLL */
  40. #endif /* _CRTIMP */
  41. /* Define __cdecl for non-Microsoft compilers */
  42. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  43. #define __cdecl
  44. #endif
  45. /*
  46. * Definitions specific to particular setjmp implementations.
  47. */
  48. #if defined(_M_IX86)
  49. /*
  50. * MS compiler for x86
  51. */
  52. #ifndef _INC_SETJMPEX
  53. #define setjmp _setjmp
  54. #endif
  55. #define _JBLEN 16
  56. #define _JBTYPE int
  57. /*
  58. * Define jump buffer layout for x86 setjmp/longjmp.
  59. */
  60. typedef struct __JUMP_BUFFER {
  61. unsigned long Ebp;
  62. unsigned long Ebx;
  63. unsigned long Edi;
  64. unsigned long Esi;
  65. unsigned long Esp;
  66. unsigned long Eip;
  67. unsigned long Registration;
  68. unsigned long TryLevel;
  69. unsigned long Cookie;
  70. unsigned long UnwindFunc;
  71. unsigned long UnwindData[6];
  72. } _JUMP_BUFFER;
  73. #elif defined(_M_MRX000)
  74. #ifndef _INC_SETJMPEX
  75. #if _MSC_VER >= 1100
  76. #define _setjmp _setjmpVfp
  77. #endif
  78. #define setjmp _setjmp
  79. #endif
  80. /*
  81. * All MIPS implementations need _JBLEN of 16
  82. */
  83. #define _JBLEN 16
  84. #define _JBTYPE double
  85. /*
  86. * Define jump buffer layout for MIPS setjmp/longjmp.
  87. */
  88. typedef struct __JUMP_BUFFER {
  89. unsigned long FltF20;
  90. unsigned long FltF21;
  91. unsigned long FltF22;
  92. unsigned long FltF23;
  93. unsigned long FltF24;
  94. unsigned long FltF25;
  95. unsigned long FltF26;
  96. unsigned long FltF27;
  97. unsigned long FltF28;
  98. unsigned long FltF29;
  99. unsigned long FltF30;
  100. unsigned long FltF31;
  101. unsigned long IntS0;
  102. unsigned long IntS1;
  103. unsigned long IntS2;
  104. unsigned long IntS3;
  105. unsigned long IntS4;
  106. unsigned long IntS5;
  107. unsigned long IntS6;
  108. unsigned long IntS7;
  109. unsigned long IntS8;
  110. unsigned long IntSp;
  111. unsigned long Type;
  112. unsigned long Fir;
  113. } _JUMP_BUFFER;
  114. #elif defined(_M_ALPHA)
  115. /*
  116. * The Alpha C8/GEM C compiler uses an intrinsic _setjmp.
  117. * The Alpha acc compiler implements setjmp as a function.
  118. */
  119. #ifdef _MSC_VER
  120. #ifndef _INC_SETJMPEX
  121. #define setjmp _setjmpex /* Alpha should always use setjmp as _setjmpex */
  122. #endif
  123. #endif
  124. /*
  125. * Alpha implementations use a _JBLEN of 24 quadwords.
  126. * A double is used only to obtain quadword size and alignment.
  127. */
  128. #define _JBLEN 24
  129. #define _JBTYPE double
  130. /*
  131. * Define jump buffer layout for Alpha setjmp/longjmp.
  132. * A double is used only to obtain quadword size and alignment.
  133. */
  134. typedef struct __JUMP_BUFFER {
  135. #ifdef _M_ALPHA64
  136. #define _JBFILL 3
  137. unsigned __int64 Fp;
  138. unsigned __int64 Pc;
  139. unsigned __int64 Seb;
  140. unsigned long Type;
  141. unsigned long Type_Fill;
  142. #else
  143. #define _JBFILL 5
  144. unsigned long Fp;
  145. unsigned long Pc;
  146. unsigned long Seb;
  147. unsigned long Type;
  148. #endif
  149. double FltF2;
  150. double FltF3;
  151. double FltF4;
  152. double FltF5;
  153. double FltF6;
  154. double FltF7;
  155. double FltF8;
  156. double FltF9;
  157. double IntS0;
  158. double IntS1;
  159. double IntS2;
  160. double IntS3;
  161. double IntS4;
  162. double IntS5;
  163. double IntS6;
  164. double IntSp;
  165. double Fir;
  166. double Fill[_JBFILL];
  167. } _JUMP_BUFFER;
  168. #undef _JBFILL
  169. #elif defined(_M_PPC)
  170. /*
  171. * The Microsoft VC++ V4.0 compiler uses an intrinsic _setjmp.
  172. * The Motorola C8.5 compiler implements setjmp as a function.
  173. */
  174. #if _MSC_VER > 850
  175. #ifndef _INC_SETJMPEX
  176. #undef _setjmp
  177. #define setjmp _setjmp
  178. #endif
  179. #endif
  180. /*
  181. * Min length is 240 bytes; round to 256 bytes.
  182. * Since this is allocated as an array of "double", the
  183. * number of entries required is 32.
  184. *
  185. * All PPC implementations need _JBLEN of 32
  186. */
  187. #define _JBLEN 32
  188. #define _JBTYPE double
  189. /*
  190. * Define jump buffer layout for PowerPC setjmp/longjmp.
  191. */
  192. typedef struct __JUMP_BUFFER {
  193. double Fpr14;
  194. double Fpr15;
  195. double Fpr16;
  196. double Fpr17;
  197. double Fpr18;
  198. double Fpr19;
  199. double Fpr20;
  200. double Fpr21;
  201. double Fpr22;
  202. double Fpr23;
  203. double Fpr24;
  204. double Fpr25;
  205. double Fpr26;
  206. double Fpr27;
  207. double Fpr28;
  208. double Fpr29;
  209. double Fpr30;
  210. double Fpr31;
  211. unsigned long Gpr1;
  212. unsigned long Gpr2;
  213. unsigned long Gpr13;
  214. unsigned long Gpr14;
  215. unsigned long Gpr15;
  216. unsigned long Gpr16;
  217. unsigned long Gpr17;
  218. unsigned long Gpr18;
  219. unsigned long Gpr19;
  220. unsigned long Gpr20;
  221. unsigned long Gpr21;
  222. unsigned long Gpr22;
  223. unsigned long Gpr23;
  224. unsigned long Gpr24;
  225. unsigned long Gpr25;
  226. unsigned long Gpr26;
  227. unsigned long Gpr27;
  228. unsigned long Gpr28;
  229. unsigned long Gpr29;
  230. unsigned long Gpr30;
  231. unsigned long Gpr31;
  232. unsigned long Cr;
  233. unsigned long Iar;
  234. unsigned long Type;
  235. } _JUMP_BUFFER;
  236. #elif defined(_M_IA64)
  237. /*
  238. * Minimum length is 528 bytes
  239. * Since this is allocated as an array of "SETJMP_FLOAT128", the
  240. * number of entries required is 33 (16-byte aligned).
  241. */
  242. // Avoid conflicts with winnt.h FLOAT128 by giving the typedef another name.
  243. typedef __declspec(align(16)) struct _SETJMP_FLOAT128 {
  244. __int64 LowPart;
  245. __int64 HighPart;
  246. } SETJMP_FLOAT128;
  247. #define _JBLEN 33
  248. typedef SETJMP_FLOAT128 _JBTYPE;
  249. #ifndef _INC_SETJMPEX
  250. #define setjmp _setjmp
  251. #endif
  252. /*
  253. * Define jump buffer layout for IA64 setjmp/longjmp.
  254. */
  255. typedef struct __JUMP_BUFFER {
  256. unsigned long iAReserved[6];
  257. //
  258. // x86 C9.0 compatibility
  259. //
  260. unsigned long Registration; // point to the UnwindData field.
  261. unsigned long TryLevel; // ignored by setjmp
  262. unsigned long Cookie; // set to "VC20" by setjmp
  263. unsigned long UnwindFunc; // set to EM longjmp() by setjmp
  264. //
  265. // First dword is zero to indicate it's an exception registration
  266. // record prepared by EM setjmp function.
  267. // Second dword is set to 0 for unsafe EM setjmp, and 1 for safe
  268. // EM setjmp.
  269. // Third dword is set to the setjmp site memory stack frame pointer.
  270. // Fourth dword is set to the setjmp site backing store frame pointer.
  271. //
  272. unsigned long UnwindData[6];
  273. //
  274. // floating point status register,
  275. // and preserved floating point registers fs0 - fs19
  276. //
  277. SETJMP_FLOAT128 FltS0;
  278. SETJMP_FLOAT128 FltS1;
  279. SETJMP_FLOAT128 FltS2;
  280. SETJMP_FLOAT128 FltS3;
  281. SETJMP_FLOAT128 FltS4;
  282. SETJMP_FLOAT128 FltS5;
  283. SETJMP_FLOAT128 FltS6;
  284. SETJMP_FLOAT128 FltS7;
  285. SETJMP_FLOAT128 FltS8;
  286. SETJMP_FLOAT128 FltS9;
  287. SETJMP_FLOAT128 FltS10;
  288. SETJMP_FLOAT128 FltS11;
  289. SETJMP_FLOAT128 FltS12;
  290. SETJMP_FLOAT128 FltS13;
  291. SETJMP_FLOAT128 FltS14;
  292. SETJMP_FLOAT128 FltS15;
  293. SETJMP_FLOAT128 FltS16;
  294. SETJMP_FLOAT128 FltS17;
  295. SETJMP_FLOAT128 FltS18;
  296. SETJMP_FLOAT128 FltS19;
  297. __int64 FPSR;
  298. //
  299. // return link and preserved branch registers bs0 - bs4
  300. //
  301. __int64 StIIP; // continuation address
  302. __int64 BrS0;
  303. __int64 BrS1;
  304. __int64 BrS2;
  305. __int64 BrS3;
  306. __int64 BrS4;
  307. //
  308. // preserved general registers s0 - s3, sp, nats
  309. //
  310. __int64 IntS0;
  311. __int64 IntS1;
  312. __int64 IntS2;
  313. __int64 IntS3;
  314. //
  315. // bsp, pfs, unat, lc
  316. //
  317. __int64 RsBSP;
  318. __int64 RsPFS; // previous frame marker (cfm of setjmp's caller)
  319. __int64 ApUNAT; // User Nat collection register (preserved)
  320. __int64 ApLC; // loop counter
  321. __int64 IntSp; // memory stack pointer
  322. __int64 IntNats; // Nat bits of preserved integer regs s0 - s3
  323. __int64 Preds; // predicates
  324. } _JUMP_BUFFER;
  325. #endif
  326. /* Define the buffer type for holding the state information */
  327. #ifndef _JMP_BUF_DEFINED
  328. typedef _JBTYPE jmp_buf[_JBLEN];
  329. #define _JMP_BUF_DEFINED
  330. #endif
  331. /* Function prototypes */
  332. int __cdecl setjmp(jmp_buf);
  333. #if _MSC_VER >= 1200
  334. _CRTIMP __declspec(noreturn) void __cdecl longjmp(jmp_buf, int);
  335. #else
  336. _CRTIMP void __cdecl longjmp(jmp_buf, int);
  337. #endif
  338. #ifdef __cplusplus
  339. }
  340. #endif
  341. #ifdef _MSC_VER
  342. #pragma pack(pop)
  343. #endif /* _MSC_VER */
  344. #endif /* _INC_SETJMP */