]> sjero.net Git - wget/blob - m4/longlong.m4
gnulib-tool --update; includes fix for maint.mk/gzip discovered by Steven M. Schweda.
[wget] / m4 / longlong.m4
1 # longlong.m4 serial 11
2 dnl Copyright (C) 1999-2007 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl From Paul Eggert.
8
9 # Define HAVE_LONG_LONG_INT if 'long long int' works.
10 # This fixes a bug in Autoconf 2.61, but can be removed once we
11 # assume 2.62 everywhere.
12
13 # Note: If the type 'long long int' exists but is only 32 bits large
14 # (as on some very old compilers), HAVE_LONG_LONG_INT will not be
15 # defined. In this case you can treat 'long long int' like 'long int'.
16
17 AC_DEFUN([AC_TYPE_LONG_LONG_INT],
18 [
19   AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
20     [AC_LINK_IFELSE(
21        [AC_LANG_PROGRAM(
22           [[#if ! (-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
23               error in preprocessor;
24             #endif
25             long long int ll = 9223372036854775807ll;
26             long long int nll = -9223372036854775807LL;
27             typedef int a[((-9223372036854775807LL < 0
28                             && 0 < 9223372036854775807ll)
29                            ? 1 : -1)];
30             int i = 63;]],
31           [[long long int llmax = 9223372036854775807ll;
32             return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
33                     | (llmax / ll) | (llmax % ll));]])],
34        [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
35         dnl If cross compiling, assume the bug isn't important, since
36         dnl nobody cross compiles for this platform as far as we know.
37         AC_RUN_IFELSE(
38           [AC_LANG_PROGRAM(
39              [[@%:@include <limits.h>
40                @%:@ifndef LLONG_MAX
41                @%:@ define HALF \
42                         (1LL << (sizeof (long long int) * CHAR_BIT - 2))
43                @%:@ define LLONG_MAX (HALF - 1 + HALF)
44                @%:@endif]],
45              [[long long int n = 1;
46                int i;
47                for (i = 0; ; i++)
48                  {
49                    long long int m = n << i;
50                    if (m >> i != n)
51                      return 1;
52                    if (LLONG_MAX / 2 < m)
53                      break;
54                  }
55                return 0;]])],
56           [ac_cv_type_long_long_int=yes],
57           [ac_cv_type_long_long_int=no],
58           [ac_cv_type_long_long_int=yes])],
59        [ac_cv_type_long_long_int=no])])
60   if test $ac_cv_type_long_long_int = yes; then
61     AC_DEFINE([HAVE_LONG_LONG_INT], 1,
62       [Define to 1 if the system has the type `long long int'.])
63   fi
64 ])
65
66 # This macro is obsolescent and should go away soon.
67 AC_DEFUN([gl_AC_TYPE_LONG_LONG],
68 [
69   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
70   ac_cv_type_long_long=$ac_cv_type_long_long_int
71   if test $ac_cv_type_long_long = yes; then
72     AC_DEFINE(HAVE_LONG_LONG, 1,
73       [Define if you have the 'long long' type.])
74   fi
75 ])