184344399STimo Kreuzer /** 284344399STimo Kreuzer * This file has no copyright assigned and is placed in the Public Domain. 384344399STimo Kreuzer * This file is part of the w64 mingw-runtime package. 484344399STimo Kreuzer * No warranty is given; refer to the file DISCLAIMER within this package. 584344399STimo Kreuzer */ 684344399STimo Kreuzer #ifndef _INC_SETJMP 784344399STimo Kreuzer #define _INC_SETJMP 884344399STimo Kreuzer 9*abbc7840STimo Kreuzer #include <vcruntime.h> 1084344399STimo Kreuzer 1184344399STimo Kreuzer #pragma pack(push,_CRT_PACKING) 1284344399STimo Kreuzer 1384344399STimo Kreuzer #ifdef __cplusplus 1484344399STimo Kreuzer extern "C" { 1584344399STimo Kreuzer #endif 1684344399STimo Kreuzer 1784344399STimo Kreuzer #if (defined(_X86_) && !defined(__x86_64)) 1884344399STimo Kreuzer 1984344399STimo Kreuzer #define _JBLEN 16 2084344399STimo Kreuzer #define _JBTYPE int 2184344399STimo Kreuzer 2284344399STimo Kreuzer typedef struct __JUMP_BUFFER { 2384344399STimo Kreuzer unsigned long Ebp; 2484344399STimo Kreuzer unsigned long Ebx; 2584344399STimo Kreuzer unsigned long Edi; 2684344399STimo Kreuzer unsigned long Esi; 2784344399STimo Kreuzer unsigned long Esp; 2884344399STimo Kreuzer unsigned long Eip; 2984344399STimo Kreuzer unsigned long Registration; 3084344399STimo Kreuzer unsigned long TryLevel; 3184344399STimo Kreuzer unsigned long Cookie; 3284344399STimo Kreuzer unsigned long UnwindFunc; 3384344399STimo Kreuzer unsigned long UnwindData[6]; 3484344399STimo Kreuzer } _JUMP_BUFFER; 3584344399STimo Kreuzer 3684344399STimo Kreuzer #elif defined(__ia64__) 3784344399STimo Kreuzer 3884344399STimo Kreuzer typedef _CRT_ALIGN(16) struct _SETJMP_FLOAT128 { 3984344399STimo Kreuzer __MINGW_EXTENSION __int64 LowPart; 4084344399STimo Kreuzer __MINGW_EXTENSION __int64 HighPart; 4184344399STimo Kreuzer } SETJMP_FLOAT128; 4284344399STimo Kreuzer 4384344399STimo Kreuzer #define _JBLEN 33 4484344399STimo Kreuzer typedef SETJMP_FLOAT128 _JBTYPE; 4584344399STimo Kreuzer 4684344399STimo Kreuzer typedef struct __JUMP_BUFFER { 4784344399STimo Kreuzer 4884344399STimo Kreuzer unsigned long iAReserved[6]; 4984344399STimo Kreuzer 5084344399STimo Kreuzer unsigned long Registration; 5184344399STimo Kreuzer unsigned long TryLevel; 5284344399STimo Kreuzer unsigned long Cookie; 5384344399STimo Kreuzer unsigned long UnwindFunc; 5484344399STimo Kreuzer 5584344399STimo Kreuzer unsigned long UnwindData[6]; 5684344399STimo Kreuzer 5784344399STimo Kreuzer SETJMP_FLOAT128 FltS0; 5884344399STimo Kreuzer SETJMP_FLOAT128 FltS1; 5984344399STimo Kreuzer SETJMP_FLOAT128 FltS2; 6084344399STimo Kreuzer SETJMP_FLOAT128 FltS3; 6184344399STimo Kreuzer SETJMP_FLOAT128 FltS4; 6284344399STimo Kreuzer SETJMP_FLOAT128 FltS5; 6384344399STimo Kreuzer SETJMP_FLOAT128 FltS6; 6484344399STimo Kreuzer SETJMP_FLOAT128 FltS7; 6584344399STimo Kreuzer SETJMP_FLOAT128 FltS8; 6684344399STimo Kreuzer SETJMP_FLOAT128 FltS9; 6784344399STimo Kreuzer SETJMP_FLOAT128 FltS10; 6884344399STimo Kreuzer SETJMP_FLOAT128 FltS11; 6984344399STimo Kreuzer SETJMP_FLOAT128 FltS12; 7084344399STimo Kreuzer SETJMP_FLOAT128 FltS13; 7184344399STimo Kreuzer SETJMP_FLOAT128 FltS14; 7284344399STimo Kreuzer SETJMP_FLOAT128 FltS15; 7384344399STimo Kreuzer SETJMP_FLOAT128 FltS16; 7484344399STimo Kreuzer SETJMP_FLOAT128 FltS17; 7584344399STimo Kreuzer SETJMP_FLOAT128 FltS18; 7684344399STimo Kreuzer SETJMP_FLOAT128 FltS19; 7784344399STimo Kreuzer __MINGW_EXTENSION __int64 FPSR; 7884344399STimo Kreuzer __MINGW_EXTENSION __int64 StIIP; 7984344399STimo Kreuzer __MINGW_EXTENSION __int64 BrS0; 8084344399STimo Kreuzer __MINGW_EXTENSION __int64 BrS1; 8184344399STimo Kreuzer __MINGW_EXTENSION __int64 BrS2; 8284344399STimo Kreuzer __MINGW_EXTENSION __int64 BrS3; 8384344399STimo Kreuzer __MINGW_EXTENSION __int64 BrS4; 8484344399STimo Kreuzer __MINGW_EXTENSION __int64 IntS0; 8584344399STimo Kreuzer __MINGW_EXTENSION __int64 IntS1; 8684344399STimo Kreuzer __MINGW_EXTENSION __int64 IntS2; 8784344399STimo Kreuzer __MINGW_EXTENSION __int64 IntS3; 8884344399STimo Kreuzer __MINGW_EXTENSION __int64 RsBSP; 8984344399STimo Kreuzer __MINGW_EXTENSION __int64 RsPFS; 9084344399STimo Kreuzer __MINGW_EXTENSION __int64 ApUNAT; 9184344399STimo Kreuzer __MINGW_EXTENSION __int64 ApLC; 9284344399STimo Kreuzer __MINGW_EXTENSION __int64 IntSp; 9384344399STimo Kreuzer __MINGW_EXTENSION __int64 IntNats; 9484344399STimo Kreuzer __MINGW_EXTENSION __int64 Preds; 9584344399STimo Kreuzer 9684344399STimo Kreuzer } _JUMP_BUFFER; 9784344399STimo Kreuzer 9884344399STimo Kreuzer #elif defined(__x86_64) 9984344399STimo Kreuzer 10084344399STimo Kreuzer typedef _CRT_ALIGN(16) struct _SETJMP_FLOAT128 { 10184344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 Part[2]; 10284344399STimo Kreuzer } SETJMP_FLOAT128; 10384344399STimo Kreuzer 10484344399STimo Kreuzer #define _JBLEN 16 10584344399STimo Kreuzer typedef SETJMP_FLOAT128 _JBTYPE; 10684344399STimo Kreuzer 10784344399STimo Kreuzer typedef struct _JUMP_BUFFER { 10884344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 Frame; 10984344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 Rbx; 11084344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 Rsp; 11184344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 Rbp; 11284344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 Rsi; 11384344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 Rdi; 11484344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 R12; 11584344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 R13; 11684344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 R14; 11784344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 R15; 11884344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 Rip; 11984344399STimo Kreuzer __MINGW_EXTENSION unsigned __int64 Spare; 12084344399STimo Kreuzer SETJMP_FLOAT128 Xmm6; 12184344399STimo Kreuzer SETJMP_FLOAT128 Xmm7; 12284344399STimo Kreuzer SETJMP_FLOAT128 Xmm8; 12384344399STimo Kreuzer SETJMP_FLOAT128 Xmm9; 12484344399STimo Kreuzer SETJMP_FLOAT128 Xmm10; 12584344399STimo Kreuzer SETJMP_FLOAT128 Xmm11; 12684344399STimo Kreuzer SETJMP_FLOAT128 Xmm12; 12784344399STimo Kreuzer SETJMP_FLOAT128 Xmm13; 12884344399STimo Kreuzer SETJMP_FLOAT128 Xmm14; 12984344399STimo Kreuzer SETJMP_FLOAT128 Xmm15; 13084344399STimo Kreuzer } _JUMP_BUFFER; 13184344399STimo Kreuzer 13284344399STimo Kreuzer #elif defined(_M_ARM) 13384344399STimo Kreuzer 13484344399STimo Kreuzer #define _JBLEN 28 13584344399STimo Kreuzer #define _JBTYPE int 13684344399STimo Kreuzer 13784344399STimo Kreuzer typedef struct _JUMP_BUFFER { 13884344399STimo Kreuzer unsigned long Frame; 13984344399STimo Kreuzer unsigned long R4; 14084344399STimo Kreuzer unsigned long R5; 14184344399STimo Kreuzer unsigned long R6; 14284344399STimo Kreuzer unsigned long R7; 14384344399STimo Kreuzer unsigned long R8; 14484344399STimo Kreuzer unsigned long R9; 14584344399STimo Kreuzer unsigned long R10; 14684344399STimo Kreuzer unsigned long R11; 14784344399STimo Kreuzer unsigned long Sp; 14884344399STimo Kreuzer unsigned long Pc; 14984344399STimo Kreuzer unsigned long Fpscr; 15084344399STimo Kreuzer unsigned long long D[8]; // D8-D15 VFP/NEON regs 15184344399STimo Kreuzer } _JUMP_BUFFER; 15284344399STimo Kreuzer 15384344399STimo Kreuzer #elif defined(_M_ARM64) 15484344399STimo Kreuzer 15584344399STimo Kreuzer #define _JBLEN 24 15684344399STimo Kreuzer #define _JBTYPE unsigned __int64 15784344399STimo Kreuzer 15884344399STimo Kreuzer typedef struct __JUMP_BUFFER { 15984344399STimo Kreuzer unsigned __int64 Frame; 16084344399STimo Kreuzer unsigned __int64 Reserved; 16184344399STimo Kreuzer unsigned __int64 X19; 16284344399STimo Kreuzer unsigned __int64 X20; 16384344399STimo Kreuzer unsigned __int64 X21; 16484344399STimo Kreuzer unsigned __int64 X22; 16584344399STimo Kreuzer unsigned __int64 X23; 16684344399STimo Kreuzer unsigned __int64 X24; 16784344399STimo Kreuzer unsigned __int64 X25; 16884344399STimo Kreuzer unsigned __int64 X26; 16984344399STimo Kreuzer unsigned __int64 X27; 17084344399STimo Kreuzer unsigned __int64 X28; 17184344399STimo Kreuzer unsigned __int64 Fp; 17284344399STimo Kreuzer unsigned __int64 Lr; 17384344399STimo Kreuzer unsigned __int64 Sp; 17484344399STimo Kreuzer unsigned long Fpcr; 17584344399STimo Kreuzer unsigned long Fpsr; 17684344399STimo Kreuzer double D[8]; 17784344399STimo Kreuzer } _JUMP_BUFFER; 17884344399STimo Kreuzer 17984344399STimo Kreuzer #else 18084344399STimo Kreuzer 18184344399STimo Kreuzer #error Define Setjmp for this architecture! 18284344399STimo Kreuzer 18384344399STimo Kreuzer #endif 18484344399STimo Kreuzer 18584344399STimo Kreuzer #ifndef _JMP_BUF_DEFINED 18684344399STimo Kreuzer typedef _JBTYPE jmp_buf[_JBLEN]; 18784344399STimo Kreuzer #define _JMP_BUF_DEFINED 18884344399STimo Kreuzer #endif 18984344399STimo Kreuzer 19084344399STimo Kreuzer #ifdef USE_MINGW_SETJMP_TWO_ARGS 19184344399STimo Kreuzer #ifndef _INC_SETJMPEX 19284344399STimo Kreuzer #if defined(__x86_64) 19384344399STimo Kreuzer # define mingw_getsp() \ 19484344399STimo Kreuzer ({ void* value; __asm__ __volatile__("movq %%rsp, %[value]" : [value] "=r" (value)); value; }) 19584344399STimo Kreuzer #elif defined(_X86_) 19684344399STimo Kreuzer # define mingw_getsp() \ 19784344399STimo Kreuzer ({ void* value; __asm__ __volatile__("movl %%esp, %[value]" : [value] "=r" (value)); value; }) 19884344399STimo Kreuzer #endif 19984344399STimo Kreuzer #define setjmp(BUF) _setjmp((BUF),mingw_getsp()) 20084344399STimo Kreuzer int __MINGW_NOTHROW __cdecl _setjmp(jmp_buf _Buf,void *_Ctx); 20184344399STimo Kreuzer #else /* _INC_SETJMPEX */ 20284344399STimo Kreuzer #undef setjmp 20384344399STimo Kreuzer #define setjmp(BUF) _setjmpex((BUF),mingw_getsp()) 20484344399STimo Kreuzer #define setjmpex(BUF) _setjmpex((BUF),mingw_getsp()) 20584344399STimo Kreuzer int __MINGW_NOTHROW __cdecl _setjmpex(jmp_buf _Buf,void *_Ctx); 20684344399STimo Kreuzer #endif /* _INC_SETJMPEX */ 20784344399STimo Kreuzer #else /* !USE_MINGW_SETJMP_TWO_ARGS */ 20884344399STimo Kreuzer #ifndef _INC_SETJMPEX 20984344399STimo Kreuzer #define setjmp _setjmp 21084344399STimo Kreuzer #endif 21184344399STimo Kreuzer int __MINGW_NOTHROW __cdecl setjmp(jmp_buf _Buf); 21284344399STimo Kreuzer #endif /* !USE_MINGW_SETJMP_TWO_ARGS */ 21384344399STimo Kreuzer 21484344399STimo Kreuzer __declspec(noreturn) __MINGW_NOTHROW void __cdecl ms_longjmp(jmp_buf _Buf,int _Value)/* throw(...)*/; 21584344399STimo Kreuzer __declspec(noreturn) __MINGW_NOTHROW void __cdecl longjmp(jmp_buf _Buf,int _Value); 21684344399STimo Kreuzer 21784344399STimo Kreuzer #ifdef __cplusplus 21884344399STimo Kreuzer } 21984344399STimo Kreuzer #endif 22084344399STimo Kreuzer 22184344399STimo Kreuzer #pragma pack(pop) 22284344399STimo Kreuzer #endif 223