summaryrefslogtreecommitdiff
path: root/numpy/distutils/command/config.py
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2009-02-26 14:07:09 +0000
committerDavid Cournapeau <cournape@gmail.com>2009-02-26 14:07:09 +0000
commit22dd86ab5e2c52aff12472d5043dc5145d4a2aad (patch)
tree9450ba02ef142feb0768b9157f8a647bc4559242 /numpy/distutils/command/config.py
parentf76f109d10ab41bd605568d371ab2ddc87afb6e4 (diff)
downloadnumpy-22dd86ab5e2c52aff12472d5043dc5145d4a2aad.tar.gz
Add an expected keyword for check_type_size check, to speed things up on common platforms.
Diffstat (limited to 'numpy/distutils/command/config.py')
-rw-r--r--numpy/distutils/command/config.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py
index 0940355d1..f91af019b 100644
--- a/numpy/distutils/command/config.py
+++ b/numpy/distutils/command/config.py
@@ -165,7 +165,7 @@ int main()
return self.try_compile(body, headers, include_dirs)
- def check_type_size(self, type_name, headers=None, include_dirs=None, library_dirs=None):
+ def check_type_size(self, type_name, headers=None, include_dirs=None, library_dirs=None, expected=None):
"""Check size of a given type."""
self._check_compiler()
@@ -185,6 +185,27 @@ int main ()
headers, include_dirs, 'c')
self._clean()
+ if expected:
+ body = r"""
+typedef %(type)s npy_check_sizeof_type;
+int main ()
+{
+ static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) == %(size)s)];
+ test_array [0] = 0
+
+ ;
+ return 0;
+}
+"""
+ for size in expected:
+ try:
+ self._compile(body % {'type': type_name, 'size': size},
+ headers, include_dirs, 'c')
+ self._clean()
+ return size
+ except CompileError:
+ pass
+
# this fails to *compile* if size > sizeof(type)
body = r"""
typedef %(type)s npy_check_sizeof_type;