version 1.1.1.1, 2017/01/24 14:48:55
|
version 1.1.1.2, 2021/03/17 00:49:17
|
Line 1
|
Line 1
|
# longlong.m4 serial 8 | # longlong.m4 serial 17 |
dnl Copyright (C) 1999-2006 Free Software Foundation, Inc. | dnl Copyright (C) 1999-2007, 2009-2013 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. |
Line 7 dnl with or without modifications, as long as this not
|
Line 7 dnl with or without modifications, as long as this not
|
dnl From Paul Eggert. |
dnl From Paul Eggert. |
|
|
# 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.60, but can be removed once we | # This fixes a bug in Autoconf 2.61, and can be faster |
# assume 2.61 everywhere. | # than what's in Autoconf 2.62 through 2.68. |
|
|
# 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), AC_TYPE_LONG_LONG_INT will not be | # (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'. |
# defined. In this case you can treat 'long long int' like 'long int'. |
|
|
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_LANG_PROGRAM( | if test "x${ac_cv_prog_cc_c99-no}" = xno; then |
[[long long int ll = 9223372036854775807ll; | ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int |
long long int nll = -9223372036854775807LL; | if test $ac_cv_type_long_long_int = yes; then |
typedef int a[((-9223372036854775807LL < 0 | dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. |
&& 0 < 9223372036854775807ll) | dnl If cross compiling, assume the bug is not important, since |
? 1 : -1)]; | dnl nobody cross compiles for this platform as far as we know. |
int i = 63;]], | AC_RUN_IFELSE( |
[[long long int llmax = 9223372036854775807ll; | [AC_LANG_PROGRAM( |
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) | [[@%:@include <limits.h> |
| (llmax / ll) | (llmax % ll));]])], | @%:@ifndef LLONG_MAX |
[ac_cv_type_long_long_int=yes], | @%:@ define HALF \ |
[ac_cv_type_long_long_int=no])]) | (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=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 |
]) |
]) |
|
|
# This macro is obsolescent and should go away soon. | # Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. |
AC_DEFUN([gl_AC_TYPE_LONG_LONG], | # This fixes a bug in Autoconf 2.61, and can be faster |
| # than what's in Autoconf 2.62 through 2.68. |
| |
| # 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 |
| # will not be defined. In this case you can treat 'unsigned long long int' |
| # like 'unsigned long int'. |
| |
| AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], |
[ |
[ |
AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) | AC_CACHE_CHECK([for unsigned long long int], |
ac_cv_type_long_long=$ac_cv_type_long_long_int | [ac_cv_type_unsigned_long_long_int], |
if test $ac_cv_type_long_long = yes; then | [ac_cv_type_unsigned_long_long_int=yes |
AC_DEFINE(HAVE_LONG_LONG, 1, | if test "x${ac_cv_prog_cc_c99-no}" = xno; then |
[Define if you have the 'long long' type.]) | AC_LINK_IFELSE( |
| [_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 |
| AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], |
| [Define to 1 if the system has the type 'unsigned long long int'.]) |
fi |
fi |
|
]) |
|
|
|
# Expands to a C program that can be used to test for simultaneous support |
|
# of 'long long' and 'unsigned long long'. We don't want to say that |
|
# 'long long' is available if 'unsigned long long' is not, or vice versa, |
|
# because too many programs rely on the symmetry between signed and unsigned |
|
# integer types (excluding 'bool'). |
|
AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], |
|
[ |
|
AC_LANG_PROGRAM( |
|
[[/* For now, do not test the preprocessor; as of 2007 there are too many |
|
implementations with broken preprocessors. Perhaps this can |
|
be revisited in 2012. In the meantime, code should not expect |
|
#if to work with literals wider than 32 bits. */ |
|
/* Test literals. */ |
|
long long int ll = 9223372036854775807ll; |
|
long long int nll = -9223372036854775807LL; |
|
unsigned long long int ull = 18446744073709551615ULL; |
|
/* Test constant expressions. */ |
|
typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) |
|
? 1 : -1)]; |
|
typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 |
|
? 1 : -1)]; |
|
int i = 63;]], |
|
[[/* Test availability of runtime routines for shift and division. */ |
|
long long int llmax = 9223372036854775807ll; |
|
unsigned long long int ullmax = 18446744073709551615ull; |
|
return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) |
|
| (llmax / ll) | (llmax % ll) |
|
| (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) |
|
| (ullmax / ull) | (ullmax % ull));]]) |
]) |
]) |