[Numpy-svn] r6497 - trunk/numpy/distutils/command
numpy-svn at scipy.org
numpy-svn at scipy.org
Thu Feb 26 09:07:14 EST 2009
Author: cdavid
Date: 2009-02-26 08:07:09 -0600 (Thu, 26 Feb 2009)
New Revision: 6497
Modified:
trunk/numpy/distutils/command/config.py
Log:
Add an expected keyword for check_type_size check, to speed things up on common platforms.
Modified: trunk/numpy/distutils/command/config.py
===================================================================
--- trunk/numpy/distutils/command/config.py 2009-02-26 14:06:55 UTC (rev 6496)
+++ trunk/numpy/distutils/command/config.py 2009-02-26 14:07:09 UTC (rev 6497)
@@ -165,7 +165,7 @@
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 @@
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;
More information about the Numpy-svn
mailing list