summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/include/numpy/npy_math.h7
-rw-r--r--numpy/core/setup.py4
-rw-r--r--numpy/core/setup_common.py5
3 files changed, 13 insertions, 3 deletions
diff --git a/numpy/core/include/numpy/npy_math.h b/numpy/core/include/numpy/npy_math.h
index bfb35a1a0..a82541ed3 100644
--- a/numpy/core/include/numpy/npy_math.h
+++ b/numpy/core/include/numpy/npy_math.h
@@ -6,6 +6,7 @@ extern "C" {
#endif
#include <math.h>
+#include <npy_config.h>
#include <numpy/npy_common.h>
/*
@@ -151,7 +152,7 @@ double npy_spacing(double x);
/* use a builtins to avoid function calls in tight loops
* documented only on 4.4, but available in at least 4.2 */
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+#if HAVE___BUILTIN_ISNAN
#define npy_isnan(x) __builtin_isnan(x)
#else
#ifndef NPY_HAVE_DECL_ISNAN
@@ -166,7 +167,7 @@ double npy_spacing(double x);
#endif
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+#if HAVE___BUILTIN_ISFINITE
#define npy_isfinite(x) __builtin_isfinite(x)
#else
#ifndef NPY_HAVE_DECL_ISFINITE
@@ -180,7 +181,7 @@ double npy_spacing(double x);
#endif
#endif
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+#if HAVE___BUILTIN_ISINF
#define npy_isinf(x) __builtin_isinf(x)
#else
#ifndef NPY_HAVE_DECL_ISINF
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index 6df82b3fa..58d6072e8 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -161,6 +161,10 @@ def check_math_capabilities(config, moredefs, mathlibs):
check_funcs(OPTIONAL_STDFUNCS)
+ for f, args in OPTIONAL_INTRINSICS:
+ if config.check_func(f, decl=False, call=True, call_args=args):
+ moredefs.append((fname2def(f), 1))
+
# C99 functions: float and long double versions
check_funcs(C99_FUNCS_SINGLE)
check_funcs(C99_FUNCS_EXTENDED)
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
index 3f705cbe4..c9f5030f4 100644
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -97,6 +97,11 @@ OPTIONAL_STDFUNCS = ["expm1", "log1p", "acosh", "asinh", "atanh",
"rint", "trunc", "exp2", "log2", "hypot", "atan2", "pow",
"copysign", "nextafter"]
+# optional gcc compiler builtins and their call arguments
+OPTIONAL_INTRINSICS = [("__builtin_isnan", '5.'),
+ ("__builtin_isinf", '5.'),
+ ("__builtin_isfinite", '5.')]
+
# Subset of OPTIONAL_STDFUNCS which may alreay have HAVE_* defined by Python.h
OPTIONAL_STDFUNCS_MAYBE = ["expm1", "log1p", "acosh", "atanh", "asinh", "hypot",
"copysign"]