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