1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the w64 mingw-runtime package. 4 * No warranty is given; refer to the file DISCLAIMER within this package. 5 */ 6 #ifndef _INC_SETJMP 7 #define _INC_SETJMP 8 9 #include <vcruntime.h> 10 11 #pragma pack(push,_CRT_PACKING) 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #if (defined(_X86_) && !defined(__x86_64)) 18 19 #define _JBLEN 16 20 #define _JBTYPE int 21 22 typedef struct __JUMP_BUFFER { 23 unsigned long Ebp; 24 unsigned long Ebx; 25 unsigned long Edi; 26 unsigned long Esi; 27 unsigned long Esp; 28 unsigned long Eip; 29 unsigned long Registration; 30 unsigned long TryLevel; 31 unsigned long Cookie; 32 unsigned long UnwindFunc; 33 unsigned long UnwindData[6]; 34 } _JUMP_BUFFER; 35 36 #elif defined(__ia64__) 37 38 typedef _CRT_ALIGN(16) struct _SETJMP_FLOAT128 { 39 __MINGW_EXTENSION __int64 LowPart; 40 __MINGW_EXTENSION __int64 HighPart; 41 } SETJMP_FLOAT128; 42 43 #define _JBLEN 33 44 typedef SETJMP_FLOAT128 _JBTYPE; 45 46 typedef struct __JUMP_BUFFER { 47 48 unsigned long iAReserved[6]; 49 50 unsigned long Registration; 51 unsigned long TryLevel; 52 unsigned long Cookie; 53 unsigned long UnwindFunc; 54 55 unsigned long UnwindData[6]; 56 57 SETJMP_FLOAT128 FltS0; 58 SETJMP_FLOAT128 FltS1; 59 SETJMP_FLOAT128 FltS2; 60 SETJMP_FLOAT128 FltS3; 61 SETJMP_FLOAT128 FltS4; 62 SETJMP_FLOAT128 FltS5; 63 SETJMP_FLOAT128 FltS6; 64 SETJMP_FLOAT128 FltS7; 65 SETJMP_FLOAT128 FltS8; 66 SETJMP_FLOAT128 FltS9; 67 SETJMP_FLOAT128 FltS10; 68 SETJMP_FLOAT128 FltS11; 69 SETJMP_FLOAT128 FltS12; 70 SETJMP_FLOAT128 FltS13; 71 SETJMP_FLOAT128 FltS14; 72 SETJMP_FLOAT128 FltS15; 73 SETJMP_FLOAT128 FltS16; 74 SETJMP_FLOAT128 FltS17; 75 SETJMP_FLOAT128 FltS18; 76 SETJMP_FLOAT128 FltS19; 77 __MINGW_EXTENSION __int64 FPSR; 78 __MINGW_EXTENSION __int64 StIIP; 79 __MINGW_EXTENSION __int64 BrS0; 80 __MINGW_EXTENSION __int64 BrS1; 81 __MINGW_EXTENSION __int64 BrS2; 82 __MINGW_EXTENSION __int64 BrS3; 83 __MINGW_EXTENSION __int64 BrS4; 84 __MINGW_EXTENSION __int64 IntS0; 85 __MINGW_EXTENSION __int64 IntS1; 86 __MINGW_EXTENSION __int64 IntS2; 87 __MINGW_EXTENSION __int64 IntS3; 88 __MINGW_EXTENSION __int64 RsBSP; 89 __MINGW_EXTENSION __int64 RsPFS; 90 __MINGW_EXTENSION __int64 ApUNAT; 91 __MINGW_EXTENSION __int64 ApLC; 92 __MINGW_EXTENSION __int64 IntSp; 93 __MINGW_EXTENSION __int64 IntNats; 94 __MINGW_EXTENSION __int64 Preds; 95 96 } _JUMP_BUFFER; 97 98 #elif defined(__x86_64) 99 100 typedef _CRT_ALIGN(16) struct _SETJMP_FLOAT128 { 101 __MINGW_EXTENSION unsigned __int64 Part[2]; 102 } SETJMP_FLOAT128; 103 104 #define _JBLEN 16 105 typedef SETJMP_FLOAT128 _JBTYPE; 106 107 typedef struct _JUMP_BUFFER { 108 __MINGW_EXTENSION unsigned __int64 Frame; 109 __MINGW_EXTENSION unsigned __int64 Rbx; 110 __MINGW_EXTENSION unsigned __int64 Rsp; 111 __MINGW_EXTENSION unsigned __int64 Rbp; 112 __MINGW_EXTENSION unsigned __int64 Rsi; 113 __MINGW_EXTENSION unsigned __int64 Rdi; 114 __MINGW_EXTENSION unsigned __int64 R12; 115 __MINGW_EXTENSION unsigned __int64 R13; 116 __MINGW_EXTENSION unsigned __int64 R14; 117 __MINGW_EXTENSION unsigned __int64 R15; 118 __MINGW_EXTENSION unsigned __int64 Rip; 119 __MINGW_EXTENSION unsigned __int64 Spare; 120 SETJMP_FLOAT128 Xmm6; 121 SETJMP_FLOAT128 Xmm7; 122 SETJMP_FLOAT128 Xmm8; 123 SETJMP_FLOAT128 Xmm9; 124 SETJMP_FLOAT128 Xmm10; 125 SETJMP_FLOAT128 Xmm11; 126 SETJMP_FLOAT128 Xmm12; 127 SETJMP_FLOAT128 Xmm13; 128 SETJMP_FLOAT128 Xmm14; 129 SETJMP_FLOAT128 Xmm15; 130 } _JUMP_BUFFER; 131 132 #elif defined(_M_ARM) 133 134 #define _JBLEN 28 135 #define _JBTYPE int 136 137 typedef struct _JUMP_BUFFER { 138 unsigned long Frame; 139 unsigned long R4; 140 unsigned long R5; 141 unsigned long R6; 142 unsigned long R7; 143 unsigned long R8; 144 unsigned long R9; 145 unsigned long R10; 146 unsigned long R11; 147 unsigned long Sp; 148 unsigned long Pc; 149 unsigned long Fpscr; 150 unsigned long long D[8]; // D8-D15 VFP/NEON regs 151 } _JUMP_BUFFER; 152 153 #elif defined(_M_ARM64) 154 155 #define _JBLEN 24 156 #define _JBTYPE unsigned __int64 157 158 typedef struct __JUMP_BUFFER { 159 unsigned __int64 Frame; 160 unsigned __int64 Reserved; 161 unsigned __int64 X19; 162 unsigned __int64 X20; 163 unsigned __int64 X21; 164 unsigned __int64 X22; 165 unsigned __int64 X23; 166 unsigned __int64 X24; 167 unsigned __int64 X25; 168 unsigned __int64 X26; 169 unsigned __int64 X27; 170 unsigned __int64 X28; 171 unsigned __int64 Fp; 172 unsigned __int64 Lr; 173 unsigned __int64 Sp; 174 unsigned long Fpcr; 175 unsigned long Fpsr; 176 double D[8]; 177 } _JUMP_BUFFER; 178 179 #else 180 181 #error Define Setjmp for this architecture! 182 183 #endif 184 185 #ifndef _JMP_BUF_DEFINED 186 typedef _JBTYPE jmp_buf[_JBLEN]; 187 #define _JMP_BUF_DEFINED 188 #endif 189 190 #ifdef USE_MINGW_SETJMP_TWO_ARGS 191 #ifndef _INC_SETJMPEX 192 #if defined(__x86_64) 193 # define mingw_getsp() \ 194 ({ void* value; __asm__ __volatile__("movq %%rsp, %[value]" : [value] "=r" (value)); value; }) 195 #elif defined(_X86_) 196 # define mingw_getsp() \ 197 ({ void* value; __asm__ __volatile__("movl %%esp, %[value]" : [value] "=r" (value)); value; }) 198 #endif 199 #define setjmp(BUF) _setjmp((BUF),mingw_getsp()) 200 int __MINGW_NOTHROW __cdecl _setjmp(jmp_buf _Buf,void *_Ctx); 201 #else /* _INC_SETJMPEX */ 202 #undef setjmp 203 #define setjmp(BUF) _setjmpex((BUF),mingw_getsp()) 204 #define setjmpex(BUF) _setjmpex((BUF),mingw_getsp()) 205 int __MINGW_NOTHROW __cdecl _setjmpex(jmp_buf _Buf,void *_Ctx); 206 #endif /* _INC_SETJMPEX */ 207 #else /* !USE_MINGW_SETJMP_TWO_ARGS */ 208 #ifndef _INC_SETJMPEX 209 #define setjmp _setjmp 210 #endif 211 int __MINGW_NOTHROW __cdecl setjmp(jmp_buf _Buf); 212 #endif /* !USE_MINGW_SETJMP_TWO_ARGS */ 213 214 __declspec(noreturn) __MINGW_NOTHROW void __cdecl ms_longjmp(jmp_buf _Buf,int _Value)/* throw(...)*/; 215 __declspec(noreturn) __MINGW_NOTHROW void __cdecl longjmp(jmp_buf _Buf,int _Value); 216 217 #ifdef __cplusplus 218 } 219 #endif 220 221 #pragma pack(pop) 222 #endif 223