]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gnulib/import/m4/stdint.m4
Update gnulib
[thirdparty/binutils-gdb.git] / gnulib / import / m4 / stdint.m4
CommitLineData
dc6c21da
TT
1# stdint.m4 serial 61
2dnl Copyright (C) 2001-2022 Free Software Foundation, Inc.
f6ea5628
DJ
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
c0c3707f
CB
10AC_PREREQ([2.61])
11
770d76d7 12AC_DEFUN_ONCE([gl_STDINT_H],
f6ea5628 13[
f434ba03 14 AC_PREREQ([2.59])dnl
c0c3707f 15 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
f6ea5628 16
49e4877c 17 AC_REQUIRE([gl_LIMITS_H])
c0c3707f 18 AC_REQUIRE([gt_TYPE_WINT_T])
49e4877c 19
5df4cba6
SM
20 dnl For backward compatibility. Some packages may still be testing these
21 dnl macros.
22 AC_DEFINE([HAVE_LONG_LONG_INT], [1],
23 [Define to 1 if the system has the type 'long long int'.])
24 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
25 [Define to 1 if the system has the type 'unsigned long long int'.])
f6ea5628 26
770d76d7
PA
27 dnl Check for <wchar.h>, in the same way as gl_WCHAR_H does.
28 AC_CHECK_HEADERS_ONCE([wchar.h])
29 if test $ac_cv_header_wchar_h = yes; then
30 HAVE_WCHAR_H=1
31 else
32 HAVE_WCHAR_H=0
33 fi
34 AC_SUBST([HAVE_WCHAR_H])
35
f6ea5628 36 dnl Check for <inttypes.h>.
9c9d63b1 37 AC_CHECK_HEADERS_ONCE([inttypes.h])
f6ea5628
DJ
38 if test $ac_cv_header_inttypes_h = yes; then
39 HAVE_INTTYPES_H=1
40 else
41 HAVE_INTTYPES_H=0
42 fi
43 AC_SUBST([HAVE_INTTYPES_H])
44
45 dnl Check for <sys/types.h>.
9c9d63b1 46 AC_CHECK_HEADERS_ONCE([sys/types.h])
f6ea5628
DJ
47 if test $ac_cv_header_sys_types_h = yes; then
48 HAVE_SYS_TYPES_H=1
49 else
50 HAVE_SYS_TYPES_H=0
51 fi
52 AC_SUBST([HAVE_SYS_TYPES_H])
53
54 gl_CHECK_NEXT_HEADERS([stdint.h])
55 if test $ac_cv_header_stdint_h = yes; then
56 HAVE_STDINT_H=1
57 else
58 HAVE_STDINT_H=0
59 fi
60 AC_SUBST([HAVE_STDINT_H])
61
62 dnl Now see whether we need a substitute <stdint.h>.
63 if test $ac_cv_header_stdint_h = yes; then
64 AC_CACHE_CHECK([whether stdint.h conforms to C99],
65 [gl_cv_header_working_stdint_h],
66 [gl_cv_header_working_stdint_h=no
67 AC_COMPILE_IFELSE([
68 AC_LANG_PROGRAM([[
f6ea5628 69#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
49e4877c
PA
70#define __STDC_CONSTANT_MACROS 1
71#define __STDC_LIMIT_MACROS 1
f6ea5628
DJ
72#include <stdint.h>
73/* Dragonfly defines WCHAR_MIN, WCHAR_MAX only in <wchar.h>. */
74#if !(defined WCHAR_MIN && defined WCHAR_MAX)
75#error "WCHAR_MIN, WCHAR_MAX not defined in <stdint.h>"
76#endif
77]
78gl_STDINT_INCLUDES
79[
80#ifdef INT8_MAX
81int8_t a1 = INT8_MAX;
82int8_t a1min = INT8_MIN;
83#endif
84#ifdef INT16_MAX
85int16_t a2 = INT16_MAX;
86int16_t a2min = INT16_MIN;
87#endif
88#ifdef INT32_MAX
89int32_t a3 = INT32_MAX;
90int32_t a3min = INT32_MIN;
91#endif
92#ifdef INT64_MAX
93int64_t a4 = INT64_MAX;
94int64_t a4min = INT64_MIN;
95#endif
96#ifdef UINT8_MAX
97uint8_t b1 = UINT8_MAX;
98#else
99typedef int b1[(unsigned char) -1 != 255 ? 1 : -1];
100#endif
101#ifdef UINT16_MAX
102uint16_t b2 = UINT16_MAX;
103#endif
104#ifdef UINT32_MAX
105uint32_t b3 = UINT32_MAX;
106#endif
107#ifdef UINT64_MAX
108uint64_t b4 = UINT64_MAX;
109#endif
110int_least8_t c1 = INT8_C (0x7f);
111int_least8_t c1max = INT_LEAST8_MAX;
112int_least8_t c1min = INT_LEAST8_MIN;
113int_least16_t c2 = INT16_C (0x7fff);
114int_least16_t c2max = INT_LEAST16_MAX;
115int_least16_t c2min = INT_LEAST16_MIN;
116int_least32_t c3 = INT32_C (0x7fffffff);
117int_least32_t c3max = INT_LEAST32_MAX;
118int_least32_t c3min = INT_LEAST32_MIN;
119int_least64_t c4 = INT64_C (0x7fffffffffffffff);
120int_least64_t c4max = INT_LEAST64_MAX;
121int_least64_t c4min = INT_LEAST64_MIN;
122uint_least8_t d1 = UINT8_C (0xff);
123uint_least8_t d1max = UINT_LEAST8_MAX;
124uint_least16_t d2 = UINT16_C (0xffff);
125uint_least16_t d2max = UINT_LEAST16_MAX;
126uint_least32_t d3 = UINT32_C (0xffffffff);
127uint_least32_t d3max = UINT_LEAST32_MAX;
128uint_least64_t d4 = UINT64_C (0xffffffffffffffff);
129uint_least64_t d4max = UINT_LEAST64_MAX;
130int_fast8_t e1 = INT_FAST8_MAX;
131int_fast8_t e1min = INT_FAST8_MIN;
132int_fast16_t e2 = INT_FAST16_MAX;
133int_fast16_t e2min = INT_FAST16_MIN;
134int_fast32_t e3 = INT_FAST32_MAX;
135int_fast32_t e3min = INT_FAST32_MIN;
136int_fast64_t e4 = INT_FAST64_MAX;
137int_fast64_t e4min = INT_FAST64_MIN;
138uint_fast8_t f1 = UINT_FAST8_MAX;
139uint_fast16_t f2 = UINT_FAST16_MAX;
140uint_fast32_t f3 = UINT_FAST32_MAX;
141uint_fast64_t f4 = UINT_FAST64_MAX;
142#ifdef INTPTR_MAX
143intptr_t g = INTPTR_MAX;
144intptr_t gmin = INTPTR_MIN;
145#endif
146#ifdef UINTPTR_MAX
147uintptr_t h = UINTPTR_MAX;
148#endif
149intmax_t i = INTMAX_MAX;
150uintmax_t j = UINTMAX_MAX;
151
4c62b19f
PA
152/* Check that SIZE_MAX has the correct type, if possible. */
153#if 201112 <= __STDC_VERSION__
154int k = _Generic (SIZE_MAX, size_t: 0);
9c9d63b1 155#elif (2 <= __GNUC__ || 4 <= __clang_major__ || defined __IBM__TYPEOF__ \
4c62b19f
PA
156 || (0x5110 <= __SUNPRO_C && !__STDC__))
157extern size_t k;
158extern __typeof__ (SIZE_MAX) k;
159#endif
160
f6ea5628
DJ
161#include <limits.h> /* for CHAR_BIT */
162#define TYPE_MINIMUM(t) \
770d76d7 163 ((t) ((t) 0 < (t) -1 ? (t) 0 : ~ TYPE_MAXIMUM (t)))
f6ea5628 164#define TYPE_MAXIMUM(t) \
770d76d7
PA
165 ((t) ((t) 0 < (t) -1 \
166 ? (t) -1 \
167 : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
f6ea5628
DJ
168struct s {
169 int check_PTRDIFF:
170 PTRDIFF_MIN == TYPE_MINIMUM (ptrdiff_t)
171 && PTRDIFF_MAX == TYPE_MAXIMUM (ptrdiff_t)
172 ? 1 : -1;
dc6c21da 173 /* Detect bug in FreeBSD 6.0/ia64 and FreeBSD 13.0/arm64. */
f6ea5628
DJ
174 int check_SIG_ATOMIC:
175 SIG_ATOMIC_MIN == TYPE_MINIMUM (sig_atomic_t)
176 && SIG_ATOMIC_MAX == TYPE_MAXIMUM (sig_atomic_t)
177 ? 1 : -1;
178 int check_SIZE: SIZE_MAX == TYPE_MAXIMUM (size_t) ? 1 : -1;
179 int check_WCHAR:
180 WCHAR_MIN == TYPE_MINIMUM (wchar_t)
181 && WCHAR_MAX == TYPE_MAXIMUM (wchar_t)
182 ? 1 : -1;
183 /* Detect bug in mingw. */
184 int check_WINT:
185 WINT_MIN == TYPE_MINIMUM (wint_t)
186 && WINT_MAX == TYPE_MAXIMUM (wint_t)
187 ? 1 : -1;
188
189 /* Detect bugs in glibc 2.4 and Solaris 10 stdint.h, among others. */
190 int check_UINT8_C:
191 (-1 < UINT8_C (0)) == (-1 < (uint_least8_t) 0) ? 1 : -1;
192 int check_UINT16_C:
193 (-1 < UINT16_C (0)) == (-1 < (uint_least16_t) 0) ? 1 : -1;
194
195 /* Detect bugs in OpenBSD 3.9 stdint.h. */
196#ifdef UINT8_MAX
197 int check_uint8: (uint8_t) -1 == UINT8_MAX ? 1 : -1;
198#endif
199#ifdef UINT16_MAX
200 int check_uint16: (uint16_t) -1 == UINT16_MAX ? 1 : -1;
201#endif
202#ifdef UINT32_MAX
203 int check_uint32: (uint32_t) -1 == UINT32_MAX ? 1 : -1;
204#endif
205#ifdef UINT64_MAX
206 int check_uint64: (uint64_t) -1 == UINT64_MAX ? 1 : -1;
207#endif
208 int check_uint_least8: (uint_least8_t) -1 == UINT_LEAST8_MAX ? 1 : -1;
209 int check_uint_least16: (uint_least16_t) -1 == UINT_LEAST16_MAX ? 1 : -1;
210 int check_uint_least32: (uint_least32_t) -1 == UINT_LEAST32_MAX ? 1 : -1;
211 int check_uint_least64: (uint_least64_t) -1 == UINT_LEAST64_MAX ? 1 : -1;
212 int check_uint_fast8: (uint_fast8_t) -1 == UINT_FAST8_MAX ? 1 : -1;
213 int check_uint_fast16: (uint_fast16_t) -1 == UINT_FAST16_MAX ? 1 : -1;
214 int check_uint_fast32: (uint_fast32_t) -1 == UINT_FAST32_MAX ? 1 : -1;
215 int check_uint_fast64: (uint_fast64_t) -1 == UINT_FAST64_MAX ? 1 : -1;
216 int check_uintptr: (uintptr_t) -1 == UINTPTR_MAX ? 1 : -1;
217 int check_uintmax: (uintmax_t) -1 == UINTMAX_MAX ? 1 : -1;
218 int check_size: (size_t) -1 == SIZE_MAX ? 1 : -1;
219};
220 ]])],
f434ba03
PA
221 [dnl Determine whether the various *_MIN, *_MAX macros are usable
222 dnl in preprocessor expression. We could do it by compiling a test
223 dnl program for each of these macros. It is faster to run a program
224 dnl that inspects the macro expansion.
225 dnl This detects a bug on HP-UX 11.23/ia64.
226 AC_RUN_IFELSE([
227 AC_LANG_PROGRAM([[
f434ba03 228#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
49e4877c
PA
229#define __STDC_CONSTANT_MACROS 1
230#define __STDC_LIMIT_MACROS 1
f434ba03
PA
231#include <stdint.h>
232]
233gl_STDINT_INCLUDES
234[
235#include <stdio.h>
236#include <string.h>
237#define MVAL(macro) MVAL1(macro)
238#define MVAL1(expression) #expression
239static const char *macro_values[] =
240 {
241#ifdef INT8_MAX
242 MVAL (INT8_MAX),
243#endif
244#ifdef INT16_MAX
245 MVAL (INT16_MAX),
246#endif
247#ifdef INT32_MAX
248 MVAL (INT32_MAX),
249#endif
250#ifdef INT64_MAX
251 MVAL (INT64_MAX),
252#endif
253#ifdef UINT8_MAX
254 MVAL (UINT8_MAX),
255#endif
256#ifdef UINT16_MAX
257 MVAL (UINT16_MAX),
258#endif
259#ifdef UINT32_MAX
260 MVAL (UINT32_MAX),
261#endif
262#ifdef UINT64_MAX
263 MVAL (UINT64_MAX),
264#endif
265 NULL
266 };
267]], [[
268 const char **mv;
269 for (mv = macro_values; *mv != NULL; mv++)
270 {
271 const char *value = *mv;
272 /* Test whether it looks like a cast expression. */
273 if (strncmp (value, "((unsigned int)"/*)*/, 15) == 0
274 || strncmp (value, "((unsigned short)"/*)*/, 17) == 0
275 || strncmp (value, "((unsigned char)"/*)*/, 16) == 0
276 || strncmp (value, "((int)"/*)*/, 6) == 0
277 || strncmp (value, "((signed short)"/*)*/, 15) == 0
278 || strncmp (value, "((signed char)"/*)*/, 14) == 0)
770d76d7 279 return mv - macro_values + 1;
f434ba03
PA
280 }
281 return 0;
282]])],
283 [gl_cv_header_working_stdint_h=yes],
284 [],
c0c3707f
CB
285 [case "$host_os" in
286 # Guess yes on native Windows.
287 mingw*) gl_cv_header_working_stdint_h="guessing yes" ;;
288 # In general, assume it works.
289 *) gl_cv_header_working_stdint_h="guessing yes" ;;
290 esac
f434ba03
PA
291 ])
292 ])
293 ])
f6ea5628 294 fi
49e4877c
PA
295
296 HAVE_C99_STDINT_H=0
297 HAVE_SYS_BITYPES_H=0
298 HAVE_SYS_INTTYPES_H=0
dc6c21da 299 GL_GENERATE_STDINT_H=true
c0c3707f
CB
300 case "$gl_cv_header_working_stdint_h" in
301 *yes)
302 HAVE_C99_STDINT_H=1
303 dnl Now see whether the system <stdint.h> works without
304 dnl __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS defined.
9c9d63b1
PM
305 dnl If not, there would be problems when stdint.h is included from C++.
306 AC_CACHE_CHECK([whether stdint.h works without ISO C predefines],
307 [gl_cv_header_stdint_without_STDC_macros],
308 [gl_cv_header_stdint_without_STDC_macros=no
c0c3707f
CB
309 AC_COMPILE_IFELSE([
310 AC_LANG_PROGRAM([[
49e4877c
PA
311#define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1 /* work if build isn't clean */
312#include <stdint.h>
313]
314gl_STDINT_INCLUDES
315[
316intmax_t im = INTMAX_MAX;
317int32_t i32 = INT32_C (0x7fffffff);
c0c3707f 318 ]])],
9c9d63b1
PM
319 [gl_cv_header_stdint_without_STDC_macros=yes])
320 ])
49e4877c 321
9c9d63b1 322 if test $gl_cv_header_stdint_without_STDC_macros = no; then
c0c3707f 323 AC_DEFINE([__STDC_CONSTANT_MACROS], [1],
9c9d63b1 324 [Define to 1 if the system <stdint.h> predates C++11.])
c0c3707f 325 AC_DEFINE([__STDC_LIMIT_MACROS], [1],
9c9d63b1 326 [Define to 1 if the system <stdint.h> predates C++11.])
c0c3707f
CB
327 fi
328 AC_CACHE_CHECK([whether stdint.h has UINTMAX_WIDTH etc.],
329 [gl_cv_header_stdint_width],
330 [gl_cv_header_stdint_width=no
331 AC_COMPILE_IFELSE(
332 [AC_LANG_PROGRAM([[
333 /* Work if build is not clean. */
334 #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H 1
335 #ifndef __STDC_WANT_IEC_60559_BFP_EXT__
336 #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
337 #endif
338 #include <stdint.h>
339 ]gl_STDINT_INCLUDES[
340 int iw = UINTMAX_WIDTH;
341 ]])],
342 [gl_cv_header_stdint_width=yes])])
343 if test "$gl_cv_header_stdint_width" = yes; then
dc6c21da 344 GL_GENERATE_STDINT_H=false
c0c3707f
CB
345 fi
346 ;;
347 *)
348 dnl Check for <sys/inttypes.h>, and for
349 dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
350 AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
351 if test $ac_cv_header_sys_inttypes_h = yes; then
352 HAVE_SYS_INTTYPES_H=1
353 fi
354 if test $ac_cv_header_sys_bitypes_h = yes; then
355 HAVE_SYS_BITYPES_H=1
356 fi
357 gl_STDINT_TYPE_PROPERTIES
358 ;;
359 esac
49e4877c 360
c0c3707f
CB
361 dnl The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH.
362 gl_REPLACE_LIMITS_H
49e4877c
PA
363
364 AC_SUBST([HAVE_C99_STDINT_H])
365 AC_SUBST([HAVE_SYS_BITYPES_H])
366 AC_SUBST([HAVE_SYS_INTTYPES_H])
f6ea5628
DJ
367])
368
369dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
370dnl Determine the size of each of the given types in bits.
371AC_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.
f434ba03 377 m4_foreach_w([gltype], [$1],
770d76d7 378 [AH_TEMPLATE([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
f6ea5628
DJ
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
f434ba03 402 m4_foreach_w([gltype], [$1],
770d76d7 403 [AC_SUBST([BITSIZEOF_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
f6ea5628
DJ
404])
405
406dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES)
407dnl Determine the signedness of each of the given types.
408dnl Define HAVE_SIGNED_TYPE if type is signed.
409AC_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.
f434ba03 415 m4_foreach_w([gltype], [$1],
770d76d7 416 [AH_TEMPLATE([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
f6ea5628
DJ
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
f434ba03 429 AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], [1])
f6ea5628
DJ
430 eval HAVE_SIGNED_${GLTYPE}=1
431 else
432 eval HAVE_SIGNED_${GLTYPE}=0
433 fi
434 done
f434ba03 435 m4_foreach_w([gltype], [$1],
770d76d7 436 [AC_SUBST([HAVE_SIGNED_]m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
f6ea5628
DJ
437])
438
439dnl gl_INTEGER_TYPE_SUFFIX(TYPES, INCLUDES)
440dnl Determine the suffix to use for integer constants of the given types.
441dnl Define t_SUFFIX for each such type.
442AC_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.
f434ba03 448 m4_foreach_w([gltype], [$1],
770d76d7 449 [AH_TEMPLATE(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX],
f6ea5628
DJ
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';;
f434ba03
PA
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';;
f6ea5628
DJ
471 ui64)gltype1='unsigned __int64';;
472 esac
473 AC_COMPILE_IFELSE(
f434ba03 474 [AC_LANG_PROGRAM([$2[
f6ea5628 475 extern $gltype foo;
f434ba03 476 extern $gltype1 foo;]])],
f6ea5628
DJ
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
f434ba03 485 AC_DEFINE_UNQUOTED([${GLTYPE}_SUFFIX], [$result])
f6ea5628 486 done
f434ba03 487 m4_foreach_w([gltype], [$1],
770d76d7 488 [AC_SUBST(m4_translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_])[_SUFFIX])])
f6ea5628
DJ
489])
490
491dnl gl_STDINT_INCLUDES
492AC_DEFUN([gl_STDINT_INCLUDES],
493[[
f6ea5628
DJ
494 #include <stddef.h>
495 #include <signal.h>
496 #if HAVE_WCHAR_H
f6ea5628
DJ
497 # include <wchar.h>
498 #endif
499]])
500
501dnl gl_STDINT_TYPE_PROPERTIES
502dnl Compute HAVE_SIGNED_t, BITSIZEOF_t and t_SUFFIX, for all the types t
503dnl of interest to stdint.in.h.
504AC_DEFUN([gl_STDINT_TYPE_PROPERTIES],
505[
f434ba03
PA
506 AC_REQUIRE([gl_MULTIARCH])
507 if test $APPLE_UNIVERSAL_BUILD = 0; then
508 gl_STDINT_BITSIZEOF([ptrdiff_t size_t],
509 [gl_STDINT_INCLUDES])
510 fi
511 gl_STDINT_BITSIZEOF([sig_atomic_t wchar_t wint_t],
f6ea5628
DJ
512 [gl_STDINT_INCLUDES])
513 gl_CHECK_TYPES_SIGNED([sig_atomic_t wchar_t wint_t],
514 [gl_STDINT_INCLUDES])
515 gl_cv_type_ptrdiff_t_signed=yes
516 gl_cv_type_size_t_signed=no
f434ba03
PA
517 if test $APPLE_UNIVERSAL_BUILD = 0; then
518 gl_INTEGER_TYPE_SUFFIX([ptrdiff_t size_t],
519 [gl_STDINT_INCLUDES])
520 fi
521 gl_INTEGER_TYPE_SUFFIX([sig_atomic_t wchar_t wint_t],
f6ea5628 522 [gl_STDINT_INCLUDES])
770d76d7
PA
523
524 dnl If wint_t is smaller than 'int', it cannot satisfy the ISO C 99
525 dnl requirement that wint_t is "unchanged by default argument promotions".
526 dnl In this case gnulib's <wchar.h> and <wctype.h> override wint_t.
527 dnl Set the variable BITSIZEOF_WINT_T accordingly.
dc6c21da 528 if test $GNULIBHEADERS_OVERRIDE_WINT_T = 1; then
770d76d7
PA
529 BITSIZEOF_WINT_T=32
530 fi
f6ea5628 531])