mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-17 15:44:18 +08:00
tccpe.c: - fix arm64 unwind codes (to make native set/longjmp() work) sizeof(RUNTIME_FUNCTION) is 8 on arm64 in the first place no need to note stack slots if we don't save any registers anyway arm64-gen.c: - fix long double reg-move - fix arm64_hfa() for structs with float arrays - gfunc_prolog(): setup stackframe eariler (simplifies unwind codes) - new function gv_addr(RC); win32/include/setjmp.h: - provide correct definition for setjmo() (frameoffset = 224) tccasm.c: - support ".quad" with symbol & relocation - support ".size" - fix ". - symbol" arithmetic win32/lib/crt1.c and win32/include/stdlib.h: - do not write to __argc/__argv which reside in msvcrt.dll (msvcrt.dll on arm64 does not like that, crashes on unload) tcc.c,libtcc.c: - new functions tcc_fopen/fclose to avoid different stdio unstances in tcc.exe & libtcc.dll tests & github workflow: - add test-win32.bat to run tests with a tcc compiled by build-tcc.bat - add msvcrt_start.c for gcc/clang to use the same runtime as tcc the problem is that newer gcc as well as clang and cl are linking to newer runtimes (such as UCRT) that have partially different printf format behavior which makes tcctest fail. the solution here is to force these compilers to link with msvcrt.dll just like tcc. Also, there is no gcc on arm64-win32 currently at all. Anyway, this approach to running the github CI tests does not require msys2. But It does rely on gnumake as well as on some 'sh' shell though which seems to be installed somewhere (maybe it is the one from git).
200 lines
4.4 KiB
C
200 lines
4.4 KiB
C
/**
|
|
* This file has no copyright assigned and is placed in the Public Domain.
|
|
* This file is part of the w64 mingw-runtime package.
|
|
* No warranty is given; refer to the file DISCLAIMER within this package.
|
|
*/
|
|
#ifndef _INC_SETJMP
|
|
#define _INC_SETJMP
|
|
|
|
#include <_mingw.h>
|
|
|
|
#pragma pack(push,_CRT_PACKING)
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#if (defined(_X86_) && !defined(__x86_64))
|
|
|
|
#define _JBLEN 16
|
|
#define _JBTYPE int
|
|
|
|
typedef struct __JUMP_BUFFER {
|
|
unsigned long Ebp;
|
|
unsigned long Ebx;
|
|
unsigned long Edi;
|
|
unsigned long Esi;
|
|
unsigned long Esp;
|
|
unsigned long Eip;
|
|
unsigned long Registration;
|
|
unsigned long TryLevel;
|
|
unsigned long Cookie;
|
|
unsigned long UnwindFunc;
|
|
unsigned long UnwindData[6];
|
|
} _JUMP_BUFFER;
|
|
#elif defined(__ia64__)
|
|
typedef _CRT_ALIGN(16) struct _SETJMP_FLOAT128 {
|
|
__int64 LowPart;
|
|
__int64 HighPart;
|
|
} SETJMP_FLOAT128;
|
|
|
|
#define _JBLEN 33
|
|
typedef SETJMP_FLOAT128 _JBTYPE;
|
|
|
|
typedef struct __JUMP_BUFFER {
|
|
|
|
unsigned long iAReserved[6];
|
|
|
|
unsigned long Registration;
|
|
unsigned long TryLevel;
|
|
unsigned long Cookie;
|
|
unsigned long UnwindFunc;
|
|
|
|
unsigned long UnwindData[6];
|
|
|
|
SETJMP_FLOAT128 FltS0;
|
|
SETJMP_FLOAT128 FltS1;
|
|
SETJMP_FLOAT128 FltS2;
|
|
SETJMP_FLOAT128 FltS3;
|
|
SETJMP_FLOAT128 FltS4;
|
|
SETJMP_FLOAT128 FltS5;
|
|
SETJMP_FLOAT128 FltS6;
|
|
SETJMP_FLOAT128 FltS7;
|
|
SETJMP_FLOAT128 FltS8;
|
|
SETJMP_FLOAT128 FltS9;
|
|
SETJMP_FLOAT128 FltS10;
|
|
SETJMP_FLOAT128 FltS11;
|
|
SETJMP_FLOAT128 FltS12;
|
|
SETJMP_FLOAT128 FltS13;
|
|
SETJMP_FLOAT128 FltS14;
|
|
SETJMP_FLOAT128 FltS15;
|
|
SETJMP_FLOAT128 FltS16;
|
|
SETJMP_FLOAT128 FltS17;
|
|
SETJMP_FLOAT128 FltS18;
|
|
SETJMP_FLOAT128 FltS19;
|
|
__int64 FPSR;
|
|
__int64 StIIP;
|
|
__int64 BrS0;
|
|
__int64 BrS1;
|
|
__int64 BrS2;
|
|
__int64 BrS3;
|
|
__int64 BrS4;
|
|
__int64 IntS0;
|
|
__int64 IntS1;
|
|
__int64 IntS2;
|
|
__int64 IntS3;
|
|
__int64 RsBSP;
|
|
__int64 RsPFS;
|
|
__int64 ApUNAT;
|
|
__int64 ApLC;
|
|
__int64 IntSp;
|
|
__int64 IntNats;
|
|
__int64 Preds;
|
|
|
|
} _JUMP_BUFFER;
|
|
#elif defined(__x86_64)
|
|
typedef _CRT_ALIGN(16) struct _SETJMP_FLOAT128 {
|
|
unsigned __int64 Part[2];
|
|
} SETJMP_FLOAT128;
|
|
|
|
#define _JBLEN 16
|
|
typedef SETJMP_FLOAT128 _JBTYPE;
|
|
|
|
typedef struct _JUMP_BUFFER {
|
|
unsigned __int64 Frame;
|
|
unsigned __int64 Rbx;
|
|
unsigned __int64 Rsp;
|
|
unsigned __int64 Rbp;
|
|
unsigned __int64 Rsi;
|
|
unsigned __int64 Rdi;
|
|
unsigned __int64 R12;
|
|
unsigned __int64 R13;
|
|
unsigned __int64 R14;
|
|
unsigned __int64 R15;
|
|
unsigned __int64 Rip;
|
|
unsigned __int64 Spare;
|
|
SETJMP_FLOAT128 Xmm6;
|
|
SETJMP_FLOAT128 Xmm7;
|
|
SETJMP_FLOAT128 Xmm8;
|
|
SETJMP_FLOAT128 Xmm9;
|
|
SETJMP_FLOAT128 Xmm10;
|
|
SETJMP_FLOAT128 Xmm11;
|
|
SETJMP_FLOAT128 Xmm12;
|
|
SETJMP_FLOAT128 Xmm13;
|
|
SETJMP_FLOAT128 Xmm14;
|
|
SETJMP_FLOAT128 Xmm15;
|
|
} _JUMP_BUFFER;
|
|
#elif defined(_ARM_)
|
|
|
|
#define _JBLEN 28
|
|
#define _JBTYPE int
|
|
|
|
typedef struct __JUMP_BUFFER {
|
|
unsigned long Frame;
|
|
unsigned long R4;
|
|
unsigned long R5;
|
|
unsigned long R6;
|
|
unsigned long R7;
|
|
unsigned long R8;
|
|
unsigned long R9;
|
|
unsigned long R10;
|
|
unsigned long R11;
|
|
unsigned long Sp;
|
|
unsigned long Pc;
|
|
unsigned long Fpscr;
|
|
unsigned long long D[8];
|
|
} _JUMP_BUFFER;
|
|
#elif defined(_ARM64_)
|
|
|
|
#define _JBLEN 24
|
|
#define _JBTYPE unsigned __int64
|
|
|
|
typedef struct __JUMP_BUFFER {
|
|
unsigned __int64 Frame;
|
|
unsigned __int64 Reserved;
|
|
unsigned __int64 X19;
|
|
unsigned __int64 X20;
|
|
unsigned __int64 X21;
|
|
unsigned __int64 X22;
|
|
unsigned __int64 X23;
|
|
unsigned __int64 X24;
|
|
unsigned __int64 X25;
|
|
unsigned __int64 X26;
|
|
unsigned __int64 X27;
|
|
unsigned __int64 X28;
|
|
unsigned __int64 Fp;
|
|
unsigned __int64 Lr;
|
|
unsigned __int64 Sp;
|
|
unsigned long Fpcr;
|
|
unsigned long Fpsr;
|
|
double D[8];
|
|
} _JUMP_BUFFER;
|
|
#else
|
|
#define _JBLEN 1
|
|
#define _JBTYPE int
|
|
#endif
|
|
#ifndef _JMP_BUF_DEFINED
|
|
typedef _JBTYPE jmp_buf[_JBLEN];
|
|
#define _JMP_BUF_DEFINED
|
|
#endif
|
|
|
|
#pragma pack(pop)
|
|
|
|
#if defined __aarch64__
|
|
int _setjmpex(jmp_buf _Buf, void *frame);
|
|
#define setjmp(BUF) _setjmpex((BUF), (char*)__builtin_frame_address(0) + 224)
|
|
#elif defined __x86_64__
|
|
int _setjmp(jmp_buf _Buf, void *frame);
|
|
#define setjmp(BUF) _setjmp((BUF), __builtin_frame_address(0))
|
|
#else /* __i386__ */
|
|
int _setjmp(jmp_buf _Buf);
|
|
#define setjmp _setjmp
|
|
#endif
|
|
|
|
__declspec(noreturn) void longjmp(jmp_buf _Buf,int _Value);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|