Skip to content

Commit ac6cec3

Browse files
authored
Use NumPy macros for overflow detection (#55977)
* Use NumPy macros for overflow detection * typo * try more fix * try more * use generic macros * IWYU
1 parent 54f193a commit ac6cec3

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

pandas/_libs/src/vendored/numpy/datetime/np_datetime.c

+6-18
Original file line numberDiff line numberDiff line change
@@ -40,31 +40,19 @@ This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt
4040
#else
4141
#if defined __has_builtin
4242
#if __has_builtin(__builtin_add_overflow)
43-
#if _LP64 || __LP64__ || _ILP64 || __ILP64__
44-
#define checked_int64_add(a, b, res) __builtin_saddl_overflow(a, b, res)
45-
#define checked_int64_sub(a, b, res) __builtin_ssubl_overflow(a, b, res)
46-
#define checked_int64_mul(a, b, res) __builtin_smull_overflow(a, b, res)
47-
#else
48-
#define checked_int64_add(a, b, res) __builtin_saddll_overflow(a, b, res)
49-
#define checked_int64_sub(a, b, res) __builtin_ssubll_overflow(a, b, res)
50-
#define checked_int64_mul(a, b, res) __builtin_smulll_overflow(a, b, res)
51-
#endif
43+
#define checked_int64_add(a, b, res) __builtin_add_overflow(a, b, res)
44+
#define checked_int64_sub(a, b, res) __builtin_sub_overflow(a, b, res)
45+
#define checked_int64_mul(a, b, res) __builtin_mul_overflow(a, b, res)
5246
#else
5347
_Static_assert(0,
5448
"Overflow checking not detected; please try a newer compiler");
5549
#endif
5650
// __has_builtin was added in gcc 10, but our muslinux_1_1 build environment
5751
// only has gcc-9.3, so fall back to __GNUC__ macro as long as we have that
5852
#elif __GNUC__ > 7
59-
#if _LP64 || __LP64__ || _ILP64 || __ILP64__
60-
#define checked_int64_add(a, b, res) __builtin_saddl_overflow(a, b, res)
61-
#define checked_int64_sub(a, b, res) __builtin_ssubl_overflow(a, b, res)
62-
#define checked_int64_mul(a, b, res) __builtin_smull_overflow(a, b, res)
63-
#else
64-
#define checked_int64_add(a, b, res) __builtin_saddll_overflow(a, b, res)
65-
#define checked_int64_sub(a, b, res) __builtin_ssubll_overflow(a, b, res)
66-
#define checked_int64_mul(a, b, res) __builtin_smulll_overflow(a, b, res)
67-
#endif
53+
#define checked_int64_add(a, b, res) __builtin_add_overflow(a, b, res)
54+
#define checked_int64_sub(a, b, res) __builtin_sub_overflow(a, b, res)
55+
#define checked_int64_mul(a, b, res) __builtin_mul_overflow(a, b, res)
6856
#else
6957
_Static_assert(0, "__has_builtin not detected; please try a newer compiler");
7058
#endif

0 commit comments

Comments
 (0)