|
12 | 12 | # PARTICULAR PURPOSE. |
13 | 13 |
|
14 | 14 | m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) |
| 15 | +# longlong.m4 serial 17 |
| 16 | +dnl Copyright (C) 1999-2007, 2009-2016 Free Software Foundation, Inc. |
| 17 | +dnl This file is free software; the Free Software Foundation |
| 18 | +dnl gives unlimited permission to copy and/or distribute it, |
| 19 | +dnl with or without modifications, as long as this notice is preserved. |
| 20 | + |
| 21 | +dnl From Paul Eggert. |
| 22 | + |
| 23 | +# Define HAVE_LONG_LONG_INT if 'long long int' works. |
| 24 | +# This fixes a bug in Autoconf 2.61, and can be faster |
| 25 | +# than what's in Autoconf 2.62 through 2.68. |
| 26 | + |
| 27 | +# Note: If the type 'long long int' exists but is only 32 bits large |
| 28 | +# (as on some very old compilers), HAVE_LONG_LONG_INT will not be |
| 29 | +# defined. In this case you can treat 'long long int' like 'long int'. |
| 30 | + |
| 31 | +AC_DEFUN([AC_TYPE_LONG_LONG_INT], |
| 32 | +[ |
| 33 | + AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) |
| 34 | + AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], |
| 35 | + [ac_cv_type_long_long_int=yes |
| 36 | + if test "x${ac_cv_prog_cc_c99-no}" = xno; then |
| 37 | + ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int |
| 38 | + if test $ac_cv_type_long_long_int = yes; then |
| 39 | + dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004. |
| 40 | + dnl If cross compiling, assume the bug is not important, since |
| 41 | + dnl nobody cross compiles for this platform as far as we know. |
| 42 | + AC_RUN_IFELSE( |
| 43 | + [AC_LANG_PROGRAM( |
| 44 | + [[@%:@include <limits.h> |
| 45 | + @%:@ifndef LLONG_MAX |
| 46 | + @%:@ define HALF \ |
| 47 | + (1LL << (sizeof (long long int) * CHAR_BIT - 2)) |
| 48 | + @%:@ define LLONG_MAX (HALF - 1 + HALF) |
| 49 | + @%:@endif]], |
| 50 | + [[long long int n = 1; |
| 51 | + int i; |
| 52 | + for (i = 0; ; i++) |
| 53 | + { |
| 54 | + long long int m = n << i; |
| 55 | + if (m >> i != n) |
| 56 | + return 1; |
| 57 | + if (LLONG_MAX / 2 < m) |
| 58 | + break; |
| 59 | + } |
| 60 | + return 0;]])], |
| 61 | + [], |
| 62 | + [ac_cv_type_long_long_int=no], |
| 63 | + [:]) |
| 64 | + fi |
| 65 | + fi]) |
| 66 | + if test $ac_cv_type_long_long_int = yes; then |
| 67 | + AC_DEFINE([HAVE_LONG_LONG_INT], [1], |
| 68 | + [Define to 1 if the system has the type 'long long int'.]) |
| 69 | + fi |
| 70 | +]) |
| 71 | + |
| 72 | +# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. |
| 73 | +# This fixes a bug in Autoconf 2.61, and can be faster |
| 74 | +# than what's in Autoconf 2.62 through 2.68. |
| 75 | + |
| 76 | +# Note: If the type 'unsigned long long int' exists but is only 32 bits |
| 77 | +# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT |
| 78 | +# will not be defined. In this case you can treat 'unsigned long long int' |
| 79 | +# like 'unsigned long int'. |
| 80 | + |
| 81 | +AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], |
| 82 | +[ |
| 83 | + AC_CACHE_CHECK([for unsigned long long int], |
| 84 | + [ac_cv_type_unsigned_long_long_int], |
| 85 | + [ac_cv_type_unsigned_long_long_int=yes |
| 86 | + if test "x${ac_cv_prog_cc_c99-no}" = xno; then |
| 87 | + AC_LINK_IFELSE( |
| 88 | + [_AC_TYPE_LONG_LONG_SNIPPET], |
| 89 | + [], |
| 90 | + [ac_cv_type_unsigned_long_long_int=no]) |
| 91 | + fi]) |
| 92 | + if test $ac_cv_type_unsigned_long_long_int = yes; then |
| 93 | + AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1], |
| 94 | + [Define to 1 if the system has the type 'unsigned long long int'.]) |
| 95 | + fi |
| 96 | +]) |
| 97 | + |
| 98 | +# Expands to a C program that can be used to test for simultaneous support |
| 99 | +# of 'long long' and 'unsigned long long'. We don't want to say that |
| 100 | +# 'long long' is available if 'unsigned long long' is not, or vice versa, |
| 101 | +# because too many programs rely on the symmetry between signed and unsigned |
| 102 | +# integer types (excluding 'bool'). |
| 103 | +AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET], |
| 104 | +[ |
| 105 | + AC_LANG_PROGRAM( |
| 106 | + [[/* For now, do not test the preprocessor; as of 2007 there are too many |
| 107 | + implementations with broken preprocessors. Perhaps this can |
| 108 | + be revisited in 2012. In the meantime, code should not expect |
| 109 | + #if to work with literals wider than 32 bits. */ |
| 110 | + /* Test literals. */ |
| 111 | + long long int ll = 9223372036854775807ll; |
| 112 | + long long int nll = -9223372036854775807LL; |
| 113 | + unsigned long long int ull = 18446744073709551615ULL; |
| 114 | + /* Test constant expressions. */ |
| 115 | + typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll) |
| 116 | + ? 1 : -1)]; |
| 117 | + typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1 |
| 118 | + ? 1 : -1)]; |
| 119 | + int i = 63;]], |
| 120 | + [[/* Test availability of runtime routines for shift and division. */ |
| 121 | + long long int llmax = 9223372036854775807ll; |
| 122 | + unsigned long long int ullmax = 18446744073709551615ull; |
| 123 | + return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) |
| 124 | + | (llmax / ll) | (llmax % ll) |
| 125 | + | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i) |
| 126 | + | (ullmax / ull) | (ullmax % ull));]]) |
| 127 | +]) |
| 128 | + |
15 | 129 | m4_include([m4/ax_append_flag.m4]) |
16 | 130 | m4_include([m4/ax_check_compile_flag.m4]) |
17 | 131 | m4_include([m4/ax_check_link_flag.m4]) |
|
0 commit comments