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