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.

544 lines
14 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. *
  85. ****/
  86. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  87. #pragma once
  88. #endif
  89. #ifndef _INC_SETJMP
  90. #define _INC_SETJMP
  91. #if !defined(_WIN32)
  92. #error ERROR: Only Win32 target supported!
  93. #endif
  94. #ifndef _CRTBLD
  95. /* This version of the header files is NOT for user programs.
  96. * It is intended for use when building the C runtimes ONLY.
  97. * The version intended for public use will not have this message.
  98. */
  99. #error ERROR: Use of C runtime library internal header file.
  100. #endif /* _CRTBLD */
  101. #ifdef _MSC_VER
  102. /*
  103. * Currently, all MS C compilers for Win32 platforms default to 8 byte
  104. * alignment.
  105. */
  106. #pragma pack(push,8)
  107. #endif /* _MSC_VER */
  108. #ifdef __cplusplus
  109. extern "C" {
  110. #endif
  111. #ifndef _INTERNAL_IFSTRIP_
  112. #include <cruntime.h>
  113. #endif /* _INTERNAL_IFSTRIP_ */
  114. /* Define _CRTIMP */
  115. #ifndef _CRTIMP
  116. #ifdef CRTDLL
  117. #define _CRTIMP __declspec(dllexport)
  118. #else /* ndef CRTDLL */
  119. #ifdef _DLL
  120. #define _CRTIMP __declspec(dllimport)
  121. #else /* ndef _DLL */
  122. #define _CRTIMP
  123. #endif /* _DLL */
  124. #endif /* CRTDLL */
  125. #endif /* _CRTIMP */
  126. /* Define __cdecl for non-Microsoft compilers */
  127. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  128. #define __cdecl
  129. #endif
  130. /*
  131. * Definitions specific to particular setjmp implementations.
  132. */
  133. #if defined(_M_IX86)
  134. /*
  135. * MS compiler for x86
  136. */
  137. #ifndef _INC_SETJMPEX
  138. #define setjmp _setjmp
  139. #endif
  140. #define _JBLEN 16
  141. #define _JBTYPE int
  142. /*
  143. * Define jump buffer layout for x86 setjmp/longjmp.
  144. */
  145. typedef struct __JUMP_BUFFER {
  146. unsigned long Ebp;
  147. unsigned long Ebx;
  148. unsigned long Edi;
  149. unsigned long Esi;
  150. unsigned long Esp;
  151. unsigned long Eip;
  152. unsigned long Registration;
  153. unsigned long TryLevel;
  154. unsigned long Cookie;
  155. unsigned long UnwindFunc;
  156. unsigned long UnwindData[6];
  157. } _JUMP_BUFFER;
  158. #ifndef _INTERNAL_IFSTRIP_
  159. #ifdef __cplusplus
  160. extern "C"
  161. #endif
  162. void __stdcall _NLG_Notify(unsigned long);
  163. #ifdef __cplusplus
  164. extern "C"
  165. #endif
  166. void __stdcall _NLG_Return();
  167. #endif
  168. #elif defined(_M_MRX000)
  169. #ifndef _INC_SETJMPEX
  170. #if _MSC_VER >= 1100 /*IFSTRIP=IGN*/
  171. #define _setjmp _setjmpVfp
  172. #endif
  173. #define setjmp _setjmp
  174. #endif
  175. /*
  176. * All MIPS implementations need _JBLEN of 16
  177. */
  178. #define _JBLEN 16
  179. #define _JBTYPE double
  180. /*
  181. * Define jump buffer layout for MIPS setjmp/longjmp.
  182. */
  183. typedef struct __JUMP_BUFFER {
  184. unsigned long FltF20;
  185. unsigned long FltF21;
  186. unsigned long FltF22;
  187. unsigned long FltF23;
  188. unsigned long FltF24;
  189. unsigned long FltF25;
  190. unsigned long FltF26;
  191. unsigned long FltF27;
  192. unsigned long FltF28;
  193. unsigned long FltF29;
  194. unsigned long FltF30;
  195. unsigned long FltF31;
  196. unsigned long IntS0;
  197. unsigned long IntS1;
  198. unsigned long IntS2;
  199. unsigned long IntS3;
  200. unsigned long IntS4;
  201. unsigned long IntS5;
  202. unsigned long IntS6;
  203. unsigned long IntS7;
  204. unsigned long IntS8;
  205. unsigned long IntSp;
  206. unsigned long Type;
  207. unsigned long Fir;
  208. } _JUMP_BUFFER;
  209. #elif defined(_M_ALPHA)
  210. /*
  211. * The Alpha C8/GEM C compiler uses an intrinsic _setjmp.
  212. * The Alpha acc compiler implements setjmp as a function.
  213. */
  214. #ifdef _MSC_VER
  215. #ifndef _INC_SETJMPEX
  216. #define setjmp _setjmpex /* Alpha should always use setjmp as _setjmpex */
  217. #endif
  218. #endif
  219. /*
  220. * Alpha implementations use a _JBLEN of 24 quadwords.
  221. * A double is used only to obtain quadword size and alignment.
  222. */
  223. #define _JBLEN 24
  224. #define _JBTYPE double
  225. /*
  226. * Define jump buffer layout for Alpha setjmp/longjmp.
  227. * A double is used only to obtain quadword size and alignment.
  228. */
  229. typedef struct __JUMP_BUFFER {
  230. #ifdef _M_ALPHA64
  231. #define _JBFILL 3
  232. unsigned __int64 Fp;
  233. unsigned __int64 Pc;
  234. unsigned __int64 Seb;
  235. unsigned long Type;
  236. unsigned long Type_Fill;
  237. #else
  238. #define _JBFILL 5
  239. unsigned long Fp;
  240. unsigned long Pc;
  241. unsigned long Seb;
  242. unsigned long Type;
  243. #endif
  244. double FltF2;
  245. double FltF3;
  246. double FltF4;
  247. double FltF5;
  248. double FltF6;
  249. double FltF7;
  250. double FltF8;
  251. double FltF9;
  252. double IntS0;
  253. double IntS1;
  254. double IntS2;
  255. double IntS3;
  256. double IntS4;
  257. double IntS5;
  258. double IntS6;
  259. double IntSp;
  260. double Fir;
  261. double Fill[_JBFILL];
  262. } _JUMP_BUFFER;
  263. #undef _JBFILL
  264. #elif defined(_M_PPC)
  265. /*
  266. * The Microsoft VC++ V4.0 compiler uses an intrinsic _setjmp.
  267. * The Motorola C8.5 compiler implements setjmp as a function.
  268. */
  269. #if _MSC_VER > 850 /*IFSTRIP=IGN*/
  270. #ifndef _INC_SETJMPEX
  271. #undef _setjmp
  272. #define setjmp _setjmp
  273. #endif
  274. #endif
  275. /*
  276. * Min length is 240 bytes; round to 256 bytes.
  277. * Since this is allocated as an array of "double", the
  278. * number of entries required is 32.
  279. *
  280. * All PPC implementations need _JBLEN of 32
  281. */
  282. #define _JBLEN 32
  283. #define _JBTYPE double
  284. /*
  285. * Define jump buffer layout for PowerPC setjmp/longjmp.
  286. */
  287. typedef struct __JUMP_BUFFER {
  288. double Fpr14;
  289. double Fpr15;
  290. double Fpr16;
  291. double Fpr17;
  292. double Fpr18;
  293. double Fpr19;
  294. double Fpr20;
  295. double Fpr21;
  296. double Fpr22;
  297. double Fpr23;
  298. double Fpr24;
  299. double Fpr25;
  300. double Fpr26;
  301. double Fpr27;
  302. double Fpr28;
  303. double Fpr29;
  304. double Fpr30;
  305. double Fpr31;
  306. unsigned long Gpr1;
  307. unsigned long Gpr2;
  308. unsigned long Gpr13;
  309. unsigned long Gpr14;
  310. unsigned long Gpr15;
  311. unsigned long Gpr16;
  312. unsigned long Gpr17;
  313. unsigned long Gpr18;
  314. unsigned long Gpr19;
  315. unsigned long Gpr20;
  316. unsigned long Gpr21;
  317. unsigned long Gpr22;
  318. unsigned long Gpr23;
  319. unsigned long Gpr24;
  320. unsigned long Gpr25;
  321. unsigned long Gpr26;
  322. unsigned long Gpr27;
  323. unsigned long Gpr28;
  324. unsigned long Gpr29;
  325. unsigned long Gpr30;
  326. unsigned long Gpr31;
  327. unsigned long Cr;
  328. unsigned long Iar;
  329. unsigned long Type;
  330. } _JUMP_BUFFER;
  331. #elif defined(_M_IA64)
  332. /*
  333. * Minimum length is 528 bytes
  334. * Since this is allocated as an array of "SETJMP_FLOAT128", the
  335. * number of entries required is 33 (16-byte aligned).
  336. */
  337. // Avoid conflicts with winnt.h FLOAT128 by giving the typedef another name.
  338. typedef __declspec(align(16)) struct _SETJMP_FLOAT128 {
  339. __int64 LowPart;
  340. __int64 HighPart;
  341. } SETJMP_FLOAT128;
  342. #define _JBLEN 33
  343. typedef SETJMP_FLOAT128 _JBTYPE;
  344. #ifndef _INC_SETJMPEX
  345. #define setjmp _setjmp
  346. #endif
  347. /*
  348. * Define jump buffer layout for IA64 setjmp/longjmp.
  349. */
  350. typedef struct __JUMP_BUFFER {
  351. unsigned long iAReserved[6];
  352. //
  353. // x86 C9.0 compatibility
  354. //
  355. unsigned long Registration; // point to the UnwindData field.
  356. unsigned long TryLevel; // ignored by setjmp
  357. unsigned long Cookie; // set to "VC20" by setjmp
  358. unsigned long UnwindFunc; // set to EM longjmp() by setjmp
  359. //
  360. // First dword is zero to indicate it's an exception registration
  361. // record prepared by EM setjmp function.
  362. // Second dword is set to 0 for unsafe EM setjmp, and 1 for safe
  363. // EM setjmp.
  364. // Third dword is set to the setjmp site memory stack frame pointer.
  365. // Fourth dword is set to the setjmp site backing store frame pointer.
  366. //
  367. unsigned long UnwindData[6];
  368. //
  369. // floating point status register,
  370. // and preserved floating point registers fs0 - fs19
  371. //
  372. SETJMP_FLOAT128 FltS0;
  373. SETJMP_FLOAT128 FltS1;
  374. SETJMP_FLOAT128 FltS2;
  375. SETJMP_FLOAT128 FltS3;
  376. SETJMP_FLOAT128 FltS4;
  377. SETJMP_FLOAT128 FltS5;
  378. SETJMP_FLOAT128 FltS6;
  379. SETJMP_FLOAT128 FltS7;
  380. SETJMP_FLOAT128 FltS8;
  381. SETJMP_FLOAT128 FltS9;
  382. SETJMP_FLOAT128 FltS10;
  383. SETJMP_FLOAT128 FltS11;
  384. SETJMP_FLOAT128 FltS12;
  385. SETJMP_FLOAT128 FltS13;
  386. SETJMP_FLOAT128 FltS14;
  387. SETJMP_FLOAT128 FltS15;
  388. SETJMP_FLOAT128 FltS16;
  389. SETJMP_FLOAT128 FltS17;
  390. SETJMP_FLOAT128 FltS18;
  391. SETJMP_FLOAT128 FltS19;
  392. __int64 FPSR;
  393. //
  394. // return link and preserved branch registers bs0 - bs4
  395. //
  396. __int64 StIIP; // continuation address
  397. __int64 BrS0;
  398. __int64 BrS1;
  399. __int64 BrS2;
  400. __int64 BrS3;
  401. __int64 BrS4;
  402. //
  403. // preserved general registers s0 - s3, sp, nats
  404. //
  405. __int64 IntS0;
  406. __int64 IntS1;
  407. __int64 IntS2;
  408. __int64 IntS3;
  409. //
  410. // bsp, pfs, unat, lc
  411. //
  412. __int64 RsBSP;
  413. __int64 RsPFS; // previous frame marker (cfm of setjmp's caller)
  414. __int64 ApUNAT; // User Nat collection register (preserved)
  415. __int64 ApLC; // loop counter
  416. __int64 IntSp; // memory stack pointer
  417. __int64 IntNats; // Nat bits of preserved integer regs s0 - s3
  418. __int64 Preds; // predicates
  419. } _JUMP_BUFFER;
  420. #elif defined(_M_AMD64)
  421. typedef struct __declspec(align(16)) _SETJMP_FLOAT128 {
  422. unsigned __int64 Part[2];
  423. } SETJMP_FLOAT128;
  424. #define _JBLEN 16
  425. typedef SETJMP_FLOAT128 _JBTYPE;
  426. typedef struct _JUMP_BUFFER {
  427. unsigned __int64 Frame;
  428. unsigned __int64 Rbx;
  429. unsigned __int64 Rsp;
  430. unsigned __int64 Rbp;
  431. unsigned __int64 Rsi;
  432. unsigned __int64 Rdi;
  433. unsigned __int64 R12;
  434. unsigned __int64 R13;
  435. unsigned __int64 R14;
  436. unsigned __int64 R15;
  437. unsigned __int64 Rip;
  438. unsigned __int64 Spare;
  439. SETJMP_FLOAT128 Xmm6;
  440. SETJMP_FLOAT128 Xmm7;
  441. SETJMP_FLOAT128 Xmm8;
  442. SETJMP_FLOAT128 Xmm9;
  443. SETJMP_FLOAT128 Xmm10;
  444. SETJMP_FLOAT128 Xmm11;
  445. SETJMP_FLOAT128 Xmm12;
  446. SETJMP_FLOAT128 Xmm13;
  447. SETJMP_FLOAT128 Xmm14;
  448. SETJMP_FLOAT128 Xmm15;
  449. } _JUMP_BUFFER;
  450. #endif
  451. /* Define the buffer type for holding the state information */
  452. #ifndef _JMP_BUF_DEFINED
  453. typedef _JBTYPE jmp_buf[_JBLEN];
  454. #define _JMP_BUF_DEFINED
  455. #endif
  456. /* Function prototypes */
  457. int __cdecl setjmp(jmp_buf);
  458. #if _MSC_VER >= 1200 /*IFSTRIP=IGN*/
  459. _CRTIMP __declspec(noreturn) void __cdecl longjmp(jmp_buf, int);
  460. #else
  461. _CRTIMP void __cdecl longjmp(jmp_buf, int);
  462. #endif
  463. #ifdef __cplusplus
  464. }
  465. #endif
  466. #ifdef _MSC_VER
  467. #pragma pack(pop)
  468. #endif /* _MSC_VER */
  469. #endif /* _INC_SETJMP */