annotate m4/longlong.m4 @ 441:7b8d89435f30 3.0

Fixed error with forced size pcr operands
author lost@l-w.ca
date Sat, 30 Oct 2010 11:51:25 -0600
parents b8bf63962a99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
434
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
1 # longlong.m4 serial 14
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
2 dnl Copyright (C) 1999-2007, 2009-2010 Free Software Foundation, Inc.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
6
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
7 dnl From Paul Eggert.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
8
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
9 # Define HAVE_LONG_LONG_INT if 'long long int' works.
b8bf63962a99 Added various 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
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
11 # assume 2.62 everywhere.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
12
b8bf63962a99 Added various 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
b8bf63962a99 Added various 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
b8bf63962a99 Added various 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'.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
16
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
17 AC_DEFUN([AC_TYPE_LONG_LONG_INT],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
18 [
b8bf63962a99 Added various 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],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
20 [AC_LINK_IFELSE(
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
21 [_AC_TYPE_LONG_LONG_SNIPPET],
b8bf63962a99 Added various 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.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
23 dnl If cross compiling, assume the bug isn't important, since
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
24 dnl nobody cross compiles for this platform as far as we know.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
25 AC_RUN_IFELSE(
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
26 [AC_LANG_PROGRAM(
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
27 [[@%:@include <limits.h>
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
28 @%:@ifndef LLONG_MAX
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
29 @%:@ define HALF \
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
30 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
31 @%:@ define LLONG_MAX (HALF - 1 + HALF)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
32 @%:@endif]],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
33 [[long long int n = 1;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
34 int i;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
35 for (i = 0; ; i++)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
36 {
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
37 long long int m = n << i;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
38 if (m >> i != n)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
39 return 1;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
40 if (LLONG_MAX / 2 < m)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
41 break;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
42 }
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
43 return 0;]])],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
44 [ac_cv_type_long_long_int=yes],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
45 [ac_cv_type_long_long_int=no],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
46 [ac_cv_type_long_long_int=yes])],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
47 [ac_cv_type_long_long_int=no])])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
48 if test $ac_cv_type_long_long_int = yes; then
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
49 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
50 [Define to 1 if the system has the type `long long int'.])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
51 fi
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
52 ])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
53
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
54 # Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works.
b8bf63962a99 Added various 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
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
56 # assume 2.62 everywhere.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
57
b8bf63962a99 Added various 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
b8bf63962a99 Added various 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
b8bf63962a99 Added various 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'
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
61 # like 'unsigned long int'.
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
62
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
63 AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
64 [
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
65 AC_CACHE_CHECK([for unsigned long long int],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
66 [ac_cv_type_unsigned_long_long_int],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
67 [AC_LINK_IFELSE(
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
68 [_AC_TYPE_LONG_LONG_SNIPPET],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
69 [ac_cv_type_unsigned_long_long_int=yes],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
70 [ac_cv_type_unsigned_long_long_int=no])])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
71 if test $ac_cv_type_unsigned_long_long_int = yes; then
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
72 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
b8bf63962a99 Added various 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'.])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
74 fi
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
75 ])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
76
b8bf63962a99 Added various 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
b8bf63962a99 Added various 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
b8bf63962a99 Added various 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,
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
80 # because too many programs rely on the symmetry between signed and unsigned
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
81 # integer types (excluding 'bool').
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
82 AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
83 [
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
84 AC_LANG_PROGRAM(
b8bf63962a99 Added various 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
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
86 implementations with broken preprocessors. Perhaps this can
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
87 be revisited in 2012. In the meantime, code should not expect
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
88 #if to work with literals wider than 32 bits. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
89 /* Test literals. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
90 long long int ll = 9223372036854775807ll;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
91 long long int nll = -9223372036854775807LL;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
92 unsigned long long int ull = 18446744073709551615ULL;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
93 /* Test constant expressions. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
94 typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
95 ? 1 : -1)];
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
96 typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
97 ? 1 : -1)];
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
98 int i = 63;]],
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
99 [[/* Test availability of runtime routines for shift and division. */
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
100 long long int llmax = 9223372036854775807ll;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
101 unsigned long long int ullmax = 18446744073709551615ull;
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
102 return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
103 | (llmax / ll) | (llmax % ll)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
104 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
105 | (ullmax / ull) | (ullmax % ull));]])
b8bf63962a99 Added various generated files for release
lost@l-w.ca
parents:
diff changeset
106 ])