Commit 728101e3 by lhchavez

Move the intrinsics part of the change to its own PR

Less controversial changes together is better.
parent 321d19c1
...@@ -55,26 +55,16 @@ GIT_INLINE(bool) git__add_uint64_overflow(uint64_t *out, uint64_t one, uint64_t ...@@ -55,26 +55,16 @@ GIT_INLINE(bool) git__add_uint64_overflow(uint64_t *out, uint64_t one, uint64_t
} }
/* Use clang/gcc compiler intrinsics whenever possible */ /* Use clang/gcc compiler intrinsics whenever possible */
#if (__has_builtin(__builtin_add_overflow) || \ #if (SIZE_MAX == ULONG_MAX) && __has_builtin(__builtin_uaddl_overflow)
(defined(__GNUC__) && (__GNUC__ >= 5))) # define git__add_sizet_overflow(out, one, two) \
__builtin_uaddl_overflow(one, two, out)
# if (ULONG_MAX == ULLONG_MAX) && defined(_WIN64) # define git__multiply_sizet_overflow(out, one, two) \
# define git__add_sizet_overflow(out, one, two) \ __builtin_umull_overflow(one, two, out)
__builtin_uaddll_overflow(one, two, out) #elif (SIZE_MAX == UINT_MAX) && __has_builtin(__builtin_uadd_overflow)
# define git__multiply_sizet_overflow(out, one, two) \ # define git__add_sizet_overflow(out, one, two) \
__builtin_umulll_overflow(one, two, out) __builtin_uadd_overflow(one, two, out)
# elif (ULONG_MAX == ULLONG_MAX) # define git__multiply_sizet_overflow(out, one, two) \
# define git__add_sizet_overflow(out, one, two) \ __builtin_umul_overflow(one, two, out)
__builtin_uaddl_overflow(one, two, out)
# define git__multiply_sizet_overflow(out, one, two) \
__builtin_umull_overflow(one, two, out)
# else
# define git__add_sizet_overflow(out, one, two) \
__builtin_add_overflow(one, two, out)
# define git__multiply_sizet_overflow(out, one, two) \
__builtin_mul_overflow(one, two, out)
# endif
#else #else
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment