mirror of
https://github.com/ziglang/zig.git
synced 2024-12-02 09:10:17 +00:00
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>
This commit is contained in:
parent
023753b469
commit
5a26d1b426
56
stage1/zig.h
56
stage1/zig.h
@ -190,10 +190,17 @@ typedef char bool;
|
||||
|
||||
#if zig_has_builtin(trap)
|
||||
#define zig_trap() __builtin_trap()
|
||||
#elif _MSC_VER && (_M_IX86 || _M_X64)
|
||||
#define zig_trap() __ud2()
|
||||
#elif _MSC_VER
|
||||
#define zig_trap() __fastfail(0)
|
||||
#elif defined(__i386__) || defined(__x86_64__)
|
||||
#define zig_trap() __asm__ volatile("ud2");
|
||||
#elif defined(__arm__) || defined(__aarch64__)
|
||||
#define zig_breakpoint() __asm__ volatile("udf #0");
|
||||
#else
|
||||
#define zig_trap() raise(SIGTRAP)
|
||||
#include <stdlib.h>
|
||||
#define zig_trap() abort()
|
||||
#endif
|
||||
|
||||
#if zig_has_builtin(debugtrap)
|
||||
@ -202,8 +209,17 @@ typedef char bool;
|
||||
#define zig_breakpoint() __debugbreak()
|
||||
#elif defined(__i386__) || defined(__x86_64__)
|
||||
#define zig_breakpoint() __asm__ volatile("int $0x03");
|
||||
#elif defined(__arm__)
|
||||
#define zig_breakpoint() __asm__ volatile("bkpt #0");
|
||||
#elif defined(__aarch64__)
|
||||
#define zig_breakpoint() __asm__ volatile("brk #0");
|
||||
#else
|
||||
#include <signal.h>
|
||||
#if defined(SIGTRAP)
|
||||
#define zig_breakpoint() raise(SIGTRAP)
|
||||
#else
|
||||
#define zig_breakpoint() zig_breakpoint_unavailable
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#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
|
||||
(void)zig_subo_big(res, lhs, rhs, is_signed, bits);
|
||||
}
|
||||
|
||||
zig_extern void __udivei4(uint32_t *res, const uint32_t *lhs, const uint32_t *rhs, uintptr_t bits);
|
||||
static inline void zig_div_trunc_big(void *res, const void *lhs, const void *rhs, bool is_signed, uint16_t bits) {
|
||||
if (!is_signed) {
|
||||
__udivei4(res, lhs, rhs, bits);
|
||||
return;
|
||||
}
|
||||
|
||||
zig_trap();
|
||||
}
|
||||
|
||||
static inline void zig_div_floor_big(void *res, const void *lhs, const void *rhs, bool is_signed, uint16_t bits) {
|
||||
if (!is_signed) {
|
||||
zig_div_trunc_big(res, lhs, rhs, is_signed, bits);
|
||||
return;
|
||||
}
|
||||
|
||||
zig_trap();
|
||||
}
|
||||
|
||||
zig_extern void __umodei4(uint32_t *res, const uint32_t *lhs, const uint32_t *rhs, uintptr_t bits);
|
||||
static inline void zig_rem_big(void *res, const void *lhs, const void *rhs, bool is_signed, uint16_t bits) {
|
||||
if (!is_signed) {
|
||||
__umodei4(res, lhs, rhs, bits);
|
||||
return;
|
||||
}
|
||||
|
||||
zig_trap();
|
||||
}
|
||||
|
||||
static inline void zig_mod_big(void *res, const void *lhs, const void *rhs, bool is_signed, uint16_t bits) {
|
||||
if (!is_signed) {
|
||||
zig_rem_big(res, lhs, rhs, is_signed, bits);
|
||||
return;
|
||||
}
|
||||
|
||||
zig_trap();
|
||||
}
|
||||
|
||||
static inline uint16_t zig_clz_big(const void *val, bool is_signed, uint16_t bits) {
|
||||
const uint8_t *val_bytes = val;
|
||||
uint16_t byte_offset = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user