diff options
author | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-04-12 13:55:01 +0200 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2014-04-23 22:46:47 +0200 |
commit | d598cf1854d84e652ec1e35bb726b147fd6b311d (patch) | |
tree | d15227116dd306694c826b384da9def4c9de8dd2 | |
parent | d0b3f8f4213ee2d285be7d410a0cd7a1a601a7bd (diff) | |
download | python-numpy-d598cf1854d84e652ec1e35bb726b147fd6b311d.tar.gz python-numpy-d598cf1854d84e652ec1e35bb726b147fd6b311d.tar.bz2 python-numpy-d598cf1854d84e652ec1e35bb726b147fd6b311d.zip |
BLD: allow strings for check_func declarations
makes attribute checks more sane and allows adding nonnull
-rw-r--r-- | numpy/core/include/numpy/npy_common.h | 10 | ||||
-rw-r--r-- | numpy/core/setup.py | 5 | ||||
-rw-r--r-- | numpy/core/setup_common.py | 2 | ||||
-rw-r--r-- | numpy/distutils/command/config.py | 5 |
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 |