diff options
Diffstat (limited to 'm4/longlong.m4')
-rw-r--r-- | m4/longlong.m4 | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/m4/longlong.m4 b/m4/longlong.m4 index ea7c485..1f9e862 100644 --- a/m4/longlong.m4 +++ b/m4/longlong.m4 @@ -1,4 +1,4 @@ -# longlong.m4 serial 6 +# longlong.m4 serial 10 dnl Copyright (C) 1999-2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,6 +10,10 @@ dnl From Paul Eggert. # This fixes a bug in Autoconf 2.60, but can be removed once we # assume 2.61 everywhere. +# Note: If the type 'long long int' exists but is only 32 bits large +# (as on some very old compilers), HAVE_LONG_LONG_INT will not be +# defined. In this case you can treat 'long long int' like 'long int'. + AC_DEFUN([AC_TYPE_LONG_LONG_INT], [ AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], @@ -22,9 +26,33 @@ AC_DEFUN([AC_TYPE_LONG_LONG_INT], ? 1 : -1)]; int i = 63;]], [[long long int llmax = 9223372036854775807ll; - return (ll << 63 | ll >> 63 | ll < i | ll > i - | llmax / ll | llmax % ll);]])], - [ac_cv_type_long_long_int=yes], + return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) + | (llmax / ll) | (llmax % ll));]])], + [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. + dnl If cross compiling, assume the bug isn't important, since + dnl nobody cross compiles for this platform as far as we know. + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[@%:@include <limits.h> + @%:@ifndef LLONG_MAX + @%:@ define HALF \ + (1LL << (sizeof (long long int) * CHAR_BIT - 2)) + @%:@ define LLONG_MAX (HALF - 1 + HALF) + @%:@endif]], + [[long long int n = 1; + int i; + for (i = 0; ; i++) + { + long long int m = n << i; + if (m >> i != n) + return 1; + if (LLONG_MAX / 2 < m) + break; + } + return 0;]])], + [ac_cv_type_long_long_int=yes], + [ac_cv_type_long_long_int=no], + [ac_cv_type_long_long_int=yes])], [ac_cv_type_long_long_int=no])]) if test $ac_cv_type_long_long_int = yes; then AC_DEFINE([HAVE_LONG_LONG_INT], 1, |