| ... | ... | @@ -415,15 +415,15 @@ static inline long long zig_subw_longlong(long long lhs, long long rhs, long lon |
| 415 | 415 | static inline bool zig_addo_i8(int8_t lhs, int8_t rhs, int8_t *res, int8_t min, int8_t max) { |
| 416 | 416 | #if defined(__GNUC__) && INT8_MAX == INT_MAX |
| 417 | 417 | if (min == INT8_MIN && max == INT8_MAX) { |
| 418 | | return __builtin_sadd_overflow(lhs, rhs, res); |
| 418 | return __builtin_sadd_overflow(lhs, rhs, (int*)res); |
| 419 | 419 | } |
| 420 | 420 | #elif defined(__GNUC__) && INT8_MAX == LONG_MAX |
| 421 | 421 | if (min == INT8_MIN && max == INT8_MAX) { |
| 422 | | return __builtin_saddl_overflow(lhs, rhs, res); |
| 422 | return __builtin_saddl_overflow(lhs, rhs, (long*)res); |
| 423 | 423 | } |
| 424 | 424 | #elif defined(__GNUC__) && INT8_MAX == LLONG_MAX |
| 425 | 425 | if (min == INT8_MIN && max == INT8_MAX) { |
| 426 | | return __builtin_saddll_overflow(lhs, rhs, res); |
| 426 | return __builtin_saddll_overflow(lhs, rhs, (long long*)res); |
| 427 | 427 | } |
| 428 | 428 | #endif |
| 429 | 429 | int16_t big_result = (int16_t)lhs + (int16_t)rhs; |
| ... | ... | @@ -442,15 +442,15 @@ static inline bool zig_addo_i8(int8_t lhs, int8_t rhs, int8_t *res, int8_t min, |
| 442 | 442 | static inline bool zig_addo_i16(int16_t lhs, int16_t rhs, int16_t *res, int16_t min, int16_t max) { |
| 443 | 443 | #if defined(__GNUC__) && INT16_MAX == INT_MAX |
| 444 | 444 | if (min == INT16_MIN && max == INT16_MAX) { |
| 445 | | return __builtin_sadd_overflow(lhs, rhs, res); |
| 445 | return __builtin_sadd_overflow(lhs, rhs, (int*)res); |
| 446 | 446 | } |
| 447 | 447 | #elif defined(__GNUC__) && INT16_MAX == LONG_MAX |
| 448 | 448 | if (min == INT16_MIN && max == INT16_MAX) { |
| 449 | | return __builtin_saddl_overflow(lhs, rhs, res); |
| 449 | return __builtin_saddl_overflow(lhs, rhs, (long*)res); |
| 450 | 450 | } |
| 451 | 451 | #elif defined(__GNUC__) && INT16_MAX == LLONG_MAX |
| 452 | 452 | if (min == INT16_MIN && max == INT16_MAX) { |
| 453 | | return __builtin_saddll_overflow(lhs, rhs, res); |
| 453 | return __builtin_saddll_overflow(lhs, rhs, (long long*)res); |
| 454 | 454 | } |
| 455 | 455 | #endif |
| 456 | 456 | int32_t big_result = (int32_t)lhs + (int32_t)rhs; |
| ... | ... | @@ -469,15 +469,15 @@ static inline bool zig_addo_i16(int16_t lhs, int16_t rhs, int16_t *res, int16_t |
| 469 | 469 | static inline bool zig_addo_i32(int32_t lhs, int32_t rhs, int32_t *res, int32_t min, int32_t max) { |
| 470 | 470 | #if defined(__GNUC__) && INT32_MAX == INT_MAX |
| 471 | 471 | if (min == INT32_MIN && max == INT32_MAX) { |
| 472 | | return __builtin_sadd_overflow(lhs, rhs, res); |
| 472 | return __builtin_sadd_overflow(lhs, rhs, (int*)res); |
| 473 | 473 | } |
| 474 | 474 | #elif defined(__GNUC__) && INT32_MAX == LONG_MAX |
| 475 | 475 | if (min == INT32_MIN && max == INT32_MAX) { |
| 476 | | return __builtin_saddl_overflow(lhs, rhs, res); |
| 476 | return __builtin_saddl_overflow(lhs, rhs, (long*)res); |
| 477 | 477 | } |
| 478 | 478 | #elif defined(__GNUC__) && INT32_MAX == LLONG_MAX |
| 479 | 479 | if (min == INT32_MIN && max == INT32_MAX) { |
| 480 | | return __builtin_saddll_overflow(lhs, rhs, res); |
| 480 | return __builtin_saddll_overflow(lhs, rhs, (long long*)res); |
| 481 | 481 | } |
| 482 | 482 | #endif |
| 483 | 483 | int64_t big_result = (int64_t)lhs + (int64_t)rhs; |
| ... | ... | @@ -496,11 +496,11 @@ static inline bool zig_addo_i32(int32_t lhs, int32_t rhs, int32_t *res, int32_t |
| 496 | 496 | static inline bool zig_addo_i64(int64_t lhs, int64_t rhs, int64_t *res, int64_t min, int64_t max) { |
| 497 | 497 | bool overflow; |
| 498 | 498 | #if defined(__GNUC__) && INT64_MAX == INT_MAX |
| 499 | | overflow = __builtin_sadd_overflow(lhs, rhs, res); |
| 499 | overflow = __builtin_sadd_overflow(lhs, rhs, (int*)res); |
| 500 | 500 | #elif defined(__GNUC__) && INT64_MAX == LONG_MAX |
| 501 | | overflow = __builtin_saddl_overflow(lhs, rhs, res); |
| 501 | overflow = __builtin_saddl_overflow(lhs, rhs, (long*)res); |
| 502 | 502 | #elif defined(__GNUC__) && INT64_MAX == LLONG_MAX |
| 503 | | overflow = __builtin_saddll_overflow(lhs, rhs, res); |
| 503 | overflow = __builtin_saddll_overflow(lhs, rhs, (long long*)res); |
| 504 | 504 | #else |
| 505 | 505 | int int_overflow; |
| 506 | 506 | *res = __addodi4(lhs, rhs, &int_overflow); |
| ... | ... | @@ -521,11 +521,11 @@ static inline bool zig_addo_i64(int64_t lhs, int64_t rhs, int64_t *res, int64_t |
| 521 | 521 | static inline bool zig_addo_i128(int128_t lhs, int128_t rhs, int128_t *res, int128_t min, int128_t max) { |
| 522 | 522 | bool overflow; |
| 523 | 523 | #if defined(__GNUC__) && INT128_MAX == INT_MAX |
| 524 | | overflow = __builtin_sadd_overflow(lhs, rhs, res); |
| 524 | overflow = __builtin_sadd_overflow(lhs, rhs, (int*)res); |
| 525 | 525 | #elif defined(__GNUC__) && INT128_MAX == LONG_MAX |
| 526 | | overflow = __builtin_saddl_overflow(lhs, rhs, res); |
| 526 | overflow = __builtin_saddl_overflow(lhs, rhs, (long*)res); |
| 527 | 527 | #elif defined(__GNUC__) && INT128_MAX == LLONG_MAX |
| 528 | | overflow = __builtin_saddll_overflow(lhs, rhs, res); |
| 528 | overflow = __builtin_saddll_overflow(lhs, rhs, (long long*)res); |
| 529 | 529 | #else |
| 530 | 530 | int int_overflow; |
| 531 | 531 | *res = __addoti4(lhs, rhs, &int_overflow); |
| ... | ... | @@ -546,15 +546,15 @@ static inline bool zig_addo_i128(int128_t lhs, int128_t rhs, int128_t *res, int1 |
| 546 | 546 | static inline bool zig_addo_u8(uint8_t lhs, uint8_t rhs, uint8_t *res, uint8_t max) { |
| 547 | 547 | #if defined(__GNUC__) && UINT8_MAX == UINT_MAX |
| 548 | 548 | if (max == UINT8_MAX) { |
| 549 | | return __builtin_uadd_overflow(lhs, rhs, res); |
| 549 | return __builtin_uadd_overflow(lhs, rhs, (unsigned int*)res); |
| 550 | 550 | } |
| 551 | 551 | #elif defined(__GNUC__) && UINT8_MAX == ULONG_MAX |
| 552 | 552 | if (max == UINT8_MAX) { |
| 553 | | return __builtin_uaddl_overflow(lhs, rhs, res); |
| 553 | return __builtin_uaddl_overflow(lhs, rhs, (unsigned long*)res); |
| 554 | 554 | } |
| 555 | 555 | #elif defined(__GNUC__) && UINT8_MAX == ULLONG_MAX |
| 556 | 556 | if (max == UINT8_MAX) { |
| 557 | | return __builtin_uaddll_overflow(lhs, rhs, res); |
| 557 | return __builtin_uaddll_overflow(lhs, rhs, (unsigned long long*)res); |
| 558 | 558 | } |
| 559 | 559 | #endif |
| 560 | 560 | uint16_t big_result = (uint16_t)lhs + (uint16_t)rhs; |
| ... | ... | @@ -569,15 +569,15 @@ static inline bool zig_addo_u8(uint8_t lhs, uint8_t rhs, uint8_t *res, uint8_t m |
| 569 | 569 | static inline uint16_t zig_addo_u16(uint16_t lhs, uint16_t rhs, uint16_t *res, uint16_t max) { |
| 570 | 570 | #if defined(__GNUC__) && UINT16_MAX == UINT_MAX |
| 571 | 571 | if (max == UINT16_MAX) { |
| 572 | | return __builtin_uadd_overflow(lhs, rhs, res); |
| 572 | return __builtin_uadd_overflow(lhs, rhs, (unsigned int*)res); |
| 573 | 573 | } |
| 574 | 574 | #elif defined(__GNUC__) && UINT16_MAX == ULONG_MAX |
| 575 | 575 | if (max == UINT16_MAX) { |
| 576 | | return __builtin_uaddl_overflow(lhs, rhs, res); |
| 576 | return __builtin_uaddl_overflow(lhs, rhs, (unsigned long*)res); |
| 577 | 577 | } |
| 578 | 578 | #elif defined(__GNUC__) && UINT16_MAX == ULLONG_MAX |
| 579 | 579 | if (max == UINT16_MAX) { |
| 580 | | return __builtin_uaddll_overflow(lhs, rhs, res); |
| 580 | return __builtin_uaddll_overflow(lhs, rhs, (unsigned long long*)res); |
| 581 | 581 | } |
| 582 | 582 | #endif |
| 583 | 583 | uint32_t big_result = (uint32_t)lhs + (uint32_t)rhs; |
| ... | ... | @@ -592,15 +592,15 @@ static inline uint16_t zig_addo_u16(uint16_t lhs, uint16_t rhs, uint16_t *res, u |
| 592 | 592 | static inline uint32_t zig_addo_u32(uint32_t lhs, uint32_t rhs, uint32_t *res, uint32_t max) { |
| 593 | 593 | #if defined(__GNUC__) && UINT32_MAX == UINT_MAX |
| 594 | 594 | if (max == UINT32_MAX) { |
| 595 | | return __builtin_uadd_overflow(lhs, rhs, res); |
| 595 | return __builtin_uadd_overflow(lhs, rhs, (unsigned int*)res); |
| 596 | 596 | } |
| 597 | 597 | #elif defined(__GNUC__) && UINT32_MAX == ULONG_MAX |
| 598 | 598 | if (max == UINT32_MAX) { |
| 599 | | return __builtin_uaddl_overflow(lhs, rhs, res); |
| 599 | return __builtin_uaddl_overflow(lhs, rhs, (unsigned long*)res); |
| 600 | 600 | } |
| 601 | 601 | #elif defined(__GNUC__) && UINT32_MAX == ULLONG_MAX |
| 602 | 602 | if (max == UINT32_MAX) { |
| 603 | | return __builtin_uaddll_overflow(lhs, rhs, res); |
| 603 | return __builtin_uaddll_overflow(lhs, rhs, (unsigned long long*)res); |
| 604 | 604 | } |
| 605 | 605 | #endif |
| 606 | 606 | uint64_t big_result = (uint64_t)lhs + (uint64_t)rhs; |
| ... | ... | @@ -615,11 +615,11 @@ static inline uint32_t zig_addo_u32(uint32_t lhs, uint32_t rhs, uint32_t *res, u |
| 615 | 615 | static inline uint64_t zig_addo_u64(uint64_t lhs, uint64_t rhs, uint64_t *res, uint64_t max) { |
| 616 | 616 | bool overflow; |
| 617 | 617 | #if defined(__GNUC__) && UINT64_MAX == UINT_MAX |
| 618 | | overflow = __builtin_uadd_overflow(lhs, rhs, res); |
| 618 | overflow = __builtin_uadd_overflow(lhs, rhs, (unsigned int*)res); |
| 619 | 619 | #elif defined(__GNUC__) && UINT64_MAX == ULONG_MAX |
| 620 | | overflow = __builtin_uaddl_overflow(lhs, rhs, res); |
| 620 | overflow = __builtin_uaddl_overflow(lhs, rhs, (unsigned long*)res); |
| 621 | 621 | #elif defined(__GNUC__) && UINT64_MAX == ULLONG_MAX |
| 622 | | overflow = __builtin_uaddll_overflow(lhs, rhs, res); |
| 622 | overflow = __builtin_uaddll_overflow(lhs, rhs, (unsigned long long*)res); |
| 623 | 623 | #else |
| 624 | 624 | int int_overflow; |
| 625 | 625 | *res = __uaddodi4(lhs, rhs, &int_overflow); |
| ... | ... | @@ -645,15 +645,15 @@ static inline uint128_t zig_addo_u128(uint128_t lhs, uint128_t rhs, uint128_t *r |
| 645 | 645 | static inline bool zig_subo_i8(int8_t lhs, int8_t rhs, int8_t *res, int8_t min, int8_t max) { |
| 646 | 646 | #if defined(__GNUC__) && INT8_MAX == INT_MAX |
| 647 | 647 | if (min == INT8_MIN && max == INT8_MAX) { |
| 648 | | return __builtin_ssub_overflow(lhs, rhs, res); |
| 648 | return __builtin_ssub_overflow(lhs, rhs, (int*)res); |
| 649 | 649 | } |
| 650 | 650 | #elif defined(__GNUC__) && INT8_MAX == LONG_MAX |
| 651 | 651 | if (min == INT8_MIN && max == INT8_MAX) { |
| 652 | | return __builtin_ssubl_overflow(lhs, rhs, res); |
| 652 | return __builtin_ssubl_overflow(lhs, rhs, (long*)res); |
| 653 | 653 | } |
| 654 | 654 | #elif defined(__GNUC__) && INT8_MAX == LLONG_MAX |
| 655 | 655 | if (min == INT8_MIN && max == INT8_MAX) { |
| 656 | | return __builtin_ssubll_overflow(lhs, rhs, res); |
| 656 | return __builtin_ssubll_overflow(lhs, rhs, (long long*)res); |
| 657 | 657 | } |
| 658 | 658 | #endif |
| 659 | 659 | int16_t big_result = (int16_t)lhs - (int16_t)rhs; |
| ... | ... | @@ -672,15 +672,15 @@ static inline bool zig_subo_i8(int8_t lhs, int8_t rhs, int8_t *res, int8_t min, |
| 672 | 672 | static inline bool zig_subo_i16(int16_t lhs, int16_t rhs, int16_t *res, int16_t min, int16_t max) { |
| 673 | 673 | #if defined(__GNUC__) && INT16_MAX == INT_MAX |
| 674 | 674 | if (min == INT16_MIN && max == INT16_MAX) { |
| 675 | | return __builtin_ssub_overflow(lhs, rhs, res); |
| 675 | return __builtin_ssub_overflow(lhs, rhs, (int*)res); |
| 676 | 676 | } |
| 677 | 677 | #elif defined(__GNUC__) && INT16_MAX == LONG_MAX |
| 678 | 678 | if (min == INT16_MIN && max == INT16_MAX) { |
| 679 | | return __builtin_ssubl_overflow(lhs, rhs, res); |
| 679 | return __builtin_ssubl_overflow(lhs, rhs, (long*)res); |
| 680 | 680 | } |
| 681 | 681 | #elif defined(__GNUC__) && INT16_MAX == LLONG_MAX |
| 682 | 682 | if (min == INT16_MIN && max == INT16_MAX) { |
| 683 | | return __builtin_ssubll_overflow(lhs, rhs, res); |
| 683 | return __builtin_ssubll_overflow(lhs, rhs, (long long*)res); |
| 684 | 684 | } |
| 685 | 685 | #endif |
| 686 | 686 | int32_t big_result = (int32_t)lhs - (int32_t)rhs; |
| ... | ... | @@ -699,15 +699,15 @@ static inline bool zig_subo_i16(int16_t lhs, int16_t rhs, int16_t *res, int16_t |
| 699 | 699 | static inline bool zig_subo_i32(int32_t lhs, int32_t rhs, int32_t *res, int32_t min, int32_t max) { |
| 700 | 700 | #if defined(__GNUC__) && INT32_MAX == INT_MAX |
| 701 | 701 | if (min == INT32_MIN && max == INT32_MAX) { |
| 702 | | return __builtin_ssub_overflow(lhs, rhs, res); |
| 702 | return __builtin_ssub_overflow(lhs, rhs, (int*)res); |
| 703 | 703 | } |
| 704 | 704 | #elif defined(__GNUC__) && INT32_MAX == LONG_MAX |
| 705 | 705 | if (min == INT32_MIN && max == INT32_MAX) { |
| 706 | | return __builtin_ssubl_overflow(lhs, rhs, res); |
| 706 | return __builtin_ssubl_overflow(lhs, rhs, (long*)res); |
| 707 | 707 | } |
| 708 | 708 | #elif defined(__GNUC__) && INT32_MAX == LLONG_MAX |
| 709 | 709 | if (min == INT32_MIN && max == INT32_MAX) { |
| 710 | | return __builtin_ssubll_overflow(lhs, rhs, res); |
| 710 | return __builtin_ssubll_overflow(lhs, rhs, (long long*)res); |
| 711 | 711 | } |
| 712 | 712 | #endif |
| 713 | 713 | int64_t big_result = (int64_t)lhs - (int64_t)rhs; |
| ... | ... | @@ -726,11 +726,11 @@ static inline bool zig_subo_i32(int32_t lhs, int32_t rhs, int32_t *res, int32_t |
| 726 | 726 | static inline bool zig_subo_i64(int64_t lhs, int64_t rhs, int64_t *res, int64_t min, int64_t max) { |
| 727 | 727 | bool overflow; |
| 728 | 728 | #if defined(__GNUC__) && INT64_MAX == INT_MAX |
| 729 | | overflow = __builtin_ssub_overflow(lhs, rhs, res); |
| 729 | overflow = __builtin_ssub_overflow(lhs, rhs, (int*)res); |
| 730 | 730 | #elif defined(__GNUC__) && INT64_MAX == LONG_MAX |
| 731 | | overflow = __builtin_ssubl_overflow(lhs, rhs, res); |
| 731 | overflow = __builtin_ssubl_overflow(lhs, rhs, (long*)res); |
| 732 | 732 | #elif defined(__GNUC__) && INT64_MAX == LLONG_MAX |
| 733 | | overflow = __builtin_ssubll_overflow(lhs, rhs, res); |
| 733 | overflow = __builtin_ssubll_overflow(lhs, rhs, (long long*)res); |
| 734 | 734 | #else |
| 735 | 735 | int int_overflow; |
| 736 | 736 | *res = __subodi4(lhs, rhs, &int_overflow); |
| ... | ... | @@ -751,11 +751,11 @@ static inline bool zig_subo_i64(int64_t lhs, int64_t rhs, int64_t *res, int64_t |
| 751 | 751 | static inline bool zig_subo_i128(int128_t lhs, int128_t rhs, int128_t *res, int128_t min, int128_t max) { |
| 752 | 752 | bool overflow; |
| 753 | 753 | #if defined(__GNUC__) && INT128_MAX == INT_MAX |
| 754 | | overflow = __builtin_ssub_overflow(lhs, rhs, res); |
| 754 | overflow = __builtin_ssub_overflow(lhs, rhs, (int*)res); |
| 755 | 755 | #elif defined(__GNUC__) && INT128_MAX == LONG_MAX |
| 756 | | overflow = __builtin_ssubl_overflow(lhs, rhs, res); |
| 756 | overflow = __builtin_ssubl_overflow(lhs, rhs, (long*)res); |
| 757 | 757 | #elif defined(__GNUC__) && INT128_MAX == LLONG_MAX |
| 758 | | overflow = __builtin_ssubll_overflow(lhs, rhs, res); |
| 758 | overflow = __builtin_ssubll_overflow(lhs, rhs, (long long*)res); |
| 759 | 759 | #else |
| 760 | 760 | int int_overflow; |
| 761 | 761 | *res = __suboti4(lhs, rhs, &int_overflow); |
| ... | ... | @@ -775,11 +775,11 @@ static inline bool zig_subo_i128(int128_t lhs, int128_t rhs, int128_t *res, int1 |
| 775 | 775 | |
| 776 | 776 | static inline bool zig_subo_u8(uint8_t lhs, uint8_t rhs, uint8_t *res, uint8_t max) { |
| 777 | 777 | #if defined(__GNUC__) && UINT8_MAX == UINT_MAX |
| 778 | | return __builtin_usub_overflow(lhs, rhs, res); |
| 778 | return __builtin_usub_overflow(lhs, rhs, (unsigned int*)res); |
| 779 | 779 | #elif defined(__GNUC__) && UINT8_MAX == ULONG_MAX |
| 780 | | return __builtin_usubl_overflow(lhs, rhs, res); |
| 780 | return __builtin_usubl_overflow(lhs, rhs, (unsigned long*)res); |
| 781 | 781 | #elif defined(__GNUC__) && UINT8_MAX == ULLONG_MAX |
| 782 | | return __builtin_usubll_overflow(lhs, rhs, res); |
| 782 | return __builtin_usubll_overflow(lhs, rhs, (unsigned long long*)res); |
| 783 | 783 | #endif |
| 784 | 784 | if (rhs > lhs) { |
| 785 | 785 | *res = max - (rhs - lhs - 1); |
| ... | ... | @@ -791,11 +791,11 @@ static inline bool zig_subo_u8(uint8_t lhs, uint8_t rhs, uint8_t *res, uint8_t m |
| 791 | 791 | |
| 792 | 792 | static inline uint16_t zig_subo_u16(uint16_t lhs, uint16_t rhs, uint16_t *res, uint16_t max) { |
| 793 | 793 | #if defined(__GNUC__) && UINT16_MAX == UINT_MAX |
| 794 | | return __builtin_usub_overflow(lhs, rhs, res); |
| 794 | return __builtin_usub_overflow(lhs, rhs, (unsigned int*)res); |
| 795 | 795 | #elif defined(__GNUC__) && UINT16_MAX == ULONG_MAX |
| 796 | | return __builtin_usubl_overflow(lhs, rhs, res); |
| 796 | return __builtin_usubl_overflow(lhs, rhs, (unsigned long*)res); |
| 797 | 797 | #elif defined(__GNUC__) && UINT16_MAX == ULLONG_MAX |
| 798 | | return __builtin_usubll_overflow(lhs, rhs, res); |
| 798 | return __builtin_usubll_overflow(lhs, rhs, (unsigned long long*)res); |
| 799 | 799 | #endif |
| 800 | 800 | if (rhs > lhs) { |
| 801 | 801 | *res = max - (rhs - lhs - 1); |
| ... | ... | @@ -808,11 +808,11 @@ static inline uint16_t zig_subo_u16(uint16_t lhs, uint16_t rhs, uint16_t *res, u |
| 808 | 808 | static inline uint32_t zig_subo_u32(uint32_t lhs, uint32_t rhs, uint32_t *res, uint32_t max) { |
| 809 | 809 | if (max == UINT32_MAX) { |
| 810 | 810 | #if defined(__GNUC__) && UINT32_MAX == UINT_MAX |
| 811 | | return __builtin_usub_overflow(lhs, rhs, res); |
| 811 | return __builtin_usub_overflow(lhs, rhs, (unsigned int*)res); |
| 812 | 812 | #elif defined(__GNUC__) && UINT32_MAX == ULONG_MAX |
| 813 | | return __builtin_usubl_overflow(lhs, rhs, res); |
| 813 | return __builtin_usubl_overflow(lhs, rhs, (unsigned long*)res); |
| 814 | 814 | #elif defined(__GNUC__) && UINT32_MAX == ULLONG_MAX |
| 815 | | return __builtin_usubll_overflow(lhs, rhs, res); |
| 815 | return __builtin_usubll_overflow(lhs, rhs, (unsigned long long*)res); |
| 816 | 816 | #endif |
| 817 | 817 | int int_overflow; |
| 818 | 818 | *res = __usubosi4(lhs, rhs, &int_overflow); |
| ... | ... | @@ -830,11 +830,11 @@ static inline uint32_t zig_subo_u32(uint32_t lhs, uint32_t rhs, uint32_t *res, u |
| 830 | 830 | static inline uint64_t zig_subo_u64(uint64_t lhs, uint64_t rhs, uint64_t *res, uint64_t max) { |
| 831 | 831 | if (max == UINT64_MAX) { |
| 832 | 832 | #if defined(__GNUC__) && UINT64_MAX == UINT_MAX |
| 833 | | return __builtin_usub_overflow(lhs, rhs, res); |
| 833 | return __builtin_usub_overflow(lhs, rhs, (unsigned int*)res); |
| 834 | 834 | #elif defined(__GNUC__) && UINT64_MAX == ULONG_MAX |
| 835 | | return __builtin_usubl_overflow(lhs, rhs, res); |
| 835 | return __builtin_usubl_overflow(lhs, rhs, (unsigned long*)res); |
| 836 | 836 | #elif defined(__GNUC__) && UINT64_MAX == ULLONG_MAX |
| 837 | | return __builtin_usubll_overflow(lhs, rhs, res); |
| 837 | return __builtin_usubll_overflow(lhs, rhs, (unsigned long long*)res); |
| 838 | 838 | #else |
| 839 | 839 | int int_overflow; |
| 840 | 840 | *res = __usubodi4(lhs, rhs, &int_overflow); |
| ... | ... | @@ -868,15 +868,15 @@ static inline uint128_t zig_subo_u128(uint128_t lhs, uint128_t rhs, uint128_t *r |
| 868 | 868 | static inline bool zig_mulo_i8(int8_t lhs, int8_t rhs, int8_t *res, int8_t min, int8_t max) { |
| 869 | 869 | #if defined(__GNUC__) && INT8_MAX == INT_MAX |
| 870 | 870 | if (min == INT8_MIN && max == INT8_MAX) { |
| 871 | | return __builtin_smul_overflow(lhs, rhs, res); |
| 871 | return __builtin_smul_overflow(lhs, rhs, (int*)res); |
| 872 | 872 | } |
| 873 | 873 | #elif defined(__GNUC__) && INT8_MAX == LONG_MAX |
| 874 | 874 | if (min == INT8_MIN && max == INT8_MAX) { |
| 875 | | return __builtin_smull_overflow(lhs, rhs, res); |
| 875 | return __builtin_smull_overflow(lhs, rhs, (long*)res); |
| 876 | 876 | } |
| 877 | 877 | #elif defined(__GNUC__) && INT8_MAX == LLONG_MAX |
| 878 | 878 | if (min == INT8_MIN && max == INT8_MAX) { |
| 879 | | return __builtin_smulll_overflow(lhs, rhs, res); |
| 879 | return __builtin_smulll_overflow(lhs, rhs, (long long*)res); |
| 880 | 880 | } |
| 881 | 881 | #endif |
| 882 | 882 | int16_t big_result = (int16_t)lhs * (int16_t)rhs; |
| ... | ... | @@ -895,15 +895,15 @@ static inline bool zig_mulo_i8(int8_t lhs, int8_t rhs, int8_t *res, int8_t min, |
| 895 | 895 | static inline bool zig_mulo_i16(int16_t lhs, int16_t rhs, int16_t *res, int16_t min, int16_t max) { |
| 896 | 896 | #if defined(__GNUC__) && INT16_MAX == INT_MAX |
| 897 | 897 | if (min == INT16_MIN && max == INT16_MAX) { |
| 898 | | return __builtin_smul_overflow(lhs, rhs, res); |
| 898 | return __builtin_smul_overflow(lhs, rhs, (int*)res); |
| 899 | 899 | } |
| 900 | 900 | #elif defined(__GNUC__) && INT16_MAX == LONG_MAX |
| 901 | 901 | if (min == INT16_MIN && max == INT16_MAX) { |
| 902 | | return __builtin_smull_overflow(lhs, rhs, res); |
| 902 | return __builtin_smull_overflow(lhs, rhs, (long*)res); |
| 903 | 903 | } |
| 904 | 904 | #elif defined(__GNUC__) && INT16_MAX == LLONG_MAX |
| 905 | 905 | if (min == INT16_MIN && max == INT16_MAX) { |
| 906 | | return __builtin_smulll_overflow(lhs, rhs, res); |
| 906 | return __builtin_smulll_overflow(lhs, rhs, (long long*)res); |
| 907 | 907 | } |
| 908 | 908 | #endif |
| 909 | 909 | int32_t big_result = (int32_t)lhs * (int32_t)rhs; |
| ... | ... | @@ -922,15 +922,15 @@ static inline bool zig_mulo_i16(int16_t lhs, int16_t rhs, int16_t *res, int16_t |
| 922 | 922 | static inline bool zig_mulo_i32(int32_t lhs, int32_t rhs, int32_t *res, int32_t min, int32_t max) { |
| 923 | 923 | #if defined(__GNUC__) && INT32_MAX == INT_MAX |
| 924 | 924 | if (min == INT32_MIN && max == INT32_MAX) { |
| 925 | | return __builtin_smul_overflow(lhs, rhs, res); |
| 925 | return __builtin_smul_overflow(lhs, rhs, (int*)res); |
| 926 | 926 | } |
| 927 | 927 | #elif defined(__GNUC__) && INT32_MAX == LONG_MAX |
| 928 | 928 | if (min == INT32_MIN && max == INT32_MAX) { |
| 929 | | return __builtin_smull_overflow(lhs, rhs, res); |
| 929 | return __builtin_smull_overflow(lhs, rhs, (long*)res); |
| 930 | 930 | } |
| 931 | 931 | #elif defined(__GNUC__) && INT32_MAX == LLONG_MAX |
| 932 | 932 | if (min == INT32_MIN && max == INT32_MAX) { |
| 933 | | return __builtin_smulll_overflow(lhs, rhs, res); |
| 933 | return __builtin_smulll_overflow(lhs, rhs, (long long*)res); |
| 934 | 934 | } |
| 935 | 935 | #endif |
| 936 | 936 | int64_t big_result = (int64_t)lhs * (int64_t)rhs; |
| ... | ... | @@ -949,11 +949,11 @@ static inline bool zig_mulo_i32(int32_t lhs, int32_t rhs, int32_t *res, int32_t |
| 949 | 949 | static inline bool zig_mulo_i64(int64_t lhs, int64_t rhs, int64_t *res, int64_t min, int64_t max) { |
| 950 | 950 | bool overflow; |
| 951 | 951 | #if defined(__GNUC__) && INT64_MAX == INT_MAX |
| 952 | | overflow = __builtin_smul_overflow(lhs, rhs, res); |
| 952 | overflow = __builtin_smul_overflow(lhs, rhs, (int*)res); |
| 953 | 953 | #elif defined(__GNUC__) && INT64_MAX == LONG_MAX |
| 954 | | overflow = __builtin_smull_overflow(lhs, rhs, res); |
| 954 | overflow = __builtin_smull_overflow(lhs, rhs, (long*)res); |
| 955 | 955 | #elif defined(__GNUC__) && INT64_MAX == LLONG_MAX |
| 956 | | overflow = __builtin_smulll_overflow(lhs, rhs, res); |
| 956 | overflow = __builtin_smulll_overflow(lhs, rhs, (long long*)res); |
| 957 | 957 | #else |
| 958 | 958 | int int_overflow; |
| 959 | 959 | *res = __mulodi4(lhs, rhs, &int_overflow); |
| ... | ... | @@ -974,11 +974,11 @@ static inline bool zig_mulo_i64(int64_t lhs, int64_t rhs, int64_t *res, int64_t |
| 974 | 974 | static inline bool zig_mulo_i128(int128_t lhs, int128_t rhs, int128_t *res, int128_t min, int128_t max) { |
| 975 | 975 | bool overflow; |
| 976 | 976 | #if defined(__GNUC__) && INT128_MAX == INT_MAX |
| 977 | | overflow = __builtin_smul_overflow(lhs, rhs, res); |
| 977 | overflow = __builtin_smul_overflow(lhs, rhs, (int*)res); |
| 978 | 978 | #elif defined(__GNUC__) && INT128_MAX == LONG_MAX |
| 979 | | overflow = __builtin_smull_overflow(lhs, rhs, res); |
| 979 | overflow = __builtin_smull_overflow(lhs, rhs, (long*)res); |
| 980 | 980 | #elif defined(__GNUC__) && INT128_MAX == LLONG_MAX |
| 981 | | overflow = __builtin_smulll_overflow(lhs, rhs, res); |
| 981 | overflow = __builtin_smulll_overflow(lhs, rhs, (long long*)res); |
| 982 | 982 | #else |
| 983 | 983 | int int_overflow; |
| 984 | 984 | *res = __muloti4(lhs, rhs, &int_overflow); |
| ... | ... | @@ -999,15 +999,15 @@ static inline bool zig_mulo_i128(int128_t lhs, int128_t rhs, int128_t *res, int1 |
| 999 | 999 | static inline bool zig_mulo_u8(uint8_t lhs, uint8_t rhs, uint8_t *res, uint8_t max) { |
| 1000 | 1000 | #if defined(__GNUC__) && UINT8_MAX == UINT_MAX |
| 1001 | 1001 | if (max == UINT8_MAX) { |
| 1002 | | return __builtin_umul_overflow(lhs, rhs, res); |
| 1002 | return __builtin_umul_overflow(lhs, rhs, (unsigned int*)res); |
| 1003 | 1003 | } |
| 1004 | 1004 | #elif defined(__GNUC__) && UINT8_MAX == ULONG_MAX |
| 1005 | 1005 | if (max == UINT8_MAX) { |
| 1006 | | return __builtin_umull_overflow(lhs, rhs, res); |
| 1006 | return __builtin_umull_overflow(lhs, rhs, (unsigned long*)res); |
| 1007 | 1007 | } |
| 1008 | 1008 | #elif defined(__GNUC__) && UINT8_MAX == ULLONG_MAX |
| 1009 | 1009 | if (max == UINT8_MAX) { |
| 1010 | | return __builtin_umulll_overflow(lhs, rhs, res); |
| 1010 | return __builtin_umulll_overflow(lhs, rhs, (unsigned long long*)res); |
| 1011 | 1011 | } |
| 1012 | 1012 | #endif |
| 1013 | 1013 | uint16_t big_result = (uint16_t)lhs * (uint16_t)rhs; |
| ... | ... | @@ -1022,15 +1022,15 @@ static inline bool zig_mulo_u8(uint8_t lhs, uint8_t rhs, uint8_t *res, uint8_t m |
| 1022 | 1022 | static inline uint16_t zig_mulo_u16(uint16_t lhs, uint16_t rhs, uint16_t *res, uint16_t max) { |
| 1023 | 1023 | #if defined(__GNUC__) && UINT16_MAX == UINT_MAX |
| 1024 | 1024 | if (max == UINT16_MAX) { |
| 1025 | | return __builtin_umul_overflow(lhs, rhs, res); |
| 1025 | return __builtin_umul_overflow(lhs, rhs, (unsigned int*)res); |
| 1026 | 1026 | } |
| 1027 | 1027 | #elif defined(__GNUC__) && UINT16_MAX == ULONG_MAX |
| 1028 | 1028 | if (max == UINT16_MAX) { |
| 1029 | | return __builtin_umull_overflow(lhs, rhs, res); |
| 1029 | return __builtin_umull_overflow(lhs, rhs, (unsigned long*)res); |
| 1030 | 1030 | } |
| 1031 | 1031 | #elif defined(__GNUC__) && UINT16_MAX == ULLONG_MAX |
| 1032 | 1032 | if (max == UINT16_MAX) { |
| 1033 | | return __builtin_umulll_overflow(lhs, rhs, res); |
| 1033 | return __builtin_umulll_overflow(lhs, rhs, (unsigned long long*)res); |
| 1034 | 1034 | } |
| 1035 | 1035 | #endif |
| 1036 | 1036 | uint32_t big_result = (uint32_t)lhs * (uint32_t)rhs; |
| ... | ... | @@ -1045,15 +1045,15 @@ static inline uint16_t zig_mulo_u16(uint16_t lhs, uint16_t rhs, uint16_t *res, u |
| 1045 | 1045 | static inline uint32_t zig_mulo_u32(uint32_t lhs, uint32_t rhs, uint32_t *res, uint32_t max) { |
| 1046 | 1046 | #if defined(__GNUC__) && UINT32_MAX == UINT_MAX |
| 1047 | 1047 | if (max == UINT32_MAX) { |
| 1048 | | return __builtin_umul_overflow(lhs, rhs, res); |
| 1048 | return __builtin_umul_overflow(lhs, rhs, (unsigned int*)res); |
| 1049 | 1049 | } |
| 1050 | 1050 | #elif defined(__GNUC__) && UINT32_MAX == ULONG_MAX |
| 1051 | 1051 | if (max == UINT32_MAX) { |
| 1052 | | return __builtin_umull_overflow(lhs, rhs, res); |
| 1052 | return __builtin_umull_overflow(lhs, rhs, (unsigned long*)res); |
| 1053 | 1053 | } |
| 1054 | 1054 | #elif defined(__GNUC__) && UINT32_MAX == ULLONG_MAX |
| 1055 | 1055 | if (max == UINT32_MAX) { |
| 1056 | | return __builtin_umulll_overflow(lhs, rhs, res); |
| 1056 | return __builtin_umulll_overflow(lhs, rhs, (unsigned long long*)res); |
| 1057 | 1057 | } |
| 1058 | 1058 | #endif |
| 1059 | 1059 | uint64_t big_result = (uint64_t)lhs * (uint64_t)rhs; |
| ... | ... | @@ -1068,11 +1068,11 @@ static inline uint32_t zig_mulo_u32(uint32_t lhs, uint32_t rhs, uint32_t *res, u |
| 1068 | 1068 | static inline uint64_t zig_mulo_u64(uint64_t lhs, uint64_t rhs, uint64_t *res, uint64_t max) { |
| 1069 | 1069 | bool overflow; |
| 1070 | 1070 | #if defined(__GNUC__) && UINT64_MAX == UINT_MAX |
| 1071 | | overflow = __builtin_umul_overflow(lhs, rhs, res); |
| 1071 | overflow = __builtin_umul_overflow(lhs, rhs, (unsigned int*)res); |
| 1072 | 1072 | #elif defined(__GNUC__) && UINT64_MAX == ULONG_MAX |
| 1073 | | overflow = __builtin_umull_overflow(lhs, rhs, res); |
| 1073 | overflow = __builtin_umull_overflow(lhs, rhs, (unsigned long*)res); |
| 1074 | 1074 | #elif defined(__GNUC__) && UINT64_MAX == ULLONG_MAX |
| 1075 | | overflow = __builtin_umulll_overflow(lhs, rhs, res); |
| 1075 | overflow = __builtin_umulll_overflow(lhs, rhs, (unsigned long long*)res); |
| 1076 | 1076 | #else |
| 1077 | 1077 | int int_overflow; |
| 1078 | 1078 | *res = __umulodi4(lhs, rhs, &int_overflow); |