@@ -79,8 +79,12 @@ GIT_INLINE(int) git__is_int(long long p)
7979
8080# define git__add_int64_overflow (out , one , two ) \
8181 __builtin_add_overflow(one, two, out)
82- # define git__multiply_int64_overflow (out , one , two ) \
83- __builtin_mul_overflow(one, two, out)
82+
83+ /* clang on 32-bit systems produces an undefined reference to `__mulodi4`. */
84+ # if !defined(__clang__ ) || !defined(GIT_ARCH_32 )
85+ # define git__multiply_int64_overflow (out , one , two ) \
86+ __builtin_mul_overflow(one, two, out)
87+ # endif
8488
8589/* Use Microsoft's safe integer handling functions where available */
8690#elif defined(_MSC_VER )
@@ -156,6 +160,10 @@ GIT_INLINE(bool) git__add_int64_overflow(int64_t *out, int64_t one, int64_t two)
156160 return false;
157161}
158162
163+ #endif
164+
165+ /* If we could not provide an intrinsic implementation for this, provide a (slow) fallback. */
166+ #if !defined(git__multiply_int64_overflow )
159167GIT_INLINE (bool ) git__multiply_int64_overflow (int64_t * out , int64_t one , int64_t two )
160168{
161169 if ((one == -1 && two == INT_MIN ) ||
@@ -166,7 +174,6 @@ GIT_INLINE(bool) git__multiply_int64_overflow(int64_t *out, int64_t one, int64_t
166174 * out = one * two ;
167175 return false;
168176}
169-
170177#endif
171178
172179#endif
0 commit comments