1AC_DEFUN([AC_TYPE_LONG_DOUBLE],
2[
3  AC_CACHE_CHECK([for long double], [ac_cv_type_long_double],
4    [if test "$GCC" = yes; then
5       ac_cv_type_long_double=yes
6     else
7       AC_COMPILE_IFELSE(
8         [AC_LANG_BOOL_COMPILE_TRY(
9            [[/* The Stardent Vistra knows sizeof (long double), but does
10                 not support it.  */
11              long double foo = 0.0L;]],
12            [[/* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
13              sizeof (double) <= sizeof (long double)]])],
14         [ac_cv_type_long_double=yes],
15         [ac_cv_type_long_double=no])
16     fi])
17  if test $ac_cv_type_long_double = yes; then
18    AC_DEFINE([HAVE_LONG_DOUBLE], 1,
19      [Define to 1 if the system has the type `long double'.])
20  fi
21])
22
23AC_DEFUN([AC_TYPE_LONG_LONG_INT],
24[
25  AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
26    [AC_LINK_IFELSE(
27       [_AC_TYPE_LONG_LONG_SNIPPET],
28       [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
29        dnl If cross compiling, assume the bug isn't important, since
30        dnl nobody cross compiles for this platform as far as we know.
31        AC_RUN_IFELSE(
32          [AC_LANG_PROGRAM(
33             [[@%:@include <limits.h>
34               @%:@ifndef LLONG_MAX
35               @%:@ define HALF \
36                        (1LL << (sizeof (long long int) * CHAR_BIT - 2))
37               @%:@ define LLONG_MAX (HALF - 1 + HALF)
38               @%:@endif]],
39             [[long long int n = 1;
40               int i;
41               for (i = 0; ; i++)
42                 {
43                   long long int m = n << i;
44                   if (m >> i != n)
45                     return 1;
46                   if (LLONG_MAX / 2 < m)
47                     break;
48                 }
49               return 0;]])],
50          [ac_cv_type_long_long_int=yes],
51          [ac_cv_type_long_long_int=no],
52          [ac_cv_type_long_long_int=yes])],
53       [ac_cv_type_long_long_int=no])])
54  if test $ac_cv_type_long_long_int = yes; then
55    AC_DEFINE([HAVE_LONG_LONG_INT], 1,
56      [Define to 1 if the system has the type `long long int'.])
57  fi
58])
59
60AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
61[
62  AC_CACHE_CHECK([for unsigned long long int],
63    [ac_cv_type_unsigned_long_long_int],
64    [AC_LINK_IFELSE(
65       [_AC_TYPE_LONG_LONG_SNIPPET],
66       [ac_cv_type_unsigned_long_long_int=yes],
67       [ac_cv_type_unsigned_long_long_int=no])])
68  if test $ac_cv_type_unsigned_long_long_int = yes; then
69    AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], 1,
70      [Define to 1 if the system has the type `unsigned long long int'.])
71  fi
72])
73
74AC_DEFUN([AC_TYPE_INTMAX_T],
75[
76  AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
77  AC_CHECK_TYPE([intmax_t],
78    [AC_DEFINE([HAVE_INTMAX_T], 1,
79       [Define to 1 if the system has the type `intmax_t'.])],
80    [test $ac_cv_type_long_long_int = yes \
81       && ac_type='long long int' \
82       || ac_type='long int'
83     AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
84       [Define to the widest signed integer type
85        if <stdint.h> and <inttypes.h> do not define.])])
86])
87
88AC_DEFUN([AC_TYPE_UINTMAX_T],
89[
90  AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
91  AC_CHECK_TYPE([uintmax_t],
92    [AC_DEFINE([HAVE_UINTMAX_T], 1,
93       [Define to 1 if the system has the type `uintmax_t'.])],
94    [test $ac_cv_type_unsigned_long_long_int = yes \
95       && ac_type='unsigned long long int' \
96       || ac_type='unsigned long int'
97     AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
98       [Define to the widest unsigned integer type
99        if <stdint.h> and <inttypes.h> do not define.])])
100])
101
102AC_DEFUN([AC_TYPE_UINTPTR_T],
103[
104  AC_CHECK_TYPE([uintptr_t],
105    [AC_DEFINE([HAVE_UINTPTR_T], 1,
106       [Define to 1 if the system has the type `uintptr_t'.])],
107    [for ac_type in 'unsigned int' 'unsigned long int' \
108        'unsigned long long int'; do
109       AC_COMPILE_IFELSE(
110         [AC_LANG_BOOL_COMPILE_TRY(
111            [AC_INCLUDES_DEFAULT],
112            [[sizeof (void *) <= sizeof ($ac_type)]])],
113         [AC_DEFINE_UNQUOTED([uintptr_t], [$ac_type],
114            [Define to the type of an unsigned integer type wide enough to
115             hold a pointer, if such a type exists, and if the system
116             does not define it.])
117          ac_type=])
118       test -z "$ac_type" && break
119     done])
120])
121
122AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
123[
124  AC_LANG_PROGRAM(
125    [[/* For now, do not test the preprocessor; as of 2007 there are too many
126         implementations with broken preprocessors.  Perhaps this can
127         be revisited in 2012.  In the meantime, code should not expect
128         #if to work with literals wider than 32 bits.  */
129      /* Test literals.  */
130      long long int ll = 9223372036854775807ll;
131      long long int nll = -9223372036854775807LL;
132      unsigned long long int ull = 18446744073709551615ULL;
133      /* Test constant expressions.   */
134      typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
135                     ? 1 : -1)];
136      typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
137                     ? 1 : -1)];
138      int i = 63;]],
139    [[/* Test availability of runtime routines for shift and division.  */
140      long long int llmax = 9223372036854775807ll;
141      unsigned long long int ullmax = 18446744073709551615ull;
142      return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
143              | (llmax / ll) | (llmax % ll)
144              | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
145              | (ullmax / ull) | (ullmax % ull));]])
146])
147
148