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.

458 lines
9.4 KiB

  1. /***
  2. *setjmp.h - definitions/declarations for setjmp/longjmp routines
  3. *
  4. * Copyright (c) 1985-2000, 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_AMD64)
  74. #ifndef _INC_SETJMPEX
  75. #define setjmp _setjmp
  76. #endif
  77. /*
  78. * AMD64 setjmp definitions.
  79. */
  80. typedef struct __declspec(align(16)) _SETJMP_FLOAT128 {
  81. unsigned __int64 Part[2];
  82. } SETJMP_FLOAT128;
  83. #define _JBLEN 16
  84. typedef SETJMP_FLOAT128 _JBTYPE;
  85. typedef struct _JUMP_BUFFER {
  86. unsigned __int64 Frame;
  87. unsigned __int64 Rbx;
  88. unsigned __int64 Rsp;
  89. unsigned __int64 Rbp;
  90. unsigned __int64 Rsi;
  91. unsigned __int64 Rdi;
  92. unsigned __int64 R12;
  93. unsigned __int64 R13;
  94. unsigned __int64 R14;
  95. unsigned __int64 R15;
  96. unsigned __int64 Rip;
  97. unsigned __int64 Spare;
  98. SETJMP_FLOAT128 Xmm6;
  99. SETJMP_FLOAT128 Xmm7;
  100. SETJMP_FLOAT128 Xmm8;
  101. SETJMP_FLOAT128 Xmm9;
  102. SETJMP_FLOAT128 Xmm10;
  103. SETJMP_FLOAT128 Xmm11;
  104. SETJMP_FLOAT128 Xmm12;
  105. SETJMP_FLOAT128 Xmm13;
  106. SETJMP_FLOAT128 Xmm14;
  107. SETJMP_FLOAT128 Xmm15;
  108. } _JUMP_BUFFER;
  109. #elif defined(_M_MRX000)
  110. #ifndef _INC_SETJMPEX
  111. #if _MSC_VER >= 1100
  112. #define _setjmp _setjmpVfp
  113. #endif
  114. #define setjmp _setjmp
  115. #endif
  116. /*
  117. * All MIPS implementations need _JBLEN of 16
  118. */
  119. #define _JBLEN 16
  120. #define _JBTYPE double
  121. /*
  122. * Define jump buffer layout for MIPS setjmp/longjmp.
  123. */
  124. typedef struct __JUMP_BUFFER {
  125. unsigned long FltF20;
  126. unsigned long FltF21;
  127. unsigned long FltF22;
  128. unsigned long FltF23;
  129. unsigned long FltF24;
  130. unsigned long FltF25;
  131. unsigned long FltF26;
  132. unsigned long FltF27;
  133. unsigned long FltF28;
  134. unsigned long FltF29;
  135. unsigned long FltF30;
  136. unsigned long FltF31;
  137. unsigned long IntS0;
  138. unsigned long IntS1;
  139. unsigned long IntS2;
  140. unsigned long IntS3;
  141. unsigned long IntS4;
  142. unsigned long IntS5;
  143. unsigned long IntS6;
  144. unsigned long IntS7;
  145. unsigned long IntS8;
  146. unsigned long IntSp;
  147. unsigned long Type;
  148. unsigned long Fir;
  149. } _JUMP_BUFFER;
  150. #elif defined(_M_ALPHA)
  151. /*
  152. * The Alpha C8/GEM C compiler uses an intrinsic _setjmp.
  153. * The Alpha acc compiler implements setjmp as a function.
  154. */
  155. #ifdef _MSC_VER
  156. #ifndef _INC_SETJMPEX
  157. #define setjmp _setjmpex /* Alpha should always use setjmp as _setjmpex */
  158. #endif
  159. #endif
  160. /*
  161. * Alpha implementations use a _JBLEN of 24 quadwords.
  162. * A double is used only to obtain quadword size and alignment.
  163. */
  164. #define _JBLEN 24
  165. #define _JBTYPE double
  166. /*
  167. * Define jump buffer layout for Alpha setjmp/longjmp.
  168. * A double is used only to obtain quadword size and alignment.
  169. */
  170. typedef struct __JUMP_BUFFER {
  171. #ifdef _M_ALPHA64
  172. #define _JBFILL 3
  173. unsigned __int64 Fp;
  174. unsigned __int64 Pc;
  175. unsigned __int64 Seb;
  176. unsigned long Type;
  177. unsigned long Type_Fill;
  178. #else
  179. #define _JBFILL 5
  180. unsigned long Fp;
  181. unsigned long Pc;
  182. unsigned long Seb;
  183. unsigned long Type;
  184. #endif
  185. double FltF2;
  186. double FltF3;
  187. double FltF4;
  188. double FltF5;
  189. double FltF6;
  190. double FltF7;
  191. double FltF8;
  192. double FltF9;
  193. double IntS0;
  194. double IntS1;
  195. double IntS2;
  196. double IntS3;
  197. double IntS4;
  198. double IntS5;
  199. double IntS6;
  200. double IntSp;
  201. double Fir;
  202. double Fill[_JBFILL];
  203. } _JUMP_BUFFER;
  204. #undef _JBFILL
  205. #elif defined(_M_PPC)
  206. /*
  207. * The Microsoft VC++ V4.0 compiler uses an intrinsic _setjmp.
  208. * The Motorola C8.5 compiler implements setjmp as a function.
  209. */
  210. #if _MSC_VER > 850
  211. #ifndef _INC_SETJMPEX
  212. #undef _setjmp
  213. #define setjmp _setjmp
  214. #endif
  215. #endif
  216. /*
  217. * Min length is 240 bytes; round to 256 bytes.
  218. * Since this is allocated as an array of "double", the
  219. * number of entries required is 32.
  220. *
  221. * All PPC implementations need _JBLEN of 32
  222. */
  223. #define _JBLEN 32
  224. #define _JBTYPE double
  225. /*
  226. * Define jump buffer layout for PowerPC setjmp/longjmp.
  227. */
  228. typedef struct __JUMP_BUFFER {
  229. double Fpr14;
  230. double Fpr15;
  231. double Fpr16;
  232. double Fpr17;
  233. double Fpr18;
  234. double Fpr19;
  235. double Fpr20;
  236. double Fpr21;
  237. double Fpr22;
  238. double Fpr23;
  239. double Fpr24;
  240. double Fpr25;
  241. double Fpr26;
  242. double Fpr27;
  243. double Fpr28;
  244. double Fpr29;
  245. double Fpr30;
  246. double Fpr31;
  247. unsigned long Gpr1;
  248. unsigned long Gpr2;
  249. unsigned long Gpr13;
  250. unsigned long Gpr14;
  251. unsigned long Gpr15;
  252. unsigned long Gpr16;
  253. unsigned long Gpr17;
  254. unsigned long Gpr18;
  255. unsigned long Gpr19;
  256. unsigned long Gpr20;
  257. unsigned long Gpr21;
  258. unsigned long Gpr22;
  259. unsigned long Gpr23;
  260. unsigned long Gpr24;
  261. unsigned long Gpr25;
  262. unsigned long Gpr26;
  263. unsigned long Gpr27;
  264. unsigned long Gpr28;
  265. unsigned long Gpr29;
  266. unsigned long Gpr30;
  267. unsigned long Gpr31;
  268. unsigned long Cr;
  269. unsigned long Iar;
  270. unsigned long Type;
  271. } _JUMP_BUFFER;
  272. #elif defined(_M_IA64)
  273. /*
  274. * Minimum length is 528 bytes
  275. * Since this is allocated as an array of "SETJMP_FLOAT128", the
  276. * number of entries required is 33 (16-byte aligned).
  277. */
  278. // Avoid conflicts with winnt.h FLOAT128 by giving the typedef another name.
  279. typedef __declspec(align(16)) struct _SETJMP_FLOAT128 {
  280. __int64 LowPart;
  281. __int64 HighPart;
  282. } SETJMP_FLOAT128;
  283. #define _JBLEN 33
  284. typedef SETJMP_FLOAT128 _JBTYPE;
  285. #ifndef _INC_SETJMPEX
  286. #define setjmp _setjmp
  287. #endif
  288. /*
  289. * Define jump buffer layout for IA64 setjmp/longjmp.
  290. */
  291. typedef struct __JUMP_BUFFER {
  292. //
  293. // x86 reserved.
  294. //
  295. unsigned long iAReserved[6];
  296. //
  297. // x86 C9.0 compatibility
  298. //
  299. unsigned long Registration; // point to the UnwindData field.
  300. unsigned long TryLevel; // ignored by setjmp
  301. unsigned long Cookie; // set to "VC20" by setjmp
  302. unsigned long UnwindFunc; // set to EM longjmp() by setjmp
  303. //
  304. // First dword is zero to indicate it's an exception registration
  305. // record prepared by EM setjmp function.
  306. // Second dword is set to 0 for unsafe EM setjmp, and 1 for safe
  307. // EM setjmp.
  308. // Third dword is set to the setjmp site memory stack frame pointer.
  309. // Fourth dword is set to the setjmp site backing store frame pointer.
  310. //
  311. unsigned long UnwindData[6];
  312. //
  313. // floating point status register,
  314. // and preserved floating point registers fs0 - fs19
  315. //
  316. SETJMP_FLOAT128 FltS0;
  317. SETJMP_FLOAT128 FltS1;
  318. SETJMP_FLOAT128 FltS2;
  319. SETJMP_FLOAT128 FltS3;
  320. SETJMP_FLOAT128 FltS4;
  321. SETJMP_FLOAT128 FltS5;
  322. SETJMP_FLOAT128 FltS6;
  323. SETJMP_FLOAT128 FltS7;
  324. SETJMP_FLOAT128 FltS8;
  325. SETJMP_FLOAT128 FltS9;
  326. SETJMP_FLOAT128 FltS10;
  327. SETJMP_FLOAT128 FltS11;
  328. SETJMP_FLOAT128 FltS12;
  329. SETJMP_FLOAT128 FltS13;
  330. SETJMP_FLOAT128 FltS14;
  331. SETJMP_FLOAT128 FltS15;
  332. SETJMP_FLOAT128 FltS16;
  333. SETJMP_FLOAT128 FltS17;
  334. SETJMP_FLOAT128 FltS18;
  335. SETJMP_FLOAT128 FltS19;
  336. __int64 FPSR;
  337. //
  338. // return link and preserved branch registers bs0 - bs4
  339. //
  340. __int64 StIIP; // continuation address
  341. __int64 BrS0;
  342. __int64 BrS1;
  343. __int64 BrS2;
  344. __int64 BrS3;
  345. __int64 BrS4;
  346. //
  347. // preserved general registers s0 - s3, sp, nats
  348. //
  349. __int64 IntS0;
  350. __int64 IntS1;
  351. __int64 IntS2;
  352. __int64 IntS3;
  353. //
  354. // bsp, pfs, unat, lc
  355. //
  356. __int64 RsBSP;
  357. __int64 RsPFS; // previous frame marker (cfm of setjmp's caller)
  358. __int64 ApUNAT; // User Nat collection register (preserved)
  359. __int64 ApLC; // loop counter
  360. __int64 IntSp; // memory stack pointer
  361. __int64 IntNats; // Nat bits of preserved integer regs s0 - s3
  362. __int64 Preds; // predicates
  363. } _JUMP_BUFFER;
  364. #endif
  365. /* Define the buffer type for holding the state information */
  366. #ifndef _JMP_BUF_DEFINED
  367. typedef _JBTYPE jmp_buf[_JBLEN];
  368. #define _JMP_BUF_DEFINED
  369. #endif
  370. /* Function prototypes */
  371. int __cdecl setjmp(jmp_buf);
  372. #if _MSC_VER >= 1200
  373. _CRTIMP __declspec(noreturn) void __cdecl longjmp(jmp_buf, int);
  374. #else
  375. _CRTIMP void __cdecl longjmp(jmp_buf, int);
  376. #endif
  377. #ifdef __cplusplus
  378. }
  379. #endif
  380. #ifdef _MSC_VER
  381. #pragma pack(pop)
  382. #endif /* _MSC_VER */
  383. #endif /* _INC_SETJMP */