Skip to content

Commit 728101e

Browse files
committed
Move the intrinsics part of the change to its own PR
Less controversial changes together is better.
1 parent 321d19c commit 728101e

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

src/integer.h

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,16 @@ GIT_INLINE(bool) git__add_uint64_overflow(uint64_t *out, uint64_t one, uint64_t
5555
}
5656

5757
/* Use clang/gcc compiler intrinsics whenever possible */
58-
#if (__has_builtin(__builtin_add_overflow) || \
59-
(defined(__GNUC__) && (__GNUC__ >= 5)))
60-
61-
# if (ULONG_MAX == ULLONG_MAX) && defined(_WIN64)
62-
# define git__add_sizet_overflow(out, one, two) \
63-
__builtin_uaddll_overflow(one, two, out)
64-
# define git__multiply_sizet_overflow(out, one, two) \
65-
__builtin_umulll_overflow(one, two, out)
66-
# elif (ULONG_MAX == ULLONG_MAX)
67-
# define git__add_sizet_overflow(out, one, two) \
68-
__builtin_uaddl_overflow(one, two, out)
69-
# define git__multiply_sizet_overflow(out, one, two) \
70-
__builtin_umull_overflow(one, two, out)
71-
# else
72-
# define git__add_sizet_overflow(out, one, two) \
73-
__builtin_add_overflow(one, two, out)
74-
# define git__multiply_sizet_overflow(out, one, two) \
75-
__builtin_mul_overflow(one, two, out)
76-
# endif
77-
58+
#if (SIZE_MAX == ULONG_MAX) && __has_builtin(__builtin_uaddl_overflow)
59+
# define git__add_sizet_overflow(out, one, two) \
60+
__builtin_uaddl_overflow(one, two, out)
61+
# define git__multiply_sizet_overflow(out, one, two) \
62+
__builtin_umull_overflow(one, two, out)
63+
#elif (SIZE_MAX == UINT_MAX) && __has_builtin(__builtin_uadd_overflow)
64+
# define git__add_sizet_overflow(out, one, two) \
65+
__builtin_uadd_overflow(one, two, out)
66+
# define git__multiply_sizet_overflow(out, one, two) \
67+
__builtin_umul_overflow(one, two, out)
7868
#else
7969

8070
/**

0 commit comments

Comments
 (0)