summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorGustavo Zacarias <gustavo@zacarias.com.ar>2014-04-21 10:18:16 -0300
committerDavid Disseldorp <ddiss@samba.org>2014-05-06 18:14:13 +0200
commit6619055f6034c1f7194c821ac230d53bf735adbc (patch)
treed2fedc821d92b64b3d0ece0bd719a0451391344a /buildtools
parent5ac317e2b6a7a45c024490e3e1e2bd00debf150f (diff)
downloadsamba-6619055f6034c1f7194c821ac230d53bf735adbc.tar.gz
build: make wafsamba CHECK_SIZEOF cross-compile friendly
Use the same trick as commit 0d9bb86293c9d39298786df095c73a6251b08b7e We do the same array trick iteratively starting from 1 (byte) by powers of 2 up to 32. The new 'critical' option is used to make the invocation die or not according to each test. The default is True since normally it's expected to find a proper result and should error out if not. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/samba_autoconf.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 59d9e791bde..f60ce9dc2ba 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -304,23 +304,27 @@ def CHECK_FUNCS(conf, list, link=True, lib=None, headers=None):
@conf
-def CHECK_SIZEOF(conf, vars, headers=None, define=None):
+def CHECK_SIZEOF(conf, vars, headers=None, define=None, critical=True):
'''check the size of a type'''
- ret = True
for v in TO_LIST(vars):
v_define = define
+ ret = False
if v_define is None:
v_define = 'SIZEOF_%s' % v.upper().replace(' ', '_')
- if not CHECK_CODE(conf,
- 'printf("%%u", (unsigned)sizeof(%s))' % v,
- define=v_define,
- execute=True,
- define_ret=True,
- quote=False,
- headers=headers,
- local_include=False,
- msg="Checking size of %s" % v):
- ret = False
+ for size in list((1, 2, 4, 8, 16, 32)):
+ if CHECK_CODE(conf,
+ 'static int test_array[1 - 2 * !(((long int)(sizeof(%s))) <= %d)];' % (v, size),
+ define=v_define,
+ quote=False,
+ headers=headers,
+ local_include=False,
+ msg="Checking if size of %s == %d" % (v, size)):
+ conf.DEFINE(v_define, size)
+ ret = True
+ break
+ if not ret and critical:
+ Logs.error("Couldn't determine size of '%s'" % v)
+ sys.exit(1)
return ret
@conf