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.

272 lines
5.8 KiB

  1. /***
  2. *setjmp.h - definitions/declarations for setjmp/longjmp routines
  3. *
  4. * Copyright (c) 1985-1996, 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. * The setjmp() that will be used by those who include this file
  13. * is _setjmpex, which is safe for use with try/except/finally,
  14. * but is slow. See <crt/setjmpex.h> and <crt/setjmp.h> for more.
  15. *
  16. ****/
  17. #ifndef _INC_SETJMP
  18. #include <signal.h>
  19. #ifndef __cplusplus
  20. #define _CRTAPI1 __cdecl
  21. #define _CRTAPI2 __cdecl
  22. /*
  23. * Posix programs use _setjmpex by default.
  24. */
  25. /*
  26. * Definitions specific to particular setjmp implementations.
  27. */
  28. #if defined(_M_IX86)
  29. #define longjmp _longjmpex
  30. #define setjmp _setjmp
  31. /*
  32. * MS C8-32 or older MS C6-386 compilers
  33. */
  34. #define _JBLEN 16
  35. #define _JBTYPE int
  36. /*
  37. * Define jump buffer layout for x86 setjmp/longjmp
  38. */
  39. typedef struct __JUMP_BUFFER {
  40. unsigned long Ebp;
  41. unsigned long Ebx;
  42. unsigned long Edi;
  43. unsigned long Esi;
  44. unsigned long Esp;
  45. unsigned long Eip;
  46. unsigned long Registration;
  47. unsigned long TryLevel;
  48. unsigned long Cookie;
  49. unsigned long UnwindFunc;
  50. unsigned long UnwindData[6];
  51. } _JUMP_BUFFER;
  52. #elif defined(_ALPHA_)
  53. /*
  54. * Alpha implementations need a _JBLEN of 20 quadwords.
  55. * A double is used only to obtain quadword size and alignment.
  56. */
  57. #define _JBLEN 20
  58. #define _JBTYPE double
  59. #define _setjmp setjmp
  60. /*
  61. * Define jump buffer layout for Alpha setjmp/longjmp.
  62. * A double is used only to obtain quadword size and alignment.
  63. */
  64. typedef struct __JUMP_BUFFER {
  65. unsigned long Fp;
  66. unsigned long Pc;
  67. unsigned long Seb;
  68. unsigned long Type;
  69. double FltF2;
  70. double FltF3;
  71. double FltF4;
  72. double FltF5;
  73. double FltF6;
  74. double FltF7;
  75. double FltF8;
  76. double FltF9;
  77. double IntS0;
  78. double IntS1;
  79. double IntS2;
  80. double IntS3;
  81. double IntS4;
  82. double IntS5;
  83. double IntS6;
  84. double IntSp;
  85. double Fir;
  86. double Fill;
  87. } _JUMP_BUFFER;
  88. #elif defined(_M_IA64)
  89. /*
  90. * Length is 528 bytes
  91. * Since this is allocated as an array of "__int64", the
  92. * number of entries required is 66.
  93. *
  94. * All IA64 implementations need _JBLEN of 66
  95. */
  96. #define _JBLEN 66
  97. #define _JBTYPE __int64
  98. #ifndef _INC_SETJMPEX
  99. #define setjmp _setjmp
  100. #endif
  101. /*
  102. * Define jump buffer layout for IA64 setjmp/longjmp.
  103. */
  104. typedef struct __JUMP_BUFFER {
  105. //
  106. // x86 reserved.
  107. //
  108. unsigned long iAReserved[6];
  109. //
  110. // x86 C9.0 compatibility
  111. //
  112. unsigned long Registration; // point to the UnwindData field.
  113. unsigned long TryLevel; // ignored by setjmp
  114. unsigned long Cookie; // set to "VC20" by setjmp
  115. unsigned long UnwindFunc; // set to EM longjmp() by setjmp
  116. //
  117. //
  118. // First dword is zero to indicate it's an exception registration
  119. // record prepared by EM setjmp function.
  120. // Second dword is set to 0 for unsafe EM setjmp, and 1 for safe
  121. // EM setjmp.
  122. // Third dword is set to the setjmp site memory stack frame pointer.
  123. // Fourth dword is set to the setjmp site backing store frame pointer.
  124. //
  125. unsigned long UnwindData[6];
  126. //
  127. // floating point status register,
  128. // and preserved floating point registers fs0 - fs19
  129. //
  130. long double FltS0;
  131. long double PadS0;
  132. long double FltS1;
  133. long double PadS1;
  134. long double FltS2;
  135. long double PadS2;
  136. long double FltS3;
  137. long double PadS3;
  138. long double FltS4;
  139. long double PadS4;
  140. long double FltS5;
  141. long double PadS5;
  142. long double FltS6;
  143. long double PadS6;
  144. long double FltS7;
  145. long double PadS7;
  146. long double FltS8;
  147. long double PadS8;
  148. long double FltS9;
  149. long double PadS9;
  150. long double FltS10;
  151. long double PadS10;
  152. long double FltS11;
  153. long double PadS11;
  154. long double FltS12;
  155. long double PadS12;
  156. long double FltS13;
  157. long double PadS13;
  158. long double FltS14;
  159. long double PadS14;
  160. long double FltS15;
  161. long double PadS15;
  162. long double FltS16;
  163. long double PadS16;
  164. long double FltS17;
  165. long double PadS17;
  166. long double FltS18;
  167. long double PadS18;
  168. long double FltS19;
  169. long double PadS19;
  170. __int64 FPSR;
  171. //
  172. // return link and preserved branch registers bs0 - bs4
  173. //
  174. __int64 StIIP; // continuation address
  175. __int64 BrS0;
  176. __int64 BrS1;
  177. __int64 BrS2;
  178. __int64 BrS3;
  179. __int64 BrS4;
  180. //
  181. // preserved general registers s0 - s3, sp, nats
  182. //
  183. __int64 IntS0;
  184. __int64 IntS1;
  185. __int64 IntS2;
  186. __int64 IntS3;
  187. //
  188. // bsp, pfs, unat, lc
  189. //
  190. __int64 RsBSP;
  191. __int64 RsPFS; // previous frame marker (cfm of setjmp's caller)
  192. __int64 ApUNAT; // User Nat collection register (preserved)
  193. __int64 ApLC; // loop counter
  194. __int64 IntSp; // memory stack pointer
  195. __int64 IntNats; // Nat bits of preserved integer regs s0 - s3
  196. __int64 Preds; // predicates
  197. } _JUMP_BUFFER;
  198. #endif /* MIPS/Alpha/PPC/IA64 */
  199. /* define the buffer type for holding the state information */
  200. #ifndef _JMP_BUF_DEFINED
  201. typedef _JBTYPE jmp_buf[_JBLEN];
  202. #define _JMP_BUF_DEFINED
  203. #endif
  204. #ifndef _SIGJMP_BUF_DEFINED
  205. #define _SIGJMP_BUF_DEFINED
  206. /*
  207. * sigjmp buf is just a jmp_buf plus an int to say whether the sigmask
  208. * is saved or not, and a sigmask_t for the mask if it is saved.
  209. */
  210. typedef _JBTYPE sigjmp_buf[_JBLEN + 2];
  211. #endif /* _SIGJMP_BUF_DEFINED */
  212. extern _JBTYPE * __cdecl _sigjmp_store_mask(sigjmp_buf, int);
  213. #define sigsetjmp(_env, _save) \
  214. setjmp(_sigjmp_store_mask((_env), (_save)))
  215. /* function prototypes */
  216. int __cdecl setjmp(jmp_buf);
  217. void __cdecl longjmp(jmp_buf, int);
  218. void __cdecl siglongjmp(sigjmp_buf, int);
  219. /* function prototypes */
  220. #endif /* __cplusplus */
  221. #define _INC_SETJMP
  222. #endif /* _INC_SETJMP */