authorgravatar for milobanks@rowlandhall.orgLavt Niveau <milobanks@rowlandhall.org> 2023-03-10 06:36:43-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-03-10 13:36:43+00:00
log5a26d1b4268b2e4598e0c39d3703d184921cfa6d
tree359277e0f95f61d180e31f59da6f26574c85650e
parent023753b4693317055e8094059f6195d041311b5d
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Include `signal.h` to define SIGTRAP in Stage 1 compiler (#14867)

copy lib/zig.h to stage1/zig.h In this case, it looks safe to backport over with no changes. Co-authored-by: Andrew Kelley <andrew@ziglang.org>

1 files changed, 55 insertions(+), 1 deletions(-)

stage1/zig.h+55-1
......@@ -190,10 +190,17 @@ typedef char bool;
190190
191191#if zig_has_builtin(trap)
192192#define zig_trap() __builtin_trap()
193#elif _MSC_VER && (_M_IX86 || _M_X64)
194#define zig_trap() __ud2()
195#elif _MSC_VER
196#define zig_trap() __fastfail(0)
193197#elif defined(__i386__) || defined(__x86_64__)
194198#define zig_trap() __asm__ volatile("ud2");
199#elif defined(__arm__) || defined(__aarch64__)
200#define zig_breakpoint() __asm__ volatile("udf #0");
195201#else
196#define zig_trap() raise(SIGTRAP)
202#include <stdlib.h>
203#define zig_trap() abort()
197204#endif
198205
199206#if zig_has_builtin(debugtrap)
......@@ -202,8 +209,17 @@ typedef char bool;
202209#define zig_breakpoint() __debugbreak()
203210#elif defined(__i386__) || defined(__x86_64__)
204211#define zig_breakpoint() __asm__ volatile("int $0x03");
212#elif defined(__arm__)
213#define zig_breakpoint() __asm__ volatile("bkpt #0");
214#elif defined(__aarch64__)
215#define zig_breakpoint() __asm__ volatile("brk #0");
205216#else
217#include <signal.h>
218#if defined(SIGTRAP)
206219#define zig_breakpoint() raise(SIGTRAP)
220#else
221#define zig_breakpoint() zig_breakpoint_unavailable
222#endif
207223#endif
208224
209225#if zig_has_builtin(return_address) || defined(zig_gnuc)
......@@ -2384,6 +2400,44 @@ static inline void zig_subw_big(void *res, const void *lhs, const void *rhs, boo
23842400 (void)zig_subo_big(res, lhs, rhs, is_signed, bits);
23852401}
23862402
2403zig_extern void __udivei4(uint32_t *res, const uint32_t *lhs, const uint32_t *rhs, uintptr_t bits);
2404static inline void zig_div_trunc_big(void *res, const void *lhs, const void *rhs, bool is_signed, uint16_t bits) {
2405 if (!is_signed) {
2406 __udivei4(res, lhs, rhs, bits);
2407 return;
2408 }
2409
2410 zig_trap();
2411}
2412
2413static inline void zig_div_floor_big(void *res, const void *lhs, const void *rhs, bool is_signed, uint16_t bits) {
2414 if (!is_signed) {
2415 zig_div_trunc_big(res, lhs, rhs, is_signed, bits);
2416 return;
2417 }
2418
2419 zig_trap();
2420}
2421
2422zig_extern void __umodei4(uint32_t *res, const uint32_t *lhs, const uint32_t *rhs, uintptr_t bits);
2423static inline void zig_rem_big(void *res, const void *lhs, const void *rhs, bool is_signed, uint16_t bits) {
2424 if (!is_signed) {
2425 __umodei4(res, lhs, rhs, bits);
2426 return;
2427 }
2428
2429 zig_trap();
2430}
2431
2432static inline void zig_mod_big(void *res, const void *lhs, const void *rhs, bool is_signed, uint16_t bits) {
2433 if (!is_signed) {
2434 zig_rem_big(res, lhs, rhs, is_signed, bits);
2435 return;
2436 }
2437
2438 zig_trap();
2439}
2440
23872441static inline uint16_t zig_clz_big(const void *val, bool is_signed, uint16_t bits) {
23882442 const uint8_t *val_bytes = val;
23892443 uint16_t byte_offset = 0;