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.

278 lines
6.0 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_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_IA64)
  110. /*
  111. * Minimum length is 528 bytes
  112. * Since this is allocated as an array of "SETJMP_FLOAT128", the
  113. * number of entries required is 33 (16-byte aligned).
  114. */
  115. /* Avoid conflicts with winnt.h FLOAT128 by giving the typedef another name. */
  116. typedef __declspec(align(16)) struct _SETJMP_FLOAT128 {
  117. __int64 LowPart;
  118. __int64 HighPart;
  119. } SETJMP_FLOAT128;
  120. #define _JBLEN 33
  121. typedef SETJMP_FLOAT128 _JBTYPE;
  122. #ifndef _INC_SETJMPEX
  123. #define setjmp _setjmp
  124. #endif
  125. /*
  126. * Define jump buffer layout for IA64 setjmp/longjmp.
  127. */
  128. typedef struct __JUMP_BUFFER {
  129. /*
  130. * x86 reserved.
  131. */
  132. unsigned long iAReserved[6];
  133. /*
  134. * x86 C9.0 compatibility
  135. */
  136. unsigned long Registration; /* point to the UnwindData field. */
  137. unsigned long TryLevel; /* ignored by setjmp */
  138. unsigned long Cookie; /* set to "VC20" by setjmp */
  139. unsigned long UnwindFunc; /* set to EM longjmp() by setjmp */
  140. /*
  141. * First dword is zero to indicate it's an exception registration
  142. * record prepared by EM setjmp function.
  143. * Second dword is set to 0 for unsafe EM setjmp, and 1 for safe
  144. * EM setjmp.
  145. * Third dword is set to the setjmp site memory stack frame pointer.
  146. * Fourth dword is set to the setjmp site backing store frame pointer.
  147. */
  148. unsigned long UnwindData[6];
  149. /*
  150. * floating point status register,
  151. * and preserved floating point registers fs0 - fs19
  152. */
  153. SETJMP_FLOAT128 FltS0;
  154. SETJMP_FLOAT128 FltS1;
  155. SETJMP_FLOAT128 FltS2;
  156. SETJMP_FLOAT128 FltS3;
  157. SETJMP_FLOAT128 FltS4;
  158. SETJMP_FLOAT128 FltS5;
  159. SETJMP_FLOAT128 FltS6;
  160. SETJMP_FLOAT128 FltS7;
  161. SETJMP_FLOAT128 FltS8;
  162. SETJMP_FLOAT128 FltS9;
  163. SETJMP_FLOAT128 FltS10;
  164. SETJMP_FLOAT128 FltS11;
  165. SETJMP_FLOAT128 FltS12;
  166. SETJMP_FLOAT128 FltS13;
  167. SETJMP_FLOAT128 FltS14;
  168. SETJMP_FLOAT128 FltS15;
  169. SETJMP_FLOAT128 FltS16;
  170. SETJMP_FLOAT128 FltS17;
  171. SETJMP_FLOAT128 FltS18;
  172. SETJMP_FLOAT128 FltS19;
  173. __int64 FPSR;
  174. /*
  175. * return link and preserved branch registers bs0 - bs4
  176. */
  177. __int64 StIIP; /* continuation address */
  178. __int64 BrS0;
  179. __int64 BrS1;
  180. __int64 BrS2;
  181. __int64 BrS3;
  182. __int64 BrS4;
  183. /*
  184. * preserved general registers s0 - s3, sp, nats
  185. */
  186. __int64 IntS0;
  187. __int64 IntS1;
  188. __int64 IntS2;
  189. __int64 IntS3;
  190. /*
  191. * bsp, pfs, unat, lc
  192. */
  193. __int64 RsBSP;
  194. __int64 RsPFS; /* previous frame marker (cfm of setjmp's caller) */
  195. __int64 ApUNAT; /* User Nat collection register (preserved) */
  196. __int64 ApLC; /* loop counter */
  197. __int64 IntSp; /* memory stack pointer */
  198. __int64 IntNats; /* Nat bits of preserved integer regs s0 - s3 */
  199. __int64 Preds; /* predicates */
  200. } _JUMP_BUFFER;
  201. #endif
  202. /* Define the buffer type for holding the state information */
  203. #ifndef _JMP_BUF_DEFINED
  204. typedef _JBTYPE jmp_buf[_JBLEN];
  205. #define _JMP_BUF_DEFINED
  206. #endif
  207. /* Function prototypes */
  208. int __cdecl setjmp(jmp_buf);
  209. #if _MSC_VER >= 1200
  210. _CRTIMP __declspec(noreturn) void __cdecl longjmp(jmp_buf, int);
  211. #else
  212. _CRTIMP void __cdecl longjmp(jmp_buf, int);
  213. #endif
  214. #ifdef __cplusplus
  215. }
  216. #endif
  217. #ifdef _MSC_VER
  218. #pragma pack(pop)
  219. #endif /* _MSC_VER */
  220. #endif /* _INC_SETJMP */