| ... | @@ -190,10 +190,17 @@ typedef char bool; | ... | @@ -190,10 +190,17 @@ typedef char bool; |
| 190 | | 190 | |
| 191 | #if zig_has_builtin(trap) | 191 | #if zig_has_builtin(trap) |
| 192 | #define zig_trap() __builtin_trap() | 192 | #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) |
| 193 | #elif defined(__i386__) || defined(__x86_64__) | 197 | #elif defined(__i386__) || defined(__x86_64__) |
| 194 | #define zig_trap() __asm__ volatile("ud2"); | 198 | #define zig_trap() __asm__ volatile("ud2"); |
| | 199 | #elif defined(__arm__) || defined(__aarch64__) |
| | 200 | #define zig_breakpoint() __asm__ volatile("udf #0"); |
| 195 | #else | 201 | #else |
| 196 | #define zig_trap() raise(SIGTRAP) | 202 | #include <stdlib.h> |
| | 203 | #define zig_trap() abort() |
| 197 | #endif | 204 | #endif |
| 198 | | 205 | |
| 199 | #if zig_has_builtin(debugtrap) | 206 | #if zig_has_builtin(debugtrap) |
| ... | @@ -202,8 +209,17 @@ typedef char bool; | ... | @@ -202,8 +209,17 @@ typedef char bool; |
| 202 | #define zig_breakpoint() __debugbreak() | 209 | #define zig_breakpoint() __debugbreak() |
| 203 | #elif defined(__i386__) || defined(__x86_64__) | 210 | #elif defined(__i386__) || defined(__x86_64__) |
| 204 | #define zig_breakpoint() __asm__ volatile("int $0x03"); | 211 | #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"); |
| 205 | #else | 216 | #else |
| | 217 | #include <signal.h> |
| | 218 | #if defined(SIGTRAP) |
| 206 | #define zig_breakpoint() raise(SIGTRAP) | 219 | #define zig_breakpoint() raise(SIGTRAP) |
| | 220 | #else |
| | 221 | #define zig_breakpoint() zig_breakpoint_unavailable |
| | 222 | #endif |
| 207 | #endif | 223 | #endif |
| 208 | | 224 | |
| 209 | #if zig_has_builtin(return_address) || defined(zig_gnuc) | 225 | #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 | ... | @@ -2384,6 +2400,44 @@ static inline void zig_subw_big(void *res, const void *lhs, const void *rhs, boo |
| 2384 | (void)zig_subo_big(res, lhs, rhs, is_signed, bits); | 2400 | (void)zig_subo_big(res, lhs, rhs, is_signed, bits); |
| 2385 | } | 2401 | } |
| 2386 | | 2402 | |
| | 2403 | zig_extern void __udivei4(uint32_t *res, const uint32_t *lhs, const uint32_t *rhs, uintptr_t bits); |
| | 2404 | static 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 | |
| | 2413 | static 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 | |
| | 2422 | zig_extern void __umodei4(uint32_t *res, const uint32_t *lhs, const uint32_t *rhs, uintptr_t bits); |
| | 2423 | static 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 | |
| | 2432 | static 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 | |
| 2387 | static inline uint16_t zig_clz_big(const void *val, bool is_signed, uint16_t bits) { | 2441 | static inline uint16_t zig_clz_big(const void *val, bool is_signed, uint16_t bits) { |
| 2388 | const uint8_t *val_bytes = val; | 2442 | const uint8_t *val_bytes = val; |
| 2389 | uint16_t byte_offset = 0; | 2443 | uint16_t byte_offset = 0; |