2 dnl Copyright (C) 2001-2002, 2004-2006 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.
8 dnl Test whether <stdint.h> is supported or must be substituted.
10 AC_DEFUN([gl_STDINT_H],
12 dnl Check for <stdint.h> that doesn't clash with <sys/types.h>.
14 if test $gl_cv_header_stdint_h = yes; then
15 ac_cv_header_stdint_h=yes; dnl Hack for gl_FULL_HEADER_PATH.
16 gl_FULL_HEADER_PATH([stdint.h])
17 FULL_PATH_STDINT_H='<'$gl_cv_full_path_stdint_h'>'
18 AC_SUBST([FULL_PATH_STDINT_H])
23 AC_SUBST([HAVE_STDINT_H])
25 dnl Check for <inttypes.h> that doesn't clash with <sys/types.h>.
27 if test $gl_cv_header_inttypes_h = yes; then
28 ac_cv_header_inttypes_h=yes; dnl Hack for gl_FULL_HEADER_PATH.
29 gl_FULL_HEADER_PATH([inttypes.h])
30 FULL_PATH_INTTYPES_H='<'$gl_cv_full_path_inttypes_h'>'
31 AC_SUBST([FULL_PATH_INTTYPES_H])
36 AC_SUBST([HAVE_INTTYPES_H])
38 dnl Check for <sys/inttypes.h>.
39 AC_CHECK_HEADERS([sys/inttypes.h])
40 if test $ac_cv_header_sys_inttypes_h = yes; then
45 AC_SUBST([HAVE_SYS_INTTYPES_H])
47 dnl Check for <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
48 AC_CHECK_HEADERS([sys/bitypes.h])
49 if test $ac_cv_header_sys_bitypes_h = yes; then
54 AC_SUBST([HAVE_SYS_BITYPES_H])
56 dnl Is long == int64_t ?
57 AC_CACHE_CHECK([whether 'long' is 64 bit wide], gl_cv_long_bitsize_64, [
59 #define POW63 ((((((long) 1 << 15) << 15) << 15) << 15) << 3)
60 #define POW64 ((((((long) 1 << 15) << 15) << 15) << 15) << 4)
61 typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
62 ], , gl_cv_long_bitsize_64=yes, gl_cv_long_bitsize_64=no)])
63 if test $gl_cv_long_bitsize_64 = yes; then
68 AC_SUBST(HAVE_LONG_64BIT)
70 dnl Is long long == int64_t ?
71 AC_CACHE_CHECK([whether 'long long' is 64 bit wide], gl_cv_longlong_bitsize_64, [
73 #define POW63 ((((((long long) 1 << 15) << 15) << 15) << 15) << 3)
74 #define POW64 ((((((long long) 1 << 15) << 15) << 15) << 15) << 4)
75 typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
76 ], , gl_cv_longlong_bitsize_64=yes, gl_cv_longlong_bitsize_64=no)])
77 if test $gl_cv_longlong_bitsize_64 = yes; then
78 HAVE_LONG_LONG_64BIT=1
80 HAVE_LONG_LONG_64BIT=0
82 AC_SUBST(HAVE_LONG_LONG_64BIT)
84 dnl Here we use FULL_PATH_INTTYPES_H and FULL_PATH_STDINT_H, not just
85 dnl <inttypes.h> and <stdint.h>, so that it also works during a
86 dnl "config.status --recheck" if an inttypes.h or stdint.h have been
87 dnl created in the build directory.
89 /* Get those types that are already defined in other system include files. */
90 #if defined(__FreeBSD__) && (__FreeBSD__ >= 3) && (__FreeBSD__ <= 4)
91 # include <sys/inttypes.h>
93 #if defined(__OpenBSD__) || defined(__bsdi__) || defined(__sgi)
94 # include <sys/types.h>
96 # include FULL_PATH_INTTYPES_H
99 #if defined(__linux__) && HAVE_SYS_BITYPES_H
100 # include <sys/bitypes.h>
102 #if defined(__sun) && HAVE_SYS_INTTYPES_H
103 # include <sys/inttypes.h>
105 #if (defined(__hpux) || defined(_AIX)) && HAVE_INTTYPES_H
106 # include FULL_PATH_INTTYPES_H
108 #if HAVE_STDINT_H && !(defined(__sgi) && HAVE_INTTYPES_H && !defined(_c99))
109 # include FULL_PATH_STDINT_H
112 gl_STDINT_CHECK_TYPES(
113 [int8_t int16_t int32_t int64_t \
114 uint8_t uint16_t uint32_t uint64_t \
115 int_least8_t int_least16_t int_least32_t int_least64_t \
116 uint_least8_t uint_least16_t uint_least32_t uint_least64_t \
117 int_fast8_t int_fast16_t int_fast32_t int_fast64_t \
118 uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t \
122 [gl_cv_type_], [], [])
124 dnl Now see if we need a substitute <stdint.h>.
125 gl_cv_header_working_stdint_h=no
126 if test $gl_cv_header_stdint_h = yes; then
127 gl_STDINT_CHECK_TYPES(
129 int_least64_t uint_least64_t \
130 int_fast64_t uint_fast64_t],
131 [#include <stdint.h>],
132 [gl_cv_stdint_], [_IN_STDINT_H], [in <stdint.h>])
135 #define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
137 int8_t a1 = INT8_C (17);
138 int16_t a2 = INT16_C (17);
139 int32_t a3 = INT32_C (17);
140 #if HAVE_INT64_T_IN_STDINT_H
141 int64_t a4 = INT64_C (17);
143 uint8_t b1 = UINT8_C (17);
144 uint16_t b2 = UINT16_C (17);
145 uint32_t b3 = UINT32_C (17);
146 #if HAVE_UINT64_T_IN_STDINT_H
147 uint64_t b4 = UINT64_C (17);
149 int_least8_t c1 = 17;
150 int_least16_t c2 = 17;
151 int_least32_t c3 = 17;
152 #if HAVE_INT_LEAST64_T_IN_STDINT_H
153 int_least64_t c4 = 17;
155 uint_least8_t d1 = 17;
156 uint_least16_t d2 = 17;
157 uint_least32_t d3 = 17;
158 #if HAVE_UINT_LEAST64_T_IN_STDINT_H
159 uint_least64_t d4 = 17;
162 int_fast16_t e2 = 17;
163 int_fast32_t e3 = 17;
164 #if HAVE_INT_FAST64_T_IN_STDINT_H
165 int_fast64_t e4 = 17;
167 uint_fast8_t f1 = 17;
168 uint_fast16_t f2 = 17;
169 uint_fast32_t f3 = 17;
170 #if HAVE_UINT_FAST64_T_IN_STDINT_H
171 uint_fast64_t f4 = 17;
175 intmax_t i = INTMAX_C (17);
176 uintmax_t j = UINTMAX_C (17);
178 [gl_cv_header_working_stdint_h=yes])
180 if test $gl_cv_header_working_stdint_h = yes; then
181 dnl Use the existing <stdint.h>, adding missing macro definitions.
184 if test $HAVE_LONG_64BIT = 1; then
188 if test $HAVE_LONG_LONG_64BIT = 1; then
192 AC_EGREP_CPP([msvc compiler], [
202 dnl Here we assume a standard architecture where the hardware integer
203 dnl types have 8, 16, 32, optionally 64 bits.
204 gl_STDINT_MISSING_BOUND([INT8_MIN], [-128],
205 [Define if <stdint.h> doesn't define it.])
206 gl_STDINT_MISSING_BOUND([INT8_MAX], [127],
207 [Define if <stdint.h> doesn't define it.])
208 gl_STDINT_MISSING_BOUND([UINT8_MAX], [255],
209 [Define if <stdint.h> doesn't define it.])
210 gl_STDINT_MISSING_BOUND([INT16_MIN], [-32768],
211 [Define if <stdint.h> doesn't define it.])
212 gl_STDINT_MISSING_BOUND([INT16_MAX], [32767],
213 [Define if <stdint.h> doesn't define it.])
214 gl_STDINT_MISSING_BOUND([UINT16_MAX], [65535],
215 [Define if <stdint.h> doesn't define it.])
216 gl_STDINT_MISSING_BOUND([INT32_MIN], [(~INT32_MAX)],
217 [Define if <stdint.h> doesn't define it.])
218 gl_STDINT_MISSING_BOUND([INT32_MAX], [2147483647],
219 [Define if <stdint.h> doesn't define it.])
220 gl_STDINT_MISSING_BOUND([UINT32_MAX], [4294967295U],
221 [Define if <stdint.h> doesn't define it.])
222 if test $gl_cv_stdint_int64_t = yes; then
223 gl_STDINT_MISSING_BOUND([INT64_MIN], [(~INT64_MAX)],
224 [Define if <stdint.h> doesn't define it but has the int64_t type.])
225 gl_STDINT_MISSING_BOUND([INT64_MAX], [9223372036854775807${suff64}],
226 [Define if <stdint.h> doesn't define it but has the int64_t type.])
228 if test $gl_cv_stdint_uint64_t = yes; then
229 gl_STDINT_MISSING_BOUND([UINT64_MAX], [18446744073709551615${suffu64}],
230 [Define if <stdint.h> doesn't define it but has the uint64_t type.])
232 dnl Here we assume a standard architecture where the hardware integer
233 dnl types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
234 dnl are the same as the corresponding N_t types.
235 gl_STDINT_MISSING_BOUND([INT_LEAST8_MIN], [INT8_MIN],
236 [Define if <stdint.h> doesn't define it.])
237 gl_STDINT_MISSING_BOUND([INT_LEAST8_MAX], [INT8_MAX],
238 [Define if <stdint.h> doesn't define it.])
239 gl_STDINT_MISSING_BOUND([UINT_LEAST8_MAX], [UINT8_MAX],
240 [Define if <stdint.h> doesn't define it.])
241 gl_STDINT_MISSING_BOUND([INT_LEAST16_MIN], [INT16_MIN],
242 [Define if <stdint.h> doesn't define it.])
243 gl_STDINT_MISSING_BOUND([INT_LEAST16_MAX], [INT16_MAX],
244 [Define if <stdint.h> doesn't define it.])
245 gl_STDINT_MISSING_BOUND([UINT_LEAST16_MAX], [UINT16_MAX],
246 [Define if <stdint.h> doesn't define it.])
247 gl_STDINT_MISSING_BOUND([INT_LEAST32_MIN], [INT32_MIN],
248 [Define if <stdint.h> doesn't define it.])
249 gl_STDINT_MISSING_BOUND([INT_LEAST32_MAX], [INT32_MAX],
250 [Define if <stdint.h> doesn't define it.])
251 gl_STDINT_MISSING_BOUND([UINT_LEAST32_MAX], [UINT32_MAX],
252 [Define if <stdint.h> doesn't define it.])
253 if test $gl_cv_stdint_int_least64_t = yes; then
254 gl_STDINT_MISSING_BOUND([INT_LEAST64_MIN], [INT64_MIN],
255 [Define if <stdint.h> doesn't define it but has the int_least64_t type.])
256 gl_STDINT_MISSING_BOUND([INT_LEAST64_MAX], [INT64_MAX],
257 [Define if <stdint.h> doesn't define it but has the int_least64_t type.])
259 if test $gl_cv_stdint_uint_least64_t = yes; then
260 gl_STDINT_MISSING_BOUND([UINT_LEAST64_MAX], [UINT64_MAX],
261 [Define if <stdint.h> doesn't define it but has the uint_least64_t type.])
263 dnl Here we assume a standard architecture where the hardware integer
264 dnl types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
265 dnl are taken from the same list of types.
266 gl_STDINT_MISSING_BOUNDS([INT_FAST8_MIN INT_FAST8_MAX UINT_FAST8_MAX \
267 INT_FAST16_MIN INT_FAST16_MAX UINT_FAST16_MAX \
268 INT_FAST32_MIN INT_FAST32_MAX UINT_FAST32_MAX])
269 if test $gl_cv_stdint_uint_fast64_t = yes; then
270 gl_STDINT_MISSING_BOUNDS([INT_FAST64_MIN INT_FAST64_MAX])
272 if test $gl_cv_stdint_uint_fast64_t = yes; then
273 gl_STDINT_MISSING_BOUNDS([UINT_FAST64_MAX])
275 gl_STDINT_MISSING_BOUNDS([INTPTR_MIN INTPTR_MAX UINTPTR_MAX \
276 INTMAX_MIN INTMAX_MAX UINTMAX_MAX])
277 gl_STDINT_MISSING_BOUNDS([PTRDIFF_MIN PTRDIFF_MAX], [#include <stddef.h>])
279 gl_STDINT_MISSING_BOUNDS2([SIG_ATOMIC_MIN SIG_ATOMIC_MAX],
280 [#include <signal.h>])
281 dnl Don't bother defining WCHAR_MIN and WCHAR_MAX, since they should
282 dnl already be defined in <stddef.h>.
283 dnl For wint_t we need <wchar.h>.
284 dnl Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included
285 dnl before <wchar.h>.
286 dnl BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
288 gl_STDINT_MISSING_BOUNDS2([WINT_MIN WINT_MAX], [
297 [int8_t int16_t int32_t int64_t \
298 uint8_t uint16_t uint32_t uint64_t \
299 int_least8_t int_least16_t int_least32_t int_least64_t \
300 uint_least8_t uint_least16_t uint_least32_t uint_least64_t \
301 int_fast8_t int_fast16_t int_fast32_t int_fast64_t \
302 uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t \
307 gl_cv_type_unsigned_int=yes
309 gl_cv_type_unsigned_long=yes
310 gl_STDINT_BITSIZEOF([unsigned_int long unsigned_long],
311 [typedef unsigned int unsigned_int;
312 typedef unsigned long unsigned_long;])
314 AC_CHECK_TYPES([ptrdiff_t])
315 gl_cv_type_ptrdiff_t=$ac_cv_type_ptrdiff_t
316 AC_REQUIRE([AC_TYPE_SIZE_T])
317 gl_cv_type_size_t=yes
318 gl_STDINT_BITSIZEOF([ptrdiff_t size_t], [#include <stddef.h>])
319 gl_CHECK_TYPE_SAME([ptrdiff_t], [long], [#include <stddef.h>])
320 gl_CHECK_TYPE_SAME([size_t], [unsigned long], [#include <stddef.h>])
322 AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
323 gl_cv_type_sig_atomic_t=$ac_cv_type_sig_atomic_t
324 gl_STDINT_BITSIZEOF([sig_atomic_t], [#include <signal.h>])
325 gl_CHECK_TYPES_SIGNED([sig_atomic_t], [#include <signal.h>])
326 if test $HAVE_SIGNED_SIG_ATOMIC_T = 1; then
327 gl_CHECK_TYPE_SAME([sig_atomic_t], [long], [#include <signal.h>])
329 gl_CHECK_TYPE_SAME([sig_atomic_t], [unsigned long], [#include <signal.h>])
332 AC_REQUIRE([gt_TYPE_WCHAR_T])
333 gl_cv_type_wchar_t=$gt_cv_c_wchar_t
334 gl_STDINT_BITSIZEOF([wchar_t], [#include <stddef.h>])
335 gl_CHECK_TYPES_SIGNED([wchar_t], [#include <stddef.h>])
336 if test $HAVE_SIGNED_WCHAR_T = 1; then
337 gl_CHECK_TYPE_SAME([wchar_t], [long], [#include <stddef.h>])
339 gl_CHECK_TYPE_SAME([wchar_t], [unsigned long], [#include <stddef.h>])
342 dnl For wint_t we need <wchar.h>.
343 dnl Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included
344 dnl before <wchar.h>.
345 dnl BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
347 AC_CHECK_TYPES([wint_t], , , [#include <stdio.h>
351 gl_cv_type_wint_t=$ac_cv_type_wint_t
352 gl_STDINT_BITSIZEOF([wint_t], [#include <stdio.h>
356 gl_CHECK_TYPES_SIGNED([wint_t], [#include <stdio.h>
360 if test $HAVE_SIGNED_WINT_T = 1; then
361 gl_CHECK_TYPE_SAME([wint_t], [long], [#include <stdio.h>
366 gl_CHECK_TYPE_SAME([wint_t], [unsigned long], [#include <stdio.h>
377 dnl Set gl_cv_header_stdint_h to yes and define HAVE_STDINT_H if
378 dnl <stdint.h> exists and doesn't clash with <sys/types.h>.
379 AC_DEFUN([gl_HEADER_STDINT_H],
381 dnl Check for <stdint.h> that doesn't clash with <sys/types.h>.
382 AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h, [
384 #include <sys/types.h>
385 #include <stdint.h>],
386 [], gl_cv_header_stdint_h=yes, gl_cv_header_stdint_h=no)
388 if test $gl_cv_header_stdint_h = yes; then
389 AC_DEFINE_UNQUOTED(HAVE_STDINT_H, 1,
390 [Define if <stdint.h> exists and doesn't clash with <sys/types.h>.])
394 dnl Set gl_cv_header_inttypes_h to yes and define HAVE_INTTYPES_H if
395 dnl <inttypes.h> exists and doesn't clash with <sys/types.h>.
396 AC_DEFUN([gl_HEADER_INTTYPES_H],
398 dnl Check for <inttypes.h> that doesn't clash with <sys/types.h>.
399 dnl On IRIX 5.3, <inttypes.h> conflicts with <sys/types.h>.
400 AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h, [
402 #include <sys/types.h>
403 #include <inttypes.h>],
404 [], gl_cv_header_inttypes_h=yes, gl_cv_header_inttypes_h=no)
406 if test $gl_cv_header_inttypes_h = yes; then
407 AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
408 [Define if <inttypes.h> exists and doesn't clash with <sys/types.h>.])
412 dnl gl_STDINT_CHECK_TYPES(TYPES, INCLUDES, CACHE_VAR_PREFIX, MACRO_SUFFIX, DESCRIPTION_SUFFIX)
413 dnl Check each of the given types, whether they are defined in the given
415 AC_DEFUN([gl_STDINT_CHECK_TYPES],
417 dnl Use a shell loop, to avoid bloating configure, and
418 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
420 dnl - extra AC_SUBST calls, so that the right substitutions are made.
421 AC_FOREACH([gltype], [$1],
422 [AH_TEMPLATE([HAVE_]translit(gltype,[abcdefghijklmnopqrstuvwxyz],[ABCDEFGHIJKLMNOPQRSTUVWXYZ])[$4],
423 [Define to 1 if the type ']gltype[' is already defined$5.])])
424 for gltype in $1 ; do
425 AC_MSG_CHECKING([for $gltype])
428 /* Test if the type exists. */
431 result=yes, result=no)
432 eval $3${gltype}=\$result
433 AC_MSG_RESULT($result)
434 GLTYPE=`echo "$gltype" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
435 if test $result = yes; then
436 AC_DEFINE_UNQUOTED([HAVE_${GLTYPE}$4], 1)
437 eval HAVE_${GLTYPE}$4=1
439 eval HAVE_${GLTYPE}$4=0
442 AC_FOREACH([gltype], [$1],
443 [AC_SUBST([HAVE_]translit(gltype,[abcdefghijklmnopqrstuvwxyz],[ABCDEFGHIJKLMNOPQRSTUVWXYZ])[$4])])
446 dnl gl_STDINT_MISSING_BOUND(TYPE_BOUND, DEFAULT, DESCRIPTION)
447 dnl assumes an otherwise complete <stdint.h> and defines TYPE_BOUND if
448 dnl <stdint.h> doesn't define it.
449 AC_DEFUN([gl_STDINT_MISSING_BOUND],
451 AC_CACHE_CHECK([for $1], [gl_cv_stdint_$1],
452 [AC_EGREP_CPP([found it], [#include <stdint.h>
456 ], [gl_cv_stdint_$1=yes], [gl_cv_stdint_$1="$2"])])
457 if test "$gl_cv_stdint_$1" != yes; then
458 AC_DEFINE_UNQUOTED([$1], [$2], [$3])
462 dnl gl_STDINT_MISSING_BOUNDS(BOUNDS, INCLUDES)
463 dnl assumes an otherwise complete <stdint.h> and defines each element of BOUNDS
464 dnl if <stdint.h> doesn't define it.
465 dnl Use this for types whose signedness is determined by the first letter
467 AC_DEFUN([gl_STDINT_MISSING_BOUNDS],
469 dnl Use a shell loop, to avoid bloating configure, and
470 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
472 AC_FOREACH([bound], [$1],
473 [AH_TEMPLATE(bound, [Define if <stdint.h> doesn't define it.])])
475 sed_unsigned='s,^\(U*\).*,\1,'
476 sed_limitkind='s,^.*\(_[^_]*\)$,\1,'
479 type=`echo $bound | sed -e 's,_MAX,_t,' -e 's,_MIN,_t,' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
480 unsigned=`echo $bound | sed -e "$sed_unsigned" | tr U u`
481 width=`echo $bound | sed -e 's,^U*INT,,' -e 's,_MIN,,' -e 's,_MAX,,'`
482 limitkind=`echo $bound | sed -e "$sed_limitkind"`
483 AC_CACHE_CHECK([for $bound], [gl_cv_stdint_$bound],
484 [AC_EGREP_CPP([found it], [#include <stdint.h>
488 ], [eval gl_cv_stdint_$bound=yes],
491 *8) widthlist="8 16 32 64" ;;
492 *16) widthlist="16 32 64" ;;
493 *32 | PTR | MAX | PTRDIFF) widthlist="32 64" ;;
494 *64) widthlist="64" ;;
496 for w in $widthlist; do
497 if test -z "$result"; then
498 AC_COMPILE_IFELSE([[$2
500 int verify[2 * (sizeof ($type) == sizeof (${unsigned}int${w}_t)) - 1];
501 ]], [result=`echo "$unsigned" | tr u U`INT${w}${limitkind}])
506 if test -z "$result"; then
509 eval gl_cv_stdint_$bound=\$result
511 eval result=\$gl_cv_stdint_$bound
512 if test "$result" != yes && test "$result" != no; then
513 AC_DEFINE_UNQUOTED([$bound], [$result],
514 [Define if <stdint.h> doesn't define it.])
519 dnl gl_STDINT_MISSING_BOUNDS2(BOUNDS, INCLUDES)
520 dnl assumes an otherwise complete <stdint.h> and defines each element of BOUNDS
521 dnl if <stdint.h> doesn't define it.
522 dnl Use this for types whose signedness is a priori unknown.
523 AC_DEFUN([gl_STDINT_MISSING_BOUNDS2],
525 dnl Use a shell loop, to avoid bloating configure, and
526 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
528 AC_FOREACH([bound], [$1],
529 [AH_TEMPLATE(bound, [Define if <stdint.h> doesn't define it.])])
531 sed_limitkind='s,^.*\(_[^_]*\)$,\1,'
534 type=`echo $bound | sed -e 's,_MAX,_t,' -e 's,_MIN,_t,' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
535 limitkind=`echo $bound | sed -e "$sed_limitkind"`
536 AC_CACHE_CHECK([for $bound], [gl_cv_stdint_$bound],
537 [AC_EGREP_CPP([found it], [#include <stdint.h>
541 ], [eval gl_cv_stdint_$bound=yes],
543 AC_COMPILE_IFELSE([[$2
544 int verify[2 * (($type) -1 >= ($type) 0) - 1];
546 [eval gl_cv_${type}_signed=no],
547 [eval gl_cv_${type}_signed=yes])
548 if eval test \$gl_cv_${type}_signed = yes; then
549 for w in 8 16 32 64; do
550 if test -z "$result"; then
551 AC_COMPILE_IFELSE([[$2
553 int verify[2 * (sizeof ($type) == sizeof (int${w}_t)) - 1];
554 ]], [result=INT${w}${limitkind}])
560 if test ${limitkind} = _MIN; then
563 for w in 8 16 32 64; do
564 if test -z "$result"; then
565 AC_COMPILE_IFELSE([[$2
567 int verify[2 * (sizeof ($type) == sizeof (uint${w}_t)) - 1];
568 ]], [result=UINT${w}${limitkind}])
575 if test -z "$result"; then
578 eval gl_cv_stdint_$bound=\$result
580 eval result=\$gl_cv_stdint_$bound
581 if test "$result" != yes && test "$result" != no; then
582 AC_DEFINE_UNQUOTED([$bound], [$result],
583 [Define if <stdint.h> doesn't define it.])
588 dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
589 dnl Determine the size of each of the given types in bits.
590 AC_DEFUN([gl_STDINT_BITSIZEOF],
592 dnl Use a shell loop, to avoid bloating configure, and
593 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
595 dnl - extra AC_SUBST calls, so that the right substitutions are made.
596 AC_FOREACH([gltype], [$1],
597 [AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
598 [Define to the number of bits in type ']gltype['.])])
599 for gltype in $1 ; do
600 if eval test \$gl_cv_type_${gltype} = yes; then
601 AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}],
602 [_AC_COMPUTE_INT([sizeof ($gltype) * CHAR_BIT], result,
604 #include <limits.h>], result=unknown)
605 eval gl_cv_bitsizeof_${gltype}=\$result
607 eval result=\$gl_cv_bitsizeof_${gltype}
608 GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
609 AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
610 eval BITSIZEOF_${GLTYPE}=\$result
613 AC_FOREACH([gltype], [$1],
614 [AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
617 dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES)
618 dnl Determine the signedness of each of the given types.
619 dnl Define HAVE_SIGNED_TYPE if type is signed.
620 AC_DEFUN([gl_CHECK_TYPES_SIGNED],
622 dnl Use a shell loop, to avoid bloating configure, and
623 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
625 dnl - extra AC_SUBST calls, so that the right substitutions are made.
626 AC_FOREACH([gltype], [$1],
627 [AH_TEMPLATE([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
628 [Define to 1 if ']gltype[' is a signed integer type.])])
629 for gltype in $1 ; do
630 AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed],
632 [AC_LANG_PROGRAM([[$2
633 int verify[2 * (($1) -1 < ($1) 0) - 1];
635 result=yes, result=no)
636 eval gl_cv_type_${gltype}_signed=\$result
638 eval result=\$gl_cv_type_${gltype}_signed
639 GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
640 if test "$result" = yes; then
641 AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], 1)
642 eval HAVE_SIGNED_${GLTYPE}=1
644 eval HAVE_SIGNED_${GLTYPE}=0
647 AC_FOREACH([gltype], [$1],
648 [AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
651 dnl gl_CHECK_TYPE_SAME(TYPE, KNOWNTYPE, INCLUDES)
652 dnl Determines whether two types are the same.
653 AC_DEFUN([gl_CHECK_TYPE_SAME],
658 [SAME_TYPE_]AS_TR_CPP([$1])[_]AS_TR_CPP([$2])[=1],
659 [SAME_TYPE_]AS_TR_CPP([$1])[_]AS_TR_CPP([$2])[=0])
660 AC_SUBST([SAME_TYPE_]AS_TR_CPP([$1])[_]AS_TR_CPP([$2]))