annotate m4/longlong.m4 @ 423:079d43b6967b 3.0-beta2 3.0-beta2

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