safe-math: Fix non-existent built-ins

Divison and modulo are not built-ins implemented by GCC or Clang.

Replace the spurious macro definition with the internal implementation.
This commit is contained in:
João Valverde 2022-03-31 15:36:07 +01:00
parent 85aa5939f1
commit e15658d1c0
1 changed files with 2 additions and 2 deletions

View File

@ -1027,8 +1027,8 @@ PSNIP_SAFE_DEFINE_UNSIGNED_MOD(psnip_uint64_t, uint64, 0xffffffffffffffffULL)
#define psnip_safe_add(res, a, b) !__builtin_add_overflow(a, b, res)
#define psnip_safe_sub(res, a, b) !__builtin_sub_overflow(a, b, res)
#define psnip_safe_mul(res, a, b) !__builtin_mul_overflow(a, b, res)
#define psnip_safe_div(res, a, b) !__builtin_div_overflow(a, b, res)
#define psnip_safe_mod(res, a, b) !__builtin_mod_overflow(a, b, res)
#define psnip_safe_div(res, a, b) PSNIP_SAFE_C11_GENERIC_BINARY_OP(div, res, a, b)
#define psnip_safe_mod(res, a, b) PSNIP_SAFE_C11_GENERIC_BINARY_OP(mod, res, a, b)
#define psnip_safe_neg(res, v) PSNIP_SAFE_C11_GENERIC_UNARY_OP (neg, res, v)
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)