| ... | ... | @@ -90,7 +90,7 @@ typedef char bool; |
| 90 | 90 | #define zig_align_fn zig_align_fn_unavailable |
| 91 | 91 | #endif |
| 92 | 92 | |
| 93 | | #if zig_has_builtin(unreachable) |
| 93 | #if zig_has_builtin(unreachable) || defined(__GNUC__) |
| 94 | 94 | #define zig_unreachable() __builtin_unreachable() |
| 95 | 95 | #else |
| 96 | 96 | #define zig_unreachable() |
| ... | ... | @@ -113,7 +113,7 @@ typedef char bool; |
| 113 | 113 | |
| 114 | 114 | #if zig_has_builtin(debugtrap) |
| 115 | 115 | #define zig_breakpoint() __builtin_debugtrap() |
| 116 | | #elif zig_has_builtin(trap) |
| 116 | #elif zig_has_builtin(trap) || defined(__GNUC__) |
| 117 | 117 | #define zig_breakpoint() __builtin_trap() |
| 118 | 118 | #elif defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) |
| 119 | 119 | #define zig_breakpoint() __debugbreak() |
| ... | ... | @@ -123,7 +123,7 @@ typedef char bool; |
| 123 | 123 | #define zig_breakpoint() raise(SIGTRAP) |
| 124 | 124 | #endif |
| 125 | 125 | |
| 126 | | #if zig_has_builtin(return_address) |
| 126 | #if zig_has_builtin(return_address) || defined(__GNUC__) |
| 127 | 127 | #define zig_return_address() __builtin_extract_return_addr(__builtin_return_address(0)) |
| 128 | 128 | #elif defined(_MSC_VER) |
| 129 | 129 | #define zig_return_address() _ReturnAddress() |
| ... | ... | @@ -131,13 +131,13 @@ typedef char bool; |
| 131 | 131 | #define zig_return_address() 0 |
| 132 | 132 | #endif |
| 133 | 133 | |
| 134 | | #if zig_has_builtin(frame_address) |
| 134 | #if zig_has_builtin(frame_address) || defined(__GNUC__) |
| 135 | 135 | #define zig_frame_address() __builtin_frame_address(0) |
| 136 | 136 | #else |
| 137 | 137 | #define zig_frame_address() 0 |
| 138 | 138 | #endif |
| 139 | 139 | |
| 140 | | #if zig_has_builtin(prefetch) |
| 140 | #if zig_has_builtin(prefetch) || defined(__GNUC__) |
| 141 | 141 | #define zig_prefetch(addr, rw, locality) __builtin_prefetch(addr, rw, locality) |
| 142 | 142 | #else |
| 143 | 143 | #define zig_prefetch(addr, rw, locality) |
| ... | ... | @@ -412,7 +412,7 @@ zig_int_helpers(32) |
| 412 | 412 | zig_int_helpers(64) |
| 413 | 413 | |
| 414 | 414 | static inline bool zig_addo_u32(zig_u32 *res, zig_u32 lhs, zig_u32 rhs, zig_u8 bits) { |
| 415 | | #if zig_has_builtin(add_overflow) |
| 415 | #if zig_has_builtin(add_overflow) || defined(__GNUC__) |
| 416 | 416 | zig_u32 full_res; |
| 417 | 417 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); |
| 418 | 418 | *res = zig_wrap_u32(full_res, bits); |
| ... | ... | @@ -431,7 +431,7 @@ static inline void zig_vaddo_u32(zig_u8 *ov, zig_u32 *res, int n, |
| 431 | 431 | |
| 432 | 432 | zig_extern zig_i32 __addosi4(zig_i32 lhs, zig_i32 rhs, zig_c_int *overflow); |
| 433 | 433 | static inline bool zig_addo_i32(zig_i32 *res, zig_i32 lhs, zig_i32 rhs, zig_u8 bits) { |
| 434 | | #if zig_has_builtin(add_overflow) |
| 434 | #if zig_has_builtin(add_overflow) || defined(__GNUC__) |
| 435 | 435 | zig_i32 full_res; |
| 436 | 436 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); |
| 437 | 437 | #else |
| ... | ... | @@ -450,7 +450,7 @@ static inline void zig_vaddo_i32(zig_u8 *ov, zig_i32 *res, int n, |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | static inline bool zig_addo_u64(zig_u64 *res, zig_u64 lhs, zig_u64 rhs, zig_u8 bits) { |
| 453 | | #if zig_has_builtin(add_overflow) |
| 453 | #if zig_has_builtin(add_overflow) || defined(__GNUC__) |
| 454 | 454 | zig_u64 full_res; |
| 455 | 455 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); |
| 456 | 456 | *res = zig_wrap_u64(full_res, bits); |
| ... | ... | @@ -469,7 +469,7 @@ static inline void zig_vaddo_u64(zig_u8 *ov, zig_u64 *res, int n, |
| 469 | 469 | |
| 470 | 470 | zig_extern zig_i64 __addodi4(zig_i64 lhs, zig_i64 rhs, zig_c_int *overflow); |
| 471 | 471 | static inline bool zig_addo_i64(zig_i64 *res, zig_i64 lhs, zig_i64 rhs, zig_u8 bits) { |
| 472 | | #if zig_has_builtin(add_overflow) |
| 472 | #if zig_has_builtin(add_overflow) || defined(__GNUC__) |
| 473 | 473 | zig_i64 full_res; |
| 474 | 474 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); |
| 475 | 475 | #else |
| ... | ... | @@ -488,7 +488,7 @@ static inline void zig_vaddo_i64(zig_u8 *ov, zig_i64 *res, int n, |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | static inline bool zig_addo_u8(zig_u8 *res, zig_u8 lhs, zig_u8 rhs, zig_u8 bits) { |
| 491 | | #if zig_has_builtin(add_overflow) |
| 491 | #if zig_has_builtin(add_overflow) || defined(__GNUC__) |
| 492 | 492 | zig_u8 full_res; |
| 493 | 493 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); |
| 494 | 494 | *res = zig_wrap_u8(full_res, bits); |
| ... | ... | @@ -508,7 +508,7 @@ static inline void zig_vaddo_u8(zig_u8 *ov, zig_u8 *res, int n, |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | static inline bool zig_addo_i8(zig_i8 *res, zig_i8 lhs, zig_i8 rhs, zig_u8 bits) { |
| 511 | | #if zig_has_builtin(add_overflow) |
| 511 | #if zig_has_builtin(add_overflow) || defined(__GNUC__) |
| 512 | 512 | zig_i8 full_res; |
| 513 | 513 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); |
| 514 | 514 | *res = zig_wrap_i8(full_res, bits); |
| ... | ... | @@ -528,7 +528,7 @@ static inline void zig_vaddo_i8(zig_u8 *ov, zig_i8 *res, int n, |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | static inline bool zig_addo_u16(zig_u16 *res, zig_u16 lhs, zig_u16 rhs, zig_u8 bits) { |
| 531 | | #if zig_has_builtin(add_overflow) |
| 531 | #if zig_has_builtin(add_overflow) || defined(__GNUC__) |
| 532 | 532 | zig_u16 full_res; |
| 533 | 533 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); |
| 534 | 534 | *res = zig_wrap_u16(full_res, bits); |
| ... | ... | @@ -548,7 +548,7 @@ static inline void zig_vaddo_u16(zig_u8 *ov, zig_u16 *res, int n, |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | static inline bool zig_addo_i16(zig_i16 *res, zig_i16 lhs, zig_i16 rhs, zig_u8 bits) { |
| 551 | | #if zig_has_builtin(add_overflow) |
| 551 | #if zig_has_builtin(add_overflow) || defined(__GNUC__) |
| 552 | 552 | zig_i16 full_res; |
| 553 | 553 | bool overflow = __builtin_add_overflow(lhs, rhs, &full_res); |
| 554 | 554 | *res = zig_wrap_i16(full_res, bits); |
| ... | ... | @@ -568,7 +568,7 @@ static inline void zig_vaddo_i16(zig_u8 *ov, zig_i16 *res, int n, |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | static inline bool zig_subo_u32(zig_u32 *res, zig_u32 lhs, zig_u32 rhs, zig_u8 bits) { |
| 571 | | #if zig_has_builtin(sub_overflow) |
| 571 | #if zig_has_builtin(sub_overflow) || defined(__GNUC__) |
| 572 | 572 | zig_u32 full_res; |
| 573 | 573 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); |
| 574 | 574 | *res = zig_wrap_u32(full_res, bits); |
| ... | ... | @@ -587,7 +587,7 @@ static inline void zig_vsubo_u32(zig_u8 *ov, zig_u32 *res, int n, |
| 587 | 587 | |
| 588 | 588 | zig_extern zig_i32 __subosi4(zig_i32 lhs, zig_i32 rhs, zig_c_int *overflow); |
| 589 | 589 | static inline bool zig_subo_i32(zig_i32 *res, zig_i32 lhs, zig_i32 rhs, zig_u8 bits) { |
| 590 | | #if zig_has_builtin(sub_overflow) |
| 590 | #if zig_has_builtin(sub_overflow) || defined(__GNUC__) |
| 591 | 591 | zig_i32 full_res; |
| 592 | 592 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); |
| 593 | 593 | #else |
| ... | ... | @@ -606,7 +606,7 @@ static inline void zig_vsubo_i32(zig_u8 *ov, zig_i32 *res, int n, |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | static inline bool zig_subo_u64(zig_u64 *res, zig_u64 lhs, zig_u64 rhs, zig_u8 bits) { |
| 609 | | #if zig_has_builtin(sub_overflow) |
| 609 | #if zig_has_builtin(sub_overflow) || defined(__GNUC__) |
| 610 | 610 | zig_u64 full_res; |
| 611 | 611 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); |
| 612 | 612 | *res = zig_wrap_u64(full_res, bits); |
| ... | ... | @@ -625,7 +625,7 @@ static inline void zig_vsubo_u64(zig_u8 *ov, zig_u64 *res, int n, |
| 625 | 625 | |
| 626 | 626 | zig_extern zig_i64 __subodi4(zig_i64 lhs, zig_i64 rhs, zig_c_int *overflow); |
| 627 | 627 | static inline bool zig_subo_i64(zig_i64 *res, zig_i64 lhs, zig_i64 rhs, zig_u8 bits) { |
| 628 | | #if zig_has_builtin(sub_overflow) |
| 628 | #if zig_has_builtin(sub_overflow) || defined(__GNUC__) |
| 629 | 629 | zig_i64 full_res; |
| 630 | 630 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); |
| 631 | 631 | #else |
| ... | ... | @@ -644,7 +644,7 @@ static inline void zig_vsubo_i64(zig_u8 *ov, zig_i64 *res, int n, |
| 644 | 644 | } |
| 645 | 645 | |
| 646 | 646 | static inline bool zig_subo_u8(zig_u8 *res, zig_u8 lhs, zig_u8 rhs, zig_u8 bits) { |
| 647 | | #if zig_has_builtin(sub_overflow) |
| 647 | #if zig_has_builtin(sub_overflow) || defined(__GNUC__) |
| 648 | 648 | zig_u8 full_res; |
| 649 | 649 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); |
| 650 | 650 | *res = zig_wrap_u8(full_res, bits); |
| ... | ... | @@ -664,7 +664,7 @@ static inline void zig_vsubo_u8(zig_u8 *ov, zig_u8 *res, int n, |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | static inline bool zig_subo_i8(zig_i8 *res, zig_i8 lhs, zig_i8 rhs, zig_u8 bits) { |
| 667 | | #if zig_has_builtin(sub_overflow) |
| 667 | #if zig_has_builtin(sub_overflow) || defined(__GNUC__) |
| 668 | 668 | zig_i8 full_res; |
| 669 | 669 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); |
| 670 | 670 | *res = zig_wrap_i8(full_res, bits); |
| ... | ... | @@ -685,7 +685,7 @@ static inline void zig_vsubo_i8(zig_u8 *ov, zig_i8 *res, int n, |
| 685 | 685 | |
| 686 | 686 | |
| 687 | 687 | static inline bool zig_subo_u16(zig_u16 *res, zig_u16 lhs, zig_u16 rhs, zig_u8 bits) { |
| 688 | | #if zig_has_builtin(sub_overflow) |
| 688 | #if zig_has_builtin(sub_overflow) || defined(__GNUC__) |
| 689 | 689 | zig_u16 full_res; |
| 690 | 690 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); |
| 691 | 691 | *res = zig_wrap_u16(full_res, bits); |
| ... | ... | @@ -706,7 +706,7 @@ static inline void zig_vsubo_u16(zig_u8 *ov, zig_u16 *res, int n, |
| 706 | 706 | |
| 707 | 707 | |
| 708 | 708 | static inline bool zig_subo_i16(zig_i16 *res, zig_i16 lhs, zig_i16 rhs, zig_u8 bits) { |
| 709 | | #if zig_has_builtin(sub_overflow) |
| 709 | #if zig_has_builtin(sub_overflow) || defined(__GNUC__) |
| 710 | 710 | zig_i16 full_res; |
| 711 | 711 | bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res); |
| 712 | 712 | *res = zig_wrap_i16(full_res, bits); |
| ... | ... | @@ -726,7 +726,7 @@ static inline void zig_vsubo_i16(zig_u8 *ov, zig_i16 *res, int n, |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | static inline bool zig_mulo_u32(zig_u32 *res, zig_u32 lhs, zig_u32 rhs, zig_u8 bits) { |
| 729 | | #if zig_has_builtin(mul_overflow) |
| 729 | #if zig_has_builtin(mul_overflow) || defined(__GNUC__) |
| 730 | 730 | zig_u32 full_res; |
| 731 | 731 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); |
| 732 | 732 | *res = zig_wrap_u32(full_res, bits); |
| ... | ... | @@ -745,7 +745,7 @@ static inline void zig_vmulo_u32(zig_u8 *ov, zig_u32 *res, int n, |
| 745 | 745 | |
| 746 | 746 | zig_extern zig_i32 __mulosi4(zig_i32 lhs, zig_i32 rhs, zig_c_int *overflow); |
| 747 | 747 | static inline bool zig_mulo_i32(zig_i32 *res, zig_i32 lhs, zig_i32 rhs, zig_u8 bits) { |
| 748 | | #if zig_has_builtin(mul_overflow) |
| 748 | #if zig_has_builtin(mul_overflow) || defined(__GNUC__) |
| 749 | 749 | zig_i32 full_res; |
| 750 | 750 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); |
| 751 | 751 | #else |
| ... | ... | @@ -764,7 +764,7 @@ static inline void zig_vmulo_i32(zig_u8 *ov, zig_i32 *res, int n, |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | static inline bool zig_mulo_u64(zig_u64 *res, zig_u64 lhs, zig_u64 rhs, zig_u8 bits) { |
| 767 | | #if zig_has_builtin(mul_overflow) |
| 767 | #if zig_has_builtin(mul_overflow) || defined(__GNUC__) |
| 768 | 768 | zig_u64 full_res; |
| 769 | 769 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); |
| 770 | 770 | *res = zig_wrap_u64(full_res, bits); |
| ... | ... | @@ -783,7 +783,7 @@ static inline void zig_vmulo_u64(zig_u8 *ov, zig_u64 *res, int n, |
| 783 | 783 | |
| 784 | 784 | zig_extern zig_i64 __mulodi4(zig_i64 lhs, zig_i64 rhs, zig_c_int *overflow); |
| 785 | 785 | static inline bool zig_mulo_i64(zig_i64 *res, zig_i64 lhs, zig_i64 rhs, zig_u8 bits) { |
| 786 | | #if zig_has_builtin(mul_overflow) |
| 786 | #if zig_has_builtin(mul_overflow) || defined(__GNUC__) |
| 787 | 787 | zig_i64 full_res; |
| 788 | 788 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); |
| 789 | 789 | #else |
| ... | ... | @@ -802,7 +802,7 @@ static inline void zig_vmulo_i64(zig_u8 *ov, zig_i64 *res, int n, |
| 802 | 802 | } |
| 803 | 803 | |
| 804 | 804 | static inline bool zig_mulo_u8(zig_u8 *res, zig_u8 lhs, zig_u8 rhs, zig_u8 bits) { |
| 805 | | #if zig_has_builtin(mul_overflow) |
| 805 | #if zig_has_builtin(mul_overflow) || defined(__GNUC__) |
| 806 | 806 | zig_u8 full_res; |
| 807 | 807 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); |
| 808 | 808 | *res = zig_wrap_u8(full_res, bits); |
| ... | ... | @@ -822,7 +822,7 @@ static inline void zig_vmulo_u8(zig_u8 *ov, zig_u8 *res, int n, |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | static inline bool zig_mulo_i8(zig_i8 *res, zig_i8 lhs, zig_i8 rhs, zig_u8 bits) { |
| 825 | | #if zig_has_builtin(mul_overflow) |
| 825 | #if zig_has_builtin(mul_overflow) || defined(__GNUC__) |
| 826 | 826 | zig_i8 full_res; |
| 827 | 827 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); |
| 828 | 828 | *res = zig_wrap_i8(full_res, bits); |
| ... | ... | @@ -842,7 +842,7 @@ static inline void zig_vmulo_i8(zig_u8 *ov, zig_i8 *res, int n, |
| 842 | 842 | } |
| 843 | 843 | |
| 844 | 844 | static inline bool zig_mulo_u16(zig_u16 *res, zig_u16 lhs, zig_u16 rhs, zig_u8 bits) { |
| 845 | | #if zig_has_builtin(mul_overflow) |
| 845 | #if zig_has_builtin(mul_overflow) || defined(__GNUC__) |
| 846 | 846 | zig_u16 full_res; |
| 847 | 847 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); |
| 848 | 848 | *res = zig_wrap_u16(full_res, bits); |
| ... | ... | @@ -862,7 +862,7 @@ static inline void zig_vmulo_u16(zig_u8 *ov, zig_u16 *res, int n, |
| 862 | 862 | } |
| 863 | 863 | |
| 864 | 864 | static inline bool zig_mulo_i16(zig_i16 *res, zig_i16 lhs, zig_i16 rhs, zig_u8 bits) { |
| 865 | | #if zig_has_builtin(mul_overflow) |
| 865 | #if zig_has_builtin(mul_overflow) || defined(__GNUC__) |
| 866 | 866 | zig_i16 full_res; |
| 867 | 867 | bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res); |
| 868 | 868 | *res = zig_wrap_i16(full_res, bits); |
| ... | ... | @@ -977,7 +977,7 @@ static inline zig_i8 zig_byte_swap_i8(zig_i8 val, zig_u8 bits) { |
| 977 | 977 | |
| 978 | 978 | static inline zig_u16 zig_byte_swap_u16(zig_u16 val, zig_u8 bits) { |
| 979 | 979 | zig_u16 full_res; |
| 980 | | #if zig_has_builtin(bswap16) |
| 980 | #if zig_has_builtin(bswap16) || defined(__GNUC__) |
| 981 | 981 | full_res = __builtin_bswap16(val); |
| 982 | 982 | #else |
| 983 | 983 | full_res = (zig_u16)zig_byte_swap_u8((zig_u8)(val >> 0), 8) << 8 | |
| ... | ... | @@ -992,7 +992,7 @@ static inline zig_i16 zig_byte_swap_i16(zig_i16 val, zig_u8 bits) { |
| 992 | 992 | |
| 993 | 993 | static inline zig_u32 zig_byte_swap_u32(zig_u32 val, zig_u8 bits) { |
| 994 | 994 | zig_u32 full_res; |
| 995 | | #if zig_has_builtin(bswap32) |
| 995 | #if zig_has_builtin(bswap32) || defined(__GNUC__) |
| 996 | 996 | full_res = __builtin_bswap32(val); |
| 997 | 997 | #else |
| 998 | 998 | full_res = (zig_u32)zig_byte_swap_u16((zig_u16)(val >> 0), 16) << 16 | |
| ... | ... | @@ -1007,7 +1007,7 @@ static inline zig_i32 zig_byte_swap_i32(zig_i32 val, zig_u8 bits) { |
| 1007 | 1007 | |
| 1008 | 1008 | static inline zig_u64 zig_byte_swap_u64(zig_u64 val, zig_u8 bits) { |
| 1009 | 1009 | zig_u64 full_res; |
| 1010 | | #if zig_has_builtin(bswap64) |
| 1010 | #if zig_has_builtin(bswap64) || defined(__GNUC__) |
| 1011 | 1011 | full_res = __builtin_bswap64(val); |
| 1012 | 1012 | #else |
| 1013 | 1013 | full_res = (zig_u64)zig_byte_swap_u32((zig_u32)(val >> 0), 32) << 32 | |
| ... | ... | @@ -1087,7 +1087,7 @@ static inline zig_i64 zig_bit_reverse_i64(zig_i64 val, zig_u8 bits) { |
| 1087 | 1087 | static inline zig_u8 zig_popcount_i##w(zig_i##w val, zig_u8 bits) { \ |
| 1088 | 1088 | return zig_popcount_u##w((zig_u##w)val, bits); \ |
| 1089 | 1089 | } |
| 1090 | | #if zig_has_builtin(popcount) |
| 1090 | #if zig_has_builtin(popcount) || defined(__GNUC__) |
| 1091 | 1091 | #define zig_builtin_popcount(w) \ |
| 1092 | 1092 | static inline zig_u8 zig_popcount_u##w(zig_u##w val, zig_u8 bits) { \ |
| 1093 | 1093 | (void)bits; \ |
| ... | ... | @@ -1116,7 +1116,7 @@ zig_builtin_popcount(64) |
| 1116 | 1116 | static inline zig_u8 zig_ctz_i##w(zig_i##w val, zig_u8 bits) { \ |
| 1117 | 1117 | return zig_ctz_u##w((zig_u##w)val, bits); \ |
| 1118 | 1118 | } |
| 1119 | | #if zig_has_builtin(ctz) |
| 1119 | #if zig_has_builtin(ctz) || defined(__GNUC__) |
| 1120 | 1120 | #define zig_builtin_ctz(w) \ |
| 1121 | 1121 | static inline zig_u8 zig_ctz_u##w(zig_u##w val, zig_u8 bits) { \ |
| 1122 | 1122 | if (val == 0) return bits; \ |
| ... | ... | @@ -1141,7 +1141,7 @@ zig_builtin_ctz(64) |
| 1141 | 1141 | static inline zig_u8 zig_clz_i##w(zig_i##w val, zig_u8 bits) { \ |
| 1142 | 1142 | return zig_clz_u##w((zig_u##w)val, bits); \ |
| 1143 | 1143 | } |
| 1144 | | #if zig_has_builtin(clz) |
| 1144 | #if zig_has_builtin(clz) || defined(__GNUC__) |
| 1145 | 1145 | #define zig_builtin_clz(w) \ |
| 1146 | 1146 | static inline zig_u8 zig_clz_u##w(zig_u##w val, zig_u8 bits) { \ |
| 1147 | 1147 | if (val == 0) return bits; \ |
| ... | ... | @@ -1764,8 +1764,8 @@ static inline zig_i128 zig_bit_reverse_i128(zig_i128 val, zig_u8 bits) { |
| 1764 | 1764 | #define __builtin_infl() zig_msvc_flt_infl |
| 1765 | 1765 | #endif |
| 1766 | 1766 | |
| 1767 | | #define zig_has_float_builtins (zig_has_builtin(nan) && zig_has_builtin(nans) && zig_has_builtin(inf)) |
| 1768 | | #if zig_has_float_builtins |
| 1767 | |
| 1768 | #if (zig_has_builtin(nan) && zig_has_builtin(nans) && zig_has_builtin(inf)) || defined(__GNUC__) |
| 1769 | 1769 | #define zig_as_special_f16(sign, name, arg, repr) sign zig_as_f16(__builtin_##name, )(arg) |
| 1770 | 1770 | #define zig_as_special_f32(sign, name, arg, repr) sign zig_as_f32(__builtin_##name, )(arg) |
| 1771 | 1771 | #define zig_as_special_f64(sign, name, arg, repr) sign zig_as_f64(__builtin_##name, )(arg) |
| ... | ... | @@ -1773,6 +1773,16 @@ static inline zig_i128 zig_bit_reverse_i128(zig_i128 val, zig_u8 bits) { |
| 1773 | 1773 | #define zig_as_special_f128(sign, name, arg, repr) sign zig_as_f128(__builtin_##name, )(arg) |
| 1774 | 1774 | #define zig_as_special_c_longdouble(sign, name, arg, repr) sign zig_as_c_longdouble(__builtin_##name, )(arg) |
| 1775 | 1775 | #else |
| 1776 | #define zig_float_from_repr(Type, ReprType) \ |
| 1777 | static inline zig_##Type zig_float_from_repr_##Type(zig_##ReprType repr) { \ |
| 1778 | return *((zig_##Type*)&repr); \ |
| 1779 | } |
| 1780 | zig_float_from_repr(f16, u16) |
| 1781 | zig_float_from_repr(f32, u32) |
| 1782 | zig_float_from_repr(f64, u64) |
| 1783 | zig_float_from_repr(f80, u128) |
| 1784 | zig_float_from_repr(f128, u128) |
| 1785 | zig_float_from_repr(c_longdouble, u128) |
| 1776 | 1786 | #define zig_as_special_f16(sign, name, arg, repr) zig_float_from_repr_f16(repr) |
| 1777 | 1787 | #define zig_as_special_f32(sign, name, arg, repr) zig_float_from_repr_f32(repr) |
| 1778 | 1788 | #define zig_as_special_f64(sign, name, arg, repr) zig_float_from_repr_f64(repr) |
| ... | ... | @@ -1795,7 +1805,7 @@ typedef double zig_f16; |
| 1795 | 1805 | #define zig_bitSizeOf_c_longdouble 16 |
| 1796 | 1806 | typedef long double zig_f16; |
| 1797 | 1807 | #define zig_as_f16(fp, repr) fp##l |
| 1798 | | #elif FLT16_MANT_DIG == 11 && zig_has_builtin(inff16) |
| 1808 | #elif FLT16_MANT_DIG == 11 && (zig_has_builtin(inff16) || defined(__GNUC__)) |
| 1799 | 1809 | typedef _Float16 zig_f16; |
| 1800 | 1810 | #define zig_as_f16(fp, repr) fp##f16 |
| 1801 | 1811 | #elif defined(__SIZEOF_FP16__) |
| ... | ... | @@ -1974,20 +1984,6 @@ typedef zig_i128 zig_c_longdouble; |
| 1974 | 1984 | #define zig_as_special_constant_c_longdouble(sign, name, arg, repr) repr |
| 1975 | 1985 | #endif |
| 1976 | 1986 | |
| 1977 | | #if !zig_has_float_builtins |
| 1978 | | #define zig_float_from_repr(Type, ReprType) \ |
| 1979 | | static inline zig_##Type zig_float_from_repr_##Type(zig_##ReprType repr) { \ |
| 1980 | | return *((zig_##Type*)&repr); \ |
| 1981 | | } |
| 1982 | | |
| 1983 | | zig_float_from_repr(f16, u16) |
| 1984 | | zig_float_from_repr(f32, u32) |
| 1985 | | zig_float_from_repr(f64, u64) |
| 1986 | | zig_float_from_repr(f80, u128) |
| 1987 | | zig_float_from_repr(f128, u128) |
| 1988 | | zig_float_from_repr(c_longdouble, u128) |
| 1989 | | #endif |
| 1990 | | |
| 1991 | 1987 | #define zig_cast_f16 (zig_f16) |
| 1992 | 1988 | #define zig_cast_f32 (zig_f32) |
| 1993 | 1989 | #define zig_cast_f64 (zig_f64) |