[PATCH 3/3] build: find FILE_OFFSET_BITS via array

Andrew Bartlett abartlet at samba.org
Thu Jan 30 14:51:51 MST 2014


On Thu, 2014-01-30 at 17:59 -0300, Gustavo Zacarias wrote:
> This makes cross-compiling happy, use a trick similar to autoconf's
> AC_CHECK_SIZEOF macro.
> 
> Signed-off-by: Gustavo Zacarias <gustavo at zacarias.com.ar>
> ---
>  lib/ccan/wscript | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/ccan/wscript b/lib/ccan/wscript
> index 59b8205..626fde3 100644
> --- a/lib/ccan/wscript
> +++ b/lib/ccan/wscript
> @@ -128,14 +128,14 @@ def configure(conf):
>      # use raw routines because wrappers include previous _GNU_SOURCE
>      # or _FILE_OFFSET_BITS defines.
>      conf.check(fragment="""#include <sys/types.h>
> -               int main(void) { return !(sizeof(off_t) < 8); }""",
> -               execute=True, msg='Checking for small off_t',
> +               int main(void) { static int test_array[1 - 2 * !(((long int)(sizeof(off_t))) < 8)]; }""",
> +               msg='Checking for small off_t',
>                 define_name='SMALL_OFF_T')
>      # Unreliable return value above, hence use define.
>      if conf.CONFIG_SET('SMALL_OFF_T'):
>          conf.check(fragment="""#include <sys/types.h>
> -                   int main(void) { return !(sizeof(off_t) >= 8); }""",
> -                   execute=True, msg='Checking for -D_FILE_OFFSET_BITS=64',
> +		   int main(void) { static int test_array[1 - 2 * !(((long int)(sizeof(off_t))) >= 8)]; }""",
> +                   msg='Checking for -D_FILE_OFFSET_BITS=64',
>                     ccflags='-D_FILE_OFFSET_BITS=64',
>                     define_name='HAVE_FILE_OFFSET_BITS')
>  

This looks insane, but I see how it works.  WOW.

I'll double-check this, and then get this in soon.  Thanks for all your
hard work on this. 

Andrew Bartlett

-- 
Andrew Bartlett
http://samba.org/~abartlet/
Authentication Developer, Samba Team  http://samba.org
Samba Developer, Catalyst IT          http://catalyst.net.nz/services/samba






More information about the samba-technical mailing list