summaryrefslogtreecommitdiff
path: root/numpy/distutils/command/autodist.py
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2014-09-29 23:03:18 +0200
committerJulian Taylor <jtaylor.debian@googlemail.com>2014-09-29 23:06:44 +0200
commit5478aafee86af3447b230ede93738cca876844b1 (patch)
tree777c40d60b16f1d5e0fcd36d37c5c890475bde59 /numpy/distutils/command/autodist.py
parent8521e280e7e5e71b89641d06669b82e210cf0b7d (diff)
downloadnumpy-5478aafee86af3447b230ede93738cca876844b1.tar.gz
BLD: add check for C99 restrict keyword
Define it as NPY_RESTRICT Restrict indicates a memory block does not alias, gcc supports it in c89 with the __restrict__ keyword.
Diffstat (limited to 'numpy/distutils/command/autodist.py')
-rw-r--r--numpy/distutils/command/autodist.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/numpy/distutils/command/autodist.py b/numpy/distutils/command/autodist.py
index 5a9470b9b..af53c5104 100644
--- a/numpy/distutils/command/autodist.py
+++ b/numpy/distutils/command/autodist.py
@@ -28,6 +28,23 @@ static %(inline)s int static_func (void)
return ''
+def check_restrict(cmd):
+ """Return the restrict identifier (may be empty)."""
+ cmd._check_compiler()
+ body = """
+static int static_func (char * %(restrict)s a)
+{
+ return 0;
+}
+"""
+
+ for kw in ['restrict', '__restrict__', '__restrict']:
+ st = cmd.try_compile(body % {'restrict': kw}, None, None)
+ if st:
+ return kw
+
+ return ''
+
def check_compiler_gcc4(cmd):
"""Return True if the C compiler is GCC 4.x."""
cmd._check_compiler()