annotate m4/longlong.m4 @ 272:d5392bb5da3c 2.5

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