summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/include/numpy/npy_common.h10
-rw-r--r--numpy/core/setup.py5
-rw-r--r--numpy/core/setup_common.py2
-rw-r--r--numpy/distutils/command/config.py5
4 files changed, 18 insertions, 4 deletions
diff --git a/numpy/core/include/numpy/npy_common.h b/numpy/core/include/numpy/npy_common.h
index 46c745c99..44d7e1010 100644
--- a/numpy/core/include/numpy/npy_common.h
+++ b/numpy/core/include/numpy/npy_common.h
@@ -25,6 +25,16 @@
#define NPY_GCC_OPT_3
#endif
+/*
+ * mark an argument (starting from 1) that must not be NULL and is not checked
+ * DO NOT USE IF FUNCTION CHECKS FOR NULL!! the compiler will remove the check
+ */
+#ifdef HAVE_ATTRIBUTE_NONNULL
+#define NPY_GCC_NONNULL(n) __attribute__((nonnull(n)))
+#else
+#define NPY_GCC_NONNULL(n)
+#endif
+
#if defined HAVE_XMMINTRIN_H && defined HAVE__MM_LOAD_PS
#define NPY_HAVE_SSE_INTRINSICS
#endif
diff --git a/numpy/core/setup.py b/numpy/core/setup.py
index d48368ca1..c28de7c11 100644
--- a/numpy/core/setup.py
+++ b/numpy/core/setup.py
@@ -176,9 +176,8 @@ def check_math_capabilities(config, moredefs, mathlibs):
moredefs.append((fname2def(f), 1))
for dec, fn in OPTIONAL_GCC_ATTRIBUTES:
- if config.check_funcs_once([fn],
- decl=dict((('%s %s' % (dec, fn), True),)),
- call=False):
+ if config.check_func(fn, decl='int %s %s(void *);' % (dec, fn),
+ call=False):
moredefs.append((fname2def(fn), 1))
# C99 functions: float and long double versions
diff --git a/numpy/core/setup_common.py b/numpy/core/setup_common.py
index af2590fc7..4188f4c3f 100644
--- a/numpy/core/setup_common.py
+++ b/numpy/core/setup_common.py
@@ -127,6 +127,8 @@ OPTIONAL_GCC_ATTRIBUTES = [('__attribute__((optimize("unroll-loops")))',
'attribute_optimize_unroll_loops'),
('__attribute__((optimize("O3")))',
'attribute_optimize_opt_3'),
+ ('__attribute__((nonnull (1)))',
+ 'attribute_nonnull'),
]
# Subset of OPTIONAL_STDFUNCS which may alreay have HAVE_* defined by Python.h
diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py
index cadcc1dde..0086e3632 100644
--- a/numpy/distutils/command/config.py
+++ b/numpy/distutils/command/config.py
@@ -307,7 +307,10 @@ int main ()
self._check_compiler()
body = []
if decl:
- body.append("int %s (void);" % func)
+ if type(decl) == str:
+ body.append(decl)
+ else:
+ body.append("int %s (void);" % func)
# Handle MSVC intrinsics: force MS compiler to make a function call.
# Useful to test for some functions when built with optimization on, to
# avoid build error because the intrinsic and our 'fake' test