Skip to content

Commit 132342b

Browse files
committed
move to portable
1 parent c840ef0 commit 132342b

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

pandas/_libs/include/pandas/portable.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,32 @@ The full license is in the LICENSE file, distributed with this software.
3535
do { \
3636
} while (0) /* fallthrough */
3737
#endif
38+
39+
#if defined(_WIN32)
40+
#ifndef ENABLE_INTSAFE_SIGNED_FUNCTIONS
41+
#define ENABLE_INTSAFE_SIGNED_FUNCTIONS
42+
#endif
43+
#include <intsafe.h>
44+
#define checked_int64_add(a, b, res) LongLongAdd(a, b, res)
45+
#define checked_int64_sub(a, b, res) LongLongSub(a, b, res)
46+
#define checked_int64_mul(a, b, res) LongLongMult(a, b, res)
47+
#else
48+
#if defined __has_builtin
49+
#if __has_builtin(__builtin_add_overflow)
50+
#define checked_int64_add(a, b, res) __builtin_add_overflow(a, b, res)
51+
#define checked_int64_sub(a, b, res) __builtin_sub_overflow(a, b, res)
52+
#define checked_int64_mul(a, b, res) __builtin_mul_overflow(a, b, res)
53+
#else
54+
_Static_assert(0,
55+
"Overflow checking not detected; please try a newer compiler");
56+
#endif
57+
// __has_builtin was added in gcc 10, but our muslinux_1_1 build environment
58+
// only has gcc-9.3, so fall back to __GNUC__ macro as long as we have that
59+
#elif __GNUC__ > 7
60+
#define checked_int64_add(a, b, res) __builtin_add_overflow(a, b, res)
61+
#define checked_int64_sub(a, b, res) __builtin_sub_overflow(a, b, res)
62+
#define checked_int64_mul(a, b, res) __builtin_mul_overflow(a, b, res)
63+
#else
64+
_Static_assert(0, "__has_builtin not detected; please try a newer compiler");
65+
#endif
66+
#endif

pandas/_libs/include/pandas/vendored/numpy/datetime/np_datetime.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,6 @@ This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt
2020
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
2121
#endif // NPY_NO_DEPRECATED_API
2222

23-
#if defined(_WIN32)
24-
#ifndef ENABLE_INTSAFE_SIGNED_FUNCTIONS
25-
#define ENABLE_INTSAFE_SIGNED_FUNCTIONS
26-
#endif
27-
#include <intsafe.h>
28-
#define checked_int64_add(a, b, res) LongLongAdd(a, b, res)
29-
#define checked_int64_sub(a, b, res) LongLongSub(a, b, res)
30-
#define checked_int64_mul(a, b, res) LongLongMult(a, b, res)
31-
#else
32-
#if defined __has_builtin
33-
#if __has_builtin(__builtin_add_overflow)
34-
#define checked_int64_add(a, b, res) __builtin_add_overflow(a, b, res)
35-
#define checked_int64_sub(a, b, res) __builtin_sub_overflow(a, b, res)
36-
#define checked_int64_mul(a, b, res) __builtin_mul_overflow(a, b, res)
37-
#else
38-
_Static_assert(0,
39-
"Overflow checking not detected; please try a newer compiler");
40-
#endif
41-
// __has_builtin was added in gcc 10, but our muslinux_1_1 build environment
42-
// only has gcc-9.3, so fall back to __GNUC__ macro as long as we have that
43-
#elif __GNUC__ > 7
44-
#define checked_int64_add(a, b, res) __builtin_add_overflow(a, b, res)
45-
#define checked_int64_sub(a, b, res) __builtin_sub_overflow(a, b, res)
46-
#define checked_int64_mul(a, b, res) __builtin_mul_overflow(a, b, res)
47-
#else
48-
_Static_assert(0, "__has_builtin not detected; please try a newer compiler");
49-
#endif
50-
#endif
51-
5223
#include <numpy/ndarraytypes.h>
5324

5425
typedef struct {

pandas/_libs/src/parser/tokenizer.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ GitHub. See Python Software Foundation License and BSD licenses for these.
1818
*/
1919
#include "pandas/parser/tokenizer.h"
2020
#include "pandas/portable.h"
21-
#include "pandas/vendored/numpy/datetime/np_datetime.h"
2221

2322
#include <ctype.h>
2423
#include <float.h>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt
2121
#endif // NPY_NO_DEPRECATED_API
2222

2323
#include "pandas/vendored/numpy/datetime/np_datetime.h"
24+
#include "pandas/portable.h"
2425
#define NO_IMPORT_ARRAY
2526
#define PY_ARRAY_UNIQUE_SYMBOL PANDAS_DATETIME_NUMPY
2627
#include <numpy/ndarrayobject.h>

0 commit comments

Comments
 (0)