STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
setjmp.h
Go to the documentation of this file.
1 /***
2 *setjmp.h - definitions/declarations for setjmp/longjmp routines
3 *
4 * Copyright (c) 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 
16 #pragma once
17 
18 #ifndef _INC_SETJMP
19 #define _INC_SETJMP
20 
21 #include <crtdefs.h>
22 
23 #if defined (_M_CEE)
24 /*
25  * The reason why simple setjmp won't work here is that there may
26  * be case when CLR stubs are on the stack e.g. function call just
27  * after jitting, and not unwinding CLR will result in bad state of
28  * CLR which then can AV or do something very bad.
29  */
30 #include <setjmpex.h>
31 #endif /* defined (_M_CEE) */
32 
33 /*
34  * Currently, all MS C compilers for Win32 platforms default to 8 byte
35  * alignment.
36  */
37 #pragma pack(push,_CRT_PACKING)
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
42 
43 /*
44  * Definitions specific to particular setjmp implementations.
45  */
46 
47 #if defined (_M_IX86)
48 
49 /*
50  * MS compiler for x86
51  */
52 
53 #ifndef _INC_SETJMPEX
54 #define setjmp _setjmp
55 #endif /* _INC_SETJMPEX */
56 
57 #define _JBLEN 16
58 #define _JBTYPE int
59 
60 /*
61  * Define jump buffer layout for x86 setjmp/longjmp.
62  */
63 typedef struct __JUMP_BUFFER {
64  unsigned long Ebp;
65  unsigned long Ebx;
66  unsigned long Edi;
67  unsigned long Esi;
68  unsigned long Esp;
69  unsigned long Eip;
70  unsigned long Registration;
71  unsigned long TryLevel;
72  unsigned long Cookie;
73  unsigned long UnwindFunc;
74  unsigned long UnwindData[6];
75 } _JUMP_BUFFER;
76 
77 #ifdef _CRTBLD
78 #ifdef __cplusplus
79 extern "C"
80 #endif /* __cplusplus */
81 void __stdcall _NLG_Notify(unsigned long);
82 
83 #ifdef __cplusplus
84 extern "C"
85 #endif /* __cplusplus */
86 void __stdcall _NLG_Return();
87 #endif /* _CRTBLD */
88 
89 #elif defined (_M_X64)
90 
91 typedef struct _CRT_ALIGN(16) _SETJMP_FLOAT128 {
92  unsigned __int64 Part[2];
93 } SETJMP_FLOAT128;
94 
95 #define _JBLEN 16
96 typedef SETJMP_FLOAT128 _JBTYPE;
97 
98 #ifndef _INC_SETJMPEX
99 #define setjmp _setjmp
100 #endif /* _INC_SETJMPEX */
101 
102 typedef struct _JUMP_BUFFER {
103  unsigned __int64 Frame;
104  unsigned __int64 Rbx;
105  unsigned __int64 Rsp;
106  unsigned __int64 Rbp;
107  unsigned __int64 Rsi;
108  unsigned __int64 Rdi;
109  unsigned __int64 R12;
110  unsigned __int64 R13;
111  unsigned __int64 R14;
112  unsigned __int64 R15;
113  unsigned __int64 Rip;
114  unsigned long MxCsr;
115  unsigned short FpCsr;
116  unsigned short Spare;
117 
118  SETJMP_FLOAT128 Xmm6;
119  SETJMP_FLOAT128 Xmm7;
120  SETJMP_FLOAT128 Xmm8;
121  SETJMP_FLOAT128 Xmm9;
122  SETJMP_FLOAT128 Xmm10;
123  SETJMP_FLOAT128 Xmm11;
124  SETJMP_FLOAT128 Xmm12;
125  SETJMP_FLOAT128 Xmm13;
126  SETJMP_FLOAT128 Xmm14;
127  SETJMP_FLOAT128 Xmm15;
128 } _JUMP_BUFFER;
129 
130 #elif defined (_M_ARM)
131 
132 #ifndef _INC_SETJMPEX
133 #define setjmp _setjmp
134 #endif /* _INC_SETJMPEX */
135 
136 /*
137  * ARM setjmp definitions.
138  */
139 
140 #define _JBLEN 28
141 #define _JBTYPE int
142 
143 typedef struct _JUMP_BUFFER {
144  unsigned long Frame;
145 
146  unsigned long R4;
147  unsigned long R5;
148  unsigned long R6;
149  unsigned long R7;
150  unsigned long R8;
151  unsigned long R9;
152  unsigned long R10;
153  unsigned long R11;
154 
155  unsigned long Sp;
156  unsigned long Pc;
157  unsigned long Fpscr;
158  unsigned long long D[8]; // D8-D15 VFP/NEON regs
159 } _JUMP_BUFFER;
160 
161 #endif /* defined (_M_ARM) */
162 
163 
164 /* Define the buffer type for holding the state information */
165 
166 #ifndef _JMP_BUF_DEFINED
167 typedef _JBTYPE jmp_buf[_JBLEN];
168 #define _JMP_BUF_DEFINED
169 
170 #endif /* _JMP_BUF_DEFINED */
171 
172 
173 /* Function prototypes */
174 
175 int __cdecl setjmp(_Out_ jmp_buf _Buf);
176 
177 #ifdef __cplusplus
178 }
179 #endif /* __cplusplus */
180 
181 #ifdef __cplusplus
182 #pragma warning(push)
183 #pragma warning(disable:4987)
184 extern "C"
185 {
186 _CRTIMP __declspec(noreturn) void __cdecl longjmp(_In_ jmp_buf _Buf, _In_ int _Value) throw(...);
187 }
188 #pragma warning(pop)
189 #else /* __cplusplus */
190 _CRTIMP __declspec(noreturn) void __cdecl longjmp(_In_ jmp_buf _Buf, _In_ int _Value);
191 #endif /* __cplusplus */
192 
193 #pragma pack(pop)
194 
195 #endif /* _INC_SETJMP */
#define _Out_
Definition: sal.h:351
_CRTIMP _In_ int _Value
Definition: setjmp.h:190
#define _CRTIMP
Definition: crtdefs.h:23
Definition: regex:1520
typedef void(__cdecl *_se_translator_function)(unsigned int
_JBTYPE jmp_buf[_JBLEN]
Definition: setjmp.h:167
#define _In_
Definition: sal.h:314
_CRTIMP __declspec(noreturn) void __cdecl longjmp(_In_ jmp_buf _Buf
Cancels the currently executing task. This function can be called from within the body of a task to a...
Definition: ppltasks.h:203
#define _CRT_ALIGN(x)
Definition: crtdefs.h:604
int __cdecl setjmp(_Out_ jmp_buf _Buf)