build: find blkcnt_t size via array
authorGustavo Zacarias <gustavo@zacarias.com.ar>
Mon, 21 Apr 2014 13:18:18 +0000 (10:18 -0300)
committerDavid Disseldorp <ddiss@samba.org>
Tue, 6 May 2014 18:37:16 +0000 (20:37 +0200)
Using the same trick as commit 0d9bb86293c9d39298786df095c73a6251b08b7e
find blkcnt_t size via an array so that it can be determined via build
rather than running it.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): David Disseldorp <ddiss@samba.org>
Autobuild-Date(master): Tue May  6 20:37:16 CEST 2014 on sn-devel-104

source3/wscript

index 47839277e7308be52007a1754040aa8533f47798..2bca8fab770d485dc3a50240e3fc6ca7f426d6d4 100644 (file)
@@ -277,18 +277,20 @@ int main(int argc, char **argv)
                                 headers='sys/types.h sys/stat.h unistd.h')
 
     if "HAVE_BLKCNT_T" in conf.env:
-       conf.CHECK_CODE('''
-       return sizeof(blkcnt_t) == 4 ? 0 : 1''',
-               'SIZEOF_BLKCNT_T_4', execute=True,
-               headers='replace.h sys/types.h sys/stat.h unistd.h',
-               msg="Checking whether blkcnt_t is 32 bit")
+        conf.CHECK_CODE('''
+        static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 4)];''',
+                'SIZEOF_BLKCNT_T_4',
+                headers='replace.h sys/types.h sys/stat.h unistd.h',
+                msg="Checking whether blkcnt_t is 32 bit")
 
+    # If sizeof is 4 it can't be 8
     if "HAVE_BLKCNT_T" in conf.env:
-       conf.CHECK_CODE('''
-       return sizeof(blkcnt_t) == 8 ? 0 : 1''',
-               'SIZEOF_BLKCNT_T_8', execute=True,
-               headers='replace.h sys/types.h sys/stat.h unistd.h',
-               msg="Checking whether blkcnt_t is 64 bit")
+        if not conf.CONFIG_SET('SIZEOF_BLKCNT_T_4'):
+            conf.CHECK_CODE('''
+            static int test_array[1 - 2 * !(((long int)(sizeof(blkcnt_t))) <= 8)];''',
+                    'SIZEOF_BLKCNT_T_8',
+                    headers='replace.h sys/types.h sys/stat.h unistd.h',
+                    msg="Checking whether blkcnt_t is 64 bit")
 
     # Check for POSIX capability support
     conf.CHECK_FUNCS_IN('cap_get_proc', 'cap', headers='sys/capability.h')