Imported Upstream version 4.13
[platform/upstream/libtasn1.git] / gl / m4 / stdint.m4
1 # stdint.m4 serial 50
2 dnl Copyright (C) 2001-2017 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 and Bruno Haible.
8 dnl Test whether <stdint.h> is supported or must be substituted.
9
10 AC_DEFUN_ONCE([gl_STDINT_H],
11 [
12   AC_PREREQ([2.59])dnl
13
14   AC_REQUIRE([gl_LIMITS_H])
15   AC_REQUIRE([gt_TYPE_WINT_T])
16
17   dnl Check for long long int and unsigned long long int.
18   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
19   if test $ac_cv_type_long_long_int = yes; then
20     HAVE_LONG_LONG_INT=1
21   else
22     HAVE_LONG_LONG_INT=0
23   fi
24   AC_SUBST([HAVE_LONG_LONG_INT])
25   AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
26   if test $ac_cv_type_unsigned_long_long_int = yes; then
27     HAVE_UNSIGNED_LONG_LONG_INT=1
28   else
29     HAVE_UNSIGNED_LONG_LONG_INT=0
30   fi
31   AC_SUBST([HAVE_UNSIGNED_LONG_LONG_INT])
32
33   dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
34   AC_CHECK_HEADERS_ONCE([wchar.h])
35   if test $ac_cv_header_wchar_h = yes; then
36     HAVE_WCHAR_H=1
37   else
38     HAVE_WCHAR_H=0
39   fi
40   AC_SUBST([HAVE_WCHAR_H])
41
42   dnl Check for <inttypes.h>.
43   dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_inttypes_h.
44   if test $ac_cv_header_inttypes_h = yes; then
45     HAVE_INTTYPES_H=1
46   else
47     HAVE_INTTYPES_H=0
48   fi
49   AC_SUBST([HAVE_INTTYPES_H])
50
51   dnl Check for <sys/types.h>.
52   dnl AC_INCLUDES_DEFAULT defines $ac_cv_header_sys_types_h.
53   if test $ac_cv_header_sys_types_h = yes; then
54     HAVE_SYS_TYPES_H=1
55   else
56     HAVE_SYS_TYPES_H=0
57   fi
58   AC_SUBST([HAVE_SYS_TYPES_H])
59
60   gl_CHECK_NEXT_HEADERS([stdint.h])
61   if test $ac_cv_header_stdint_h = yes; then
62     HAVE_STDINT_H=1
63   else
64     HAVE_STDINT_H=0
65   fi
66   AC_SUBST([HAVE_STDINT_H])
67
68   dnl Now see whether we need a substitute <stdint.h>.
69   if test $ac_cv_header_stdint_h = yes; then
70     AC_CACHE_CHECK([whether stdint.h conforms to C99],
71       [gl_cv_header_working_stdint_h],
72       [gl_cv_header_working_stdint_h=no
73        AC_COMPILE_IFELSE([
74          AC_LANG_PROGRAM([[
75 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
76 #define __STDC_CONSTANT_MACROS 1
77 #define __STDC_LIMIT_MACROS 1
78 #include <stdint.h>
79 /* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>.  */
80 #if !(defined WCHAR_MIN && defined WCHAR_MAX)
81 #error "WCHAR_MIN, WCHAR_MAX not defined in <stdint.h>"
82 #endif
83 ]
84 gl_STDINT_INCLUDES
85 [
86 #ifdef INT8_MAX
87 int8_t a1 = INT8_MAX;
88 int8_t a1min = INT8_MIN;
89 #endif
90 #ifdef INT16_MAX
91 int16_t a2 = INT16_MAX;
92 int16_t a2min = INT16_MIN;
93 #endif
94 #ifdef INT32_MAX
95 int32_t a3 = INT32_MAX;
96 int32_t a3min = INT32_MIN;
97 #endif
98 #ifdef INT64_MAX
99 int64_t a4 = INT64_MAX;
100 int64_t a4min = INT64_MIN;
101 #endif
102 #ifdef UINT8_MAX
103 uint8_t b1 = UINT8_MAX;
104 #else
105 typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
106 #endif
107 #ifdef UINT16_MAX
108 uint16_t b2 = UINT16_MAX;
109 #endif
110 #ifdef UINT32_MAX
111 uint32_t b3 = UINT32_MAX;
112 #endif
113 #ifdef UINT64_MAX
114 uint64_t b4 = UINT64_MAX;
115 #endif
116 int_least8_t c1 = INT8_C (0x7f);
117 int_least8_t c1max = INT_LEAST8_MAX;
118 int_least8_t c1min = INT_LEAST8_MIN;
119 int_least16_t c2 = INT16_C (0x7fff);
120 int_least16_t c2max = INT_LEAST16_MAX;
121 int_least16_t c2min = INT_LEAST16_MIN;
122 int_least32_t c3 = INT32_C (0x7fffffff);
123 int_least32_t c3max = INT_LEAST32_MAX;
124 int_least32_t c3min = INT_LEAST32_MIN;
125 int_least64_t c4 = INT64_C (0x7fffffffffffffff);
126 int_least64_t c4max = INT_LEAST64_MAX;
127 int_least64_t c4min = INT_LEAST64_MIN;
128 uint_least8_t d1 = UINT8_C (0xff);
129 uint_least8_t d1max = UINT_LEAST8_MAX;
130 uint_least16_t d2 = UINT16_C (0xffff);
131 uint_least16_t d2max = UINT_LEAST16_MAX;
132 uint_least32_t d3 = UINT32_C (0xffffffff);
133 uint_least32_t d3max = UINT_LEAST32_MAX;
134 uint_least64_t d4 = UINT64_C (0xffffffffffffffff);
135 uint_least64_t d4max = UINT_LEAST64_MAX;
136 int_fast8_t e1 = INT_FAST8_MAX;
137 int_fast8_t e1min = INT_FAST8_MIN;
138 int_fast16_t e2 = INT_FAST16_MAX;
139 int_fast16_t e2min = INT_FAST16_MIN;
140 int_fast32_t e3 = INT_FAST32_MAX;
141 int_fast32_t e3min = INT_FAST32_MIN;
142 int_fast64_t e4 = INT_FAST64_MAX;
143 int_fast64_t e4min = INT_FAST64_MIN;
144 uint_fast8_t f1 = UINT_FAST8_MAX;
145 uint_fast16_t f2 = UINT_FAST16_MAX;
146 uint_fast32_t f3 = UINT_FAST32_MAX;
147 uint_fast64_t f4 = UINT_FAST64_MAX;
148 #ifdef INTPTR_MAX
149 intptr_t g = INTPTR_MAX;
150 intptr_t gmin = INTPTR_MIN;
151 #endif
152 #ifdef UINTPTR_MAX
153 uintptr_t h = UINTPTR_MAX;
154 #endif
155 intmax_t i = INTMAX_MAX;
156 uintmax_t j = UINTMAX_MAX;
157
158 /* Check that SIZE_MAX has the correct type, if possible.  */
159 #if 201112 <= __STDC_VERSION__
160 int k = _Generic (SIZE_MAX, size_t: 0);
161 #elif (2 <= __GNUC__ || defined __IBM__TYPEOF__ \
162        || (0x5110 <= __SUNPRO_C && !__STDC__))
163 extern size_t k;
164 extern __typeof__ (SIZE_MAX) k;
165 #endif
166
167 #include <limits.h> /* for CHAR_BIT */
168 #define TYPE_MINIMUM(t) \
169   ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
170 #define TYPE_MAXIMUM(t) \
171   ((t) ((t) 0 < (t) -1 \
172         ? (t) -1 \
173         : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
174 struct s {
175   int check_PTRDIFF:
176       PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
177       && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
178       ? 1 : -1;
179   /* Detect bug in FreeBSD 6.0 / ia64.  */
180   int check_SIG_ATOMIC:
181       SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
182       && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
183       ? 1 : -1;
184   int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1;
185   int check_WCHAR:
186       WCHAR_MIN == TYPE_MINIMUM (wchar_t)
187       && WCHAR_MAX == TYPE_MAXIMUM (wchar_t)
188       ? 1 : -1;
189   /* Detect bug in mingw.  */
190   int check_WINT:
191       WINT_MIN == TYPE_MINIMUM (wint_t)
192       && WINT_MAX == TYPE_MAXIMUM (wint_t)
193       ? 1 : -1;
194
195   /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others.  */
196   int check_UINT8_C:
197         (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
198   int check_UINT16_C:
199         (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;
200
201   /* Detect bugs in OpenBSD 3.9 stdint.h.  */
202 #ifdef UINT8_MAX
203   int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1;
204 #endif
205 #ifdef UINT16_MAX
206   int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1;
207 #endif
208 #ifdef UINT32_MAX
209   int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1;
210 #endif
211 #ifdef UINT64_MAX
212   int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1;
213 #endif
214   int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1;
215   int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1;
216   int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1;
217   int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1;
218   int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1;
219   int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1;
220   int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1;
221   int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1;
222   int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1;
223   int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1;
224   int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
225 };
226          ]])],
227          [dnl Determine whether the various *_MIN, *_MAX macros are usable
228           dnl in preprocessor expression. We could do it by compiling a test
229           dnl program for each of these macros. It is faster to run a program
230           dnl that inspects the macro expansion.
231           dnl This detects a bug on HP-UX 11.23/ia64.
232           AC_RUN_IFELSE([
233             AC_LANG_PROGRAM([[
234 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
235 #define __STDC_CONSTANT_MACROS 1
236 #define __STDC_LIMIT_MACROS 1
237 #include <stdint.h>
238 ]
239 gl_STDINT_INCLUDES
240 [
241 #include <stdio.h>
242 #include <string.h>
243 #define MVAL(macro) MVAL1(macro)
244 #define MVAL1(expression) #expression
245 static const char *macro_values[] =
246   {
247 #ifdef INT8_MAX
248     MVAL (INT8_MAX),
249 #endif
250 #ifdef INT16_MAX
251     MVAL (INT16_MAX),
252 #endif
253 #ifdef INT32_MAX
254     MVAL (INT32_MAX),
255 #endif
256 #ifdef INT64_MAX
257     MVAL (INT64_MAX),
258 #endif
259 #ifdef UINT8_MAX
260     MVAL (UINT8_MAX),
261 #endif
262 #ifdef UINT16_MAX
263     MVAL (UINT16_MAX),
264 #endif
265 #ifdef UINT32_MAX
266     MVAL (UINT32_MAX),
267 #endif
268 #ifdef UINT64_MAX
269     MVAL (UINT64_MAX),
270 #endif
271     NULL
272   };
273 ]], [[
274   const char **mv;
275   for (mv = macro_values; *mv != NULL; mv++)
276     {
277       const char *value = *mv;
278       /* Test whether it looks like a cast expression.  */
279       if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0
280           || strncmp (value, "((unsigned short)"/*)*/, 17) == 0
281           || strncmp (value, "((unsigned char)"/*)*/, 16) == 0
282           || strncmp (value, "((int)"/*)*/, 6) == 0
283           || strncmp (value, "((signed short)"/*)*/, 15) == 0
284           || strncmp (value, "((signed char)"/*)*/, 14) == 0)
285         return mv - macro_values + 1;
286     }
287   return 0;
288 ]])],
289               [gl_cv_header_working_stdint_h=yes],
290               [],
291               [dnl When cross-compiling, assume it works.
292                gl_cv_header_working_stdint_h=yes
293               ])
294          ])
295       ])
296   fi
297
298   HAVE_C99_STDINT_H=0
299   HAVE_SYS_BITYPES_H=0
300   HAVE_SYS_INTTYPES_H=0
301   STDINT_H=stdint.h
302   if test "$gl_cv_header_working_stdint_h" = yes; then
303     HAVE_C99_STDINT_H=1
304     dnl Now see whether the system <stdint.h> works without
305     dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
306     AC_CACHE_CHECK([whether stdint.h predates C++11],
307       [gl_cv_header_stdint_predates_cxx11_h],
308       [gl_cv_header_stdint_predates_cxx11_h=yes
309        AC_COMPILE_IFELSE([
310          AC_LANG_PROGRAM([[
311 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
312 #include <stdint.h>
313 ]
314 gl_STDINT_INCLUDES
315 [
316 intmax_t im = INTMAX_MAX;
317 int32_t i32 = INT32_C (0x7fffffff);
318          ]])],
319          [gl_cv_header_stdint_predates_cxx11_h=no])])
320
321     if test "$gl_cv_header_stdint_predates_cxx11_h" = yes; then
322       AC_DEFINE([__STDC_CONSTANT_MACROS], [1],
323                 [Define to 1 if the system <stdint.h> predates C++11.])
324       AC_DEFINE([__STDC_LIMIT_MACROS], [1],
325                 [Define to 1 if the system <stdint.h> predates C++11.])
326     fi
327     AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.],
328       [gl_cv_header_stdint_width],
329       [gl_cv_header_stdint_width=no
330        AC_COMPILE_IFELSE(
331          [AC_LANG_PROGRAM([[
332             /* Work if build is not clean.  */
333             #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1
334             #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
335              #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
336             #endif
337             #include <stdint.h>
338             ]gl_STDINT_INCLUDES[
339             int iw = UINTMAX_WIDTH;
340             ]])],
341          [gl_cv_header_stdint_width=yes])])
342     if test "$gl_cv_header_stdint_width" = yes; then
343       STDINT_H=
344     fi
345   else
346     dnl Check for <sys/inttypes.h>, and for
347     dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
348     AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
349     if test $ac_cv_header_sys_inttypes_h = yes; then
350       HAVE_SYS_INTTYPES_H=1
351     fi
352     if test $ac_cv_header_sys_bitypes_h = yes; then
353       HAVE_SYS_BITYPES_H=1
354     fi
355     gl_STDINT_TYPE_PROPERTIES
356   fi
357
358   dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH.
359   LIMITS_H=limits.h
360   AM_CONDITIONAL([GL_GENERATE_LIMITS_H], [test -n "$LIMITS_H"])
361
362   AC_SUBST([HAVE_C99_STDINT_H])
363   AC_SUBST([HAVE_SYS_BITYPES_H])
364   AC_SUBST([HAVE_SYS_INTTYPES_H])
365   AC_SUBST([STDINT_H])
366   AM_CONDITIONAL([GL_GENERATE_STDINT_H], [test -n "$STDINT_H"])
367 ])
368
369 dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
370 dnl Determine the size of each of the given types in bits.
371 AC_DEFUN([gl_STDINT_BITSIZEOF],
372 [
373   dnl Use a shell loop, to avoid bloating configure, and
374   dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
375   dnl   config.h.in,
376   dnl - extra AC_SUBST calls, so that the right substitutions are made.
377   m4_foreach_w([gltype], [$1],
378     [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
379        [Define to the number of bits in type ']gltype['.])])
380   for gltype in $1 ; do
381     AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}],
382       [AC_COMPUTE_INT([result], [sizeof ($gltype) * CHAR_BIT],
383          [$2
384 #include <limits.h>], [result=unknown])
385        eval gl_cv_bitsizeof_${gltype}=\$result
386       ])
387     eval result=\$gl_cv_bitsizeof_${gltype}
388     if test $result = unknown; then
389       dnl Use a nonempty default, because some compilers, such as IRIX 5 cc,
390       dnl do a syntax check even on unused #if conditions and give an error
391       dnl on valid C code like this:
392       dnl   #if 0
393       dnl   # if  > 32
394       dnl   # endif
395       dnl   #endif
396       result=0
397     fi
398     GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
399     AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
400     eval BITSIZEOF_${GLTYPE}=\$result
401   done
402   m4_foreach_w([gltype], [$1],
403     [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
404 ])
405
406 dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES)
407 dnl Determine the signedness of each of the given types.
408 dnl Define HAVE_SIGNED_TYPE if type is signed.
409 AC_DEFUN([gl_CHECK_TYPES_SIGNED],
410 [
411   dnl Use a shell loop, to avoid bloating configure, and
412   dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
413   dnl   config.h.in,
414   dnl - extra AC_SUBST calls, so that the right substitutions are made.
415   m4_foreach_w([gltype], [$1],
416     [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
417        [Define to 1 if ']gltype[' is a signed integer type.])])
418   for gltype in $1 ; do
419     AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed],
420       [AC_COMPILE_IFELSE(
421          [AC_LANG_PROGRAM([$2[
422             int verify[2 * (($gltype) -1 < ($gltype) 0) - 1];]])],
423          result=yes, result=no)
424        eval gl_cv_type_${gltype}_signed=\$result
425       ])
426     eval result=\$gl_cv_type_${gltype}_signed
427     GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
428     if test "$result" = yes; then
429       AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1])
430       eval HAVE_SIGNED_${GLTYPE}=1
431     else
432       eval HAVE_SIGNED_${GLTYPE}=0
433     fi
434   done
435   m4_foreach_w([gltype], [$1],
436     [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
437 ])
438
439 dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES)
440 dnl Determine the suffix to use for integer constants of the given types.
441 dnl Define t_SUFFIX for each such type.
442 AC_DEFUN([gl_INTEGER_TYPE_SUFFIX],
443 [
444   dnl Use a shell loop, to avoid bloating configure, and
445   dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
446   dnl   config.h.in,
447   dnl - extra AC_SUBST calls, so that the right substitutions are made.
448   m4_foreach_w([gltype], [$1],
449     [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
450        [Define to l, ll, u, ul, ull, etc., as suitable for
451         constants of type ']gltype['.])])
452   for gltype in $1 ; do
453     AC_CACHE_CHECK([for $gltype integer literal suffix],
454       [gl_cv_type_${gltype}_suffix],
455       [eval gl_cv_type_${gltype}_suffix=no
456        eval result=\$gl_cv_type_${gltype}_signed
457        if test "$result" = yes; then
458          glsufu=
459        else
460          glsufu=u
461        fi
462        for glsuf in "$glsufu" ${glsufu}l ${glsufu}ll ${glsufu}i64; do
463          case $glsuf in
464            '')  gltype1='int';;
465            l)   gltype1='long int';;
466            ll)  gltype1='long long int';;
467            i64) gltype1='__int64';;
468            u)   gltype1='unsigned int';;
469            ul)  gltype1='unsigned long int';;
470            ull) gltype1='unsigned long long int';;
471            ui64)gltype1='unsigned __int64';;
472          esac
473          AC_COMPILE_IFELSE(
474            [AC_LANG_PROGRAM([$2[
475               extern $gltype foo;
476               extern $gltype1 foo;]])],
477            [eval gl_cv_type_${gltype}_suffix=\$glsuf])
478          eval result=\$gl_cv_type_${gltype}_suffix
479          test "$result" != no && break
480        done])
481     GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
482     eval result=\$gl_cv_type_${gltype}_suffix
483     test "$result" = no && result=
484     eval ${GLTYPE}_SUFFIX=\$result
485     AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result])
486   done
487   m4_foreach_w([gltype], [$1],
488     [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
489 ])
490
491 dnl gl_STDINT_INCLUDES
492 AC_DEFUN([gl_STDINT_INCLUDES],
493 [[
494   /* BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
495      included before <wchar.h>.  */
496   #include <stddef.h>
497   #include <signal.h>
498   #if HAVE_WCHAR_H
499   # include <stdio.h>
500   # include <time.h>
501   # include <wchar.h>
502   #endif
503 ]])
504
505 dnl gl_STDINT_TYPE_PROPERTIES
506 dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t
507 dnl of interest to stdint.in.h.
508 AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
509 [
510   AC_REQUIRE([gl_MULTIARCH])
511   if test $APPLE_UNIVERSAL_BUILD = 0; then
512     gl_STDINT_BITSIZEOF([ptrdiff_t size_t],
513       [gl_STDINT_INCLUDES])
514   fi
515   gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t],
516     [gl_STDINT_INCLUDES])
517   gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t],
518     [gl_STDINT_INCLUDES])
519   gl_cv_type_ptrdiff_t_signed=yes
520   gl_cv_type_size_t_signed=no
521   if test $APPLE_UNIVERSAL_BUILD = 0; then
522     gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t],
523       [gl_STDINT_INCLUDES])
524   fi
525   gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t],
526     [gl_STDINT_INCLUDES])
527
528   dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99
529   dnl requirement that wint_t is "unchanged by default argument promotions".
530   dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t.
531   dnl Set the variable BITSIZEOF_WINT_T accordingly.
532   if test $GNULIB_OVERRIDES_WINT_T = 1; then
533     BITSIZEOF_WINT_T=32
534   fi
535 ])
536
537 dnl Autoconf >= 2.61 has AC_COMPUTE_INT built-in.
538 dnl Remove this when we can assume autoconf >= 2.61.
539 m4_ifdef([AC_COMPUTE_INT], [], [
540   AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
541 ])