2N/A# longlong.m4 serial 14
2N/Adnl Copyright (C) 1999-2007, 2009-2010 Free Software Foundation, Inc.
2N/Adnl This file is free software; the Free Software Foundation
2N/Adnl gives unlimited permission to copy and/or distribute it,
2N/Adnl with or without modifications, as long as this notice is preserved.
2N/A
2N/Adnl From Paul Eggert.
2N/A
2N/A# Define HAVE_LONG_LONG_INT if 'long long int' works.
2N/A# This fixes a bug in Autoconf 2.61, but can be removed once we
2N/A# assume 2.62 everywhere.
2N/A
2N/A# Note: If the type 'long long int' exists but is only 32 bits large
2N/A# (as on some very old compilers), HAVE_LONG_LONG_INT will not be
2N/A# defined. In this case you can treat 'long long int' like 'long int'.
2N/A
2N/AAC_DEFUN([AC_TYPE_LONG_LONG_INT],
2N/A[
2N/A AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
2N/A [AC_LINK_IFELSE(
2N/A [_AC_TYPE_LONG_LONG_SNIPPET],
2N/A [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
2N/A dnl If cross compiling, assume the bug isn't important, since
2N/A dnl nobody cross compiles for this platform as far as we know.
2N/A AC_RUN_IFELSE(
2N/A [AC_LANG_PROGRAM(
2N/A [[@%:@include <limits.h>
2N/A @%:@ifndef LLONG_MAX
2N/A @%:@ define HALF \
2N/A (1LL << (sizeof (long long int) * CHAR_BIT - 2))
2N/A @%:@ define LLONG_MAX (HALF - 1 + HALF)
2N/A @%:@endif]],
2N/A [[long long int n = 1;
2N/A int i;
2N/A for (i = 0; ; i++)
2N/A {
2N/A long long int m = n << i;
2N/A if (m >> i != n)
2N/A return 1;
2N/A if (LLONG_MAX / 2 < m)
2N/A break;
2N/A }
2N/A return 0;]])],
2N/A [ac_cv_type_long_long_int=yes],
2N/A [ac_cv_type_long_long_int=no],
2N/A [ac_cv_type_long_long_int=yes])],
2N/A [ac_cv_type_long_long_int=no])])
2N/A if test $ac_cv_type_long_long_int = yes; then
2N/A AC_DEFINE([HAVE_LONG_LONG_INT], [1],
2N/A [Define to 1 if the system has the type `long long int'.])
2N/A fi
2N/A])
2N/A
2N/A# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
2N/A# This fixes a bug in Autoconf 2.61, but can be removed once we
2N/A# assume 2.62 everywhere.
2N/A
2N/A# Note: If the type 'unsigned long long int' exists but is only 32 bits
2N/A# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT
2N/A# will not be defined. In this case you can treat 'unsigned long long int'
2N/A# like 'unsigned long int'.
2N/A
2N/AAC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
2N/A[
2N/A AC_CACHE_CHECK([for unsigned long long int],
2N/A [ac_cv_type_unsigned_long_long_int],
2N/A [AC_LINK_IFELSE(
2N/A [_AC_TYPE_LONG_LONG_SNIPPET],
2N/A [ac_cv_type_unsigned_long_long_int=yes],
2N/A [ac_cv_type_unsigned_long_long_int=no])])
2N/A if test $ac_cv_type_unsigned_long_long_int = yes; then
2N/A AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
2N/A [Define to 1 if the system has the type `unsigned long long int'.])
2N/A fi
2N/A])
2N/A
2N/A# Expands to a C program that can be used to test for simultaneous support
2N/A# of 'long long' and 'unsigned long long'. We don't want to say that
2N/A# 'long long' is available if 'unsigned long long' is not, or vice versa,
2N/A# because too many programs rely on the symmetry between signed and unsigned
2N/A# integer types (excluding 'bool').
2N/AAC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
2N/A[
2N/A AC_LANG_PROGRAM(
2N/A [[/* For now, do not test the preprocessor; as of 2007 there are too many
2N/A implementations with broken preprocessors. Perhaps this can
2N/A be revisited in 2012. In the meantime, code should not expect
2N/A #if to work with literals wider than 32 bits. */
2N/A /* Test literals. */
2N/A long long int ll = 9223372036854775807ll;
2N/A long long int nll = -9223372036854775807LL;
2N/A unsigned long long int ull = 18446744073709551615ULL;
2N/A /* Test constant expressions. */
2N/A typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
2N/A ? 1 : -1)];
2N/A typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
2N/A ? 1 : -1)];
2N/A int i = 63;]],
2N/A [[/* Test availability of runtime routines for shift and division. */
2N/A long long int llmax = 9223372036854775807ll;
2N/A unsigned long long int ullmax = 18446744073709551615ull;
2N/A return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
2N/A | (llmax / ll) | (llmax % ll)
2N/A | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
2N/A | (ullmax / ull) | (ullmax % ull));]])
2N/A])