Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22dd86a

Browse files
committed
Add an expected keyword for check_type_size check, to speed things up on common platforms.
1 parent f76f109 commit 22dd86a

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

numpy/distutils/command/config.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def check_decl(self, symbol,
165165

166166
return self.try_compile(body, headers, include_dirs)
167167

168-
def check_type_size(self, type_name, headers=None, include_dirs=None, library_dirs=None):
168+
def check_type_size(self, type_name, headers=None, include_dirs=None, library_dirs=None, expected=None):
169169
"""Check size of a given type."""
170170
self._check_compiler()
171171

@@ -185,6 +185,27 @@ def check_type_size(self, type_name, headers=None, include_dirs=None, library_di
185185
headers, include_dirs, 'c')
186186
self._clean()
187187

188+
if expected:
189+
body = r"""
190+
typedef %(type)s npy_check_sizeof_type;
191+
int main ()
192+
{
193+
static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) == %(size)s)];
194+
test_array [0] = 0
195+
196+
;
197+
return 0;
198+
}
199+
"""
200+
for size in expected:
201+
try:
202+
self._compile(body % {'type': type_name, 'size': size},
203+
headers, include_dirs, 'c')
204+
self._clean()
205+
return size
206+
except CompileError:
207+
pass
208+
188209
# this fails to *compile* if size > sizeof(type)
189210
body = r"""
190211
typedef %(type)s npy_check_sizeof_type;

0 commit comments

Comments
 (0)