|
version 1.1, 2012/02/21 22:57:49
|
version 1.1.1.3, 2021/03/17 13:38:46
|
|
Line 1
|
Line 1
|
| # longlong.m4 serial 14 | # longlong.m4 serial 18 |
| dnl Copyright (C) 1999-2007, 2009 Free Software Foundation, Inc. | dnl Copyright (C) 1999-2007, 2009-2019 Free Software Foundation, Inc. |
| dnl This file is free software; the Free Software Foundation |
dnl This file is free software; the Free Software Foundation |
| dnl gives unlimited permission to copy and/or distribute it, |
dnl gives unlimited permission to copy and/or distribute it, |
| dnl with or without modifications, as long as this notice is preserved. |
dnl with or without modifications, as long as this notice is preserved. |
| |
|
| dnl From Paul Eggert. |
dnl From Paul Eggert. |
| |
|
| |
AC_PREREQ([2.62]) |
| |
|
| # Define HAVE_LONG_LONG_INT if 'long long int' works. |
# Define HAVE_LONG_LONG_INT if 'long long int' works. |
| # This fixes a bug in Autoconf 2.61, but can be removed once we | # This can be faster than what's in Autoconf 2.62 through 2.68. |
| # assume 2.62 everywhere. | |
| |
|
| # Note: If the type 'long long int' exists but is only 32 bits large |
# 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 |
# (as on some very old compilers), HAVE_LONG_LONG_INT will not be |
|
Line 16 dnl From Paul Eggert.
|
Line 17 dnl From Paul Eggert.
|
| |
|
| AC_DEFUN([AC_TYPE_LONG_LONG_INT], |
AC_DEFUN([AC_TYPE_LONG_LONG_INT], |
| [ |
[ |
| |
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) |
| AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], |
AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], |
| [AC_LINK_IFELSE( | [ac_cv_type_long_long_int=yes |
| [_AC_TYPE_LONG_LONG_SNIPPET], | if test "x${ac_cv_prog_cc_c99-no}" = xno; then |
| [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. | ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int |
| dnl If cross compiling, assume the bug isn't important, since | if test $ac_cv_type_long_long_int = yes; then |
| dnl nobody cross compiles for this platform as far as we know. | dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. |
| AC_RUN_IFELSE( | dnl If cross compiling, assume the bug is not important, since |
| [AC_LANG_PROGRAM( | dnl nobody cross compiles for this platform as far as we know. |
| [[@%:@include <limits.h> | AC_RUN_IFELSE( |
| @%:@ifndef LLONG_MAX | [AC_LANG_PROGRAM( |
| @%:@ define HALF \ | [[@%:@include <limits.h> |
| (1LL << (sizeof (long long int) * CHAR_BIT - 2)) | @%:@ifndef LLONG_MAX |
| @%:@ define LLONG_MAX (HALF - 1 + HALF) | @%:@ define HALF \ |
| @%:@endif]], | (1LL << (sizeof (long long int) * CHAR_BIT - 2)) |
| [[long long int n = 1; | @%:@ define LLONG_MAX (HALF - 1 + HALF) |
| int i; | @%:@endif]], |
| for (i = 0; ; i++) | [[long long int n = 1; |
| { | int i; |
| long long int m = n << i; | for (i = 0; ; i++) |
| if (m >> i != n) | { |
| return 1; | long long int m = n << i; |
| if (LLONG_MAX / 2 < m) | if (m >> i != n) |
| break; | return 1; |
| } | if (LLONG_MAX / 2 < m) |
| return 0;]])], | break; |
| [ac_cv_type_long_long_int=yes], | } |
| [ac_cv_type_long_long_int=no], | return 0;]])], |
| [ac_cv_type_long_long_int=yes])], | [], |
| [ac_cv_type_long_long_int=no])]) | [ac_cv_type_long_long_int=no], |
| | [:]) |
| | fi |
| | fi]) |
| if test $ac_cv_type_long_long_int = yes; then |
if test $ac_cv_type_long_long_int = yes; then |
| AC_DEFINE([HAVE_LONG_LONG_INT], [1], |
AC_DEFINE([HAVE_LONG_LONG_INT], [1], |
| [Define to 1 if the system has the type `long long int'.]) | [Define to 1 if the system has the type 'long long int'.]) |
| fi |
fi |
| ]) |
]) |
| |
|
| # Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. |
# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. |
| # This fixes a bug in Autoconf 2.61, but can be removed once we | # This can be faster than what's in Autoconf 2.62 through 2.68. |
| # assume 2.62 everywhere. | |
| |
|
| # Note: If the type 'unsigned long long int' exists but is only 32 bits |
# Note: If the type 'unsigned long long int' exists but is only 32 bits |
| # large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT |
# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT |
|
Line 64 AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
|
Line 68 AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
|
| [ |
[ |
| AC_CACHE_CHECK([for unsigned long long int], |
AC_CACHE_CHECK([for unsigned long long int], |
| [ac_cv_type_unsigned_long_long_int], |
[ac_cv_type_unsigned_long_long_int], |
| [AC_LINK_IFELSE( | [ac_cv_type_unsigned_long_long_int=yes |
| [_AC_TYPE_LONG_LONG_SNIPPET], | if test "x${ac_cv_prog_cc_c99-no}" = xno; then |
| [ac_cv_type_unsigned_long_long_int=yes], | AC_LINK_IFELSE( |
| [ac_cv_type_unsigned_long_long_int=no])]) | [_AC_TYPE_LONG_LONG_SNIPPET], |
| | [], |
| | [ac_cv_type_unsigned_long_long_int=no]) |
| | fi]) |
| if test $ac_cv_type_unsigned_long_long_int = yes; then |
if test $ac_cv_type_unsigned_long_long_int = yes; then |
| AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], |
AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], |
| [Define to 1 if the system has the type `unsigned long long int'.]) | [Define to 1 if the system has the type 'unsigned long long int'.]) |
| fi |
fi |
| ]) |
]) |
| |
|
|
Line 83 AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
|
Line 90 AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
|
| [ |
[ |
| AC_LANG_PROGRAM( |
AC_LANG_PROGRAM( |
| [[/* For now, do not test the preprocessor; as of 2007 there are too many |
[[/* For now, do not test the preprocessor; as of 2007 there are too many |
| implementations with broken preprocessors. Perhaps this can | implementations with broken preprocessors. Perhaps this can |
| be revisited in 2012. In the meantime, code should not expect | be revisited in 2012. In the meantime, code should not expect |
| #if to work with literals wider than 32 bits. */ | #if to work with literals wider than 32 bits. */ |
| /* Test literals. */ |
/* Test literals. */ |
| long long int ll = 9223372036854775807ll; |
long long int ll = 9223372036854775807ll; |
| long long int nll = -9223372036854775807LL; |
long long int nll = -9223372036854775807LL; |
| unsigned long long int ull = 18446744073709551615ULL; |
unsigned long long int ull = 18446744073709551615ULL; |
| /* Test constant expressions. */ |
/* Test constant expressions. */ |
| typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) |
typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) |
| ? 1 : -1)]; | ? 1 : -1)]; |
| typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 |
typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 |
| ? 1 : -1)]; | ? 1 : -1)]; |
| int i = 63;]], |
int i = 63;]], |
| [[/* Test availability of runtime routines for shift and division. */ |
[[/* Test availability of runtime routines for shift and division. */ |
| long long int llmax = 9223372036854775807ll; |
long long int llmax = 9223372036854775807ll; |
| unsigned long long int ullmax = 18446744073709551615ull; |
unsigned long long int ullmax = 18446744073709551615ull; |
| return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) |
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) |
| | (llmax / ll) | (llmax % ll) | | (llmax / ll) | (llmax % ll) |
| | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) | | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) |
| | (ullmax / ull) | (ullmax % ull));]]) | | (ullmax / ull) | (ullmax % ull));]]) |
| ]) |
]) |