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 <wchar.h>.
13 AC_CHECK_HEADERS_ONCE([wchar.h])
14 if test $ac_cv_header_wchar_h = yes; then
19 AC_SUBST([HAVE_WCHAR_H])
21 dnl Check for <stdint.h> that doesn't clash with <sys/types.h>.
23 if test $gl_cv_header_stdint_h = yes; then
24 ac_cv_header_stdint_h=yes; dnl Hack for gl_FULL_HEADER_PATH.
25 gl_FULL_HEADER_PATH([stdint.h])
26 FULL_PATH_STDINT_H='<'$gl_cv_full_path_stdint_h'>'
27 AC_SUBST([FULL_PATH_STDINT_H])
32 AC_SUBST([HAVE_STDINT_H])
34 dnl Check for <inttypes.h> that doesn't clash with <sys/types.h>.
36 if test $gl_cv_header_inttypes_h = yes; then
37 ac_cv_header_inttypes_h=yes; dnl Hack for gl_FULL_HEADER_PATH.
38 gl_FULL_HEADER_PATH([inttypes.h])
39 FULL_PATH_INTTYPES_H='<'$gl_cv_full_path_inttypes_h'>'
40 AC_SUBST([FULL_PATH_INTTYPES_H])
45 AC_SUBST([HAVE_INTTYPES_H])
47 dnl Check for <sys/inttypes.h>.
48 AC_CHECK_HEADERS([sys/inttypes.h])
49 if test $ac_cv_header_sys_inttypes_h = yes; then
54 AC_SUBST([HAVE_SYS_INTTYPES_H])
56 dnl Check for <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
57 AC_CHECK_HEADERS([sys/bitypes.h])
58 if test $ac_cv_header_sys_bitypes_h = yes; then
63 AC_SUBST([HAVE_SYS_BITYPES_H])
65 dnl Is long == int64_t ?
66 AC_CACHE_CHECK([whether 'long' is 64 bit wide], gl_cv_long_bitsize_64, [
68 #define POW63 ((((((long) 1 << 15) << 15) << 15) << 15) << 3)
69 #define POW64 ((((((long) 1 << 15) << 15) << 15) << 15) << 4)
70 typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
71 ], , gl_cv_long_bitsize_64=yes, gl_cv_long_bitsize_64=no)])
72 if test $gl_cv_long_bitsize_64 = yes; then
77 AC_SUBST(HAVE_LONG_64BIT)
79 dnl Is long long == int64_t ?
80 AC_CACHE_CHECK([whether 'long long' is 64 bit wide], gl_cv_longlong_bitsize_64, [
82 #define POW63 ((((((long long) 1 << 15) << 15) << 15) << 15) << 3)
83 #define POW64 ((((((long long) 1 << 15) << 15) << 15) << 15) << 4)
84 typedef int array [2 * (POW63 != 0 && POW64 == 0) - 1];
85 ], , gl_cv_longlong_bitsize_64=yes, gl_cv_longlong_bitsize_64=no)])
86 if test $gl_cv_longlong_bitsize_64 = yes; then
87 HAVE_LONG_LONG_64BIT=1
89 HAVE_LONG_LONG_64BIT=0
91 AC_SUBST(HAVE_LONG_LONG_64BIT)
93 dnl Here we use FULL_PATH_INTTYPES_H and FULL_PATH_STDINT_H, not just
94 dnl <inttypes.h> and <stdint.h>, so that it also works during a
95 dnl "config.status --recheck" if an inttypes.h or stdint.h have been
96 dnl created in the build directory.
98 /* Get those types that are already defined in other system include files. */
99 #if defined(__FreeBSD__) && (__FreeBSD__ >= 3) && (__FreeBSD__ <= 4)
100 # include <sys/inttypes.h>
102 #if defined(__OpenBSD__) || defined(__bsdi__) || defined(__sgi)
103 # include <sys/types.h>
105 # include FULL_PATH_INTTYPES_H
108 #if defined(__linux__) && HAVE_SYS_BITYPES_H
109 # include <sys/bitypes.h>
111 #if defined(__sun) && HAVE_SYS_INTTYPES_H
112 # include <sys/inttypes.h>
114 #if (defined(__hpux) || defined(_AIX)) && HAVE_INTTYPES_H
115 # include FULL_PATH_INTTYPES_H
117 #if HAVE_STDINT_H && !(defined(__sgi) && HAVE_INTTYPES_H && !defined(_c99))
118 # include FULL_PATH_STDINT_H
121 gl_STDINT_CHECK_TYPES(
122 [int8_t int16_t int32_t int64_t \
123 uint8_t uint16_t uint32_t uint64_t \
124 int_least8_t int_least16_t int_least32_t int_least64_t \
125 uint_least8_t uint_least16_t uint_least32_t uint_least64_t \
126 int_fast8_t int_fast16_t int_fast32_t int_fast64_t \
127 uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t \
131 [gl_cv_type_], [], [])
133 dnl Now see if we need a substitute <stdint.h>.
134 gl_cv_header_working_stdint_h=no
135 if test $gl_cv_header_stdint_h = yes; then
136 gl_STDINT_CHECK_TYPES(
138 int_least64_t uint_least64_t \
139 int_fast64_t uint_fast64_t],
140 [#include <stdint.h>],
141 [gl_cv_stdint_], [_IN_STDINT_H], [in <stdint.h>])
144 #define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */
146 int8_t a1 = INT8_C (17);
147 int16_t a2 = INT16_C (17);
148 int32_t a3 = INT32_C (17);
149 #if HAVE_INT64_T_IN_STDINT_H
150 int64_t a4 = INT64_C (17);
152 uint8_t b1 = UINT8_C (17);
153 uint16_t b2 = UINT16_C (17);
154 uint32_t b3 = UINT32_C (17);
155 #if HAVE_UINT64_T_IN_STDINT_H
156 uint64_t b4 = UINT64_C (17);
158 int_least8_t c1 = 17;
159 int_least16_t c2 = 17;
160 int_least32_t c3 = 17;
161 #if HAVE_INT_LEAST64_T_IN_STDINT_H
162 int_least64_t c4 = 17;
164 uint_least8_t d1 = 17;
165 uint_least16_t d2 = 17;
166 uint_least32_t d3 = 17;
167 #if HAVE_UINT_LEAST64_T_IN_STDINT_H
168 uint_least64_t d4 = 17;
171 int_fast16_t e2 = 17;
172 int_fast32_t e3 = 17;
173 #if HAVE_INT_FAST64_T_IN_STDINT_H
174 int_fast64_t e4 = 17;
176 uint_fast8_t f1 = 17;
177 uint_fast16_t f2 = 17;
178 uint_fast32_t f3 = 17;
179 #if HAVE_UINT_FAST64_T_IN_STDINT_H
180 uint_fast64_t f4 = 17;
184 intmax_t i = INTMAX_C (17);
185 uintmax_t j = UINTMAX_C (17);
187 [gl_cv_header_working_stdint_h=yes])
189 if test $gl_cv_header_working_stdint_h = yes; then
190 dnl Use the existing <stdint.h>, adding missing macro definitions.
193 if test $HAVE_LONG_64BIT = 1; then
197 if test $HAVE_LONG_LONG_64BIT = 1; then
201 AC_EGREP_CPP([msvc compiler], [
211 dnl Here we assume a standard architecture where the hardware integer
212 dnl types have 8, 16, 32, optionally 64 bits.
213 gl_STDINT_MISSING_BOUND([INT8_MIN], [-128],
214 [Define if <stdint.h> doesn't define it.])
215 gl_STDINT_MISSING_BOUND([INT8_MAX], [127],
216 [Define if <stdint.h> doesn't define it.])
217 gl_STDINT_MISSING_BOUND([UINT8_MAX], [255],
218 [Define if <stdint.h> doesn't define it.])
219 gl_STDINT_MISSING_BOUND([INT16_MIN], [-32768],
220 [Define if <stdint.h> doesn't define it.])
221 gl_STDINT_MISSING_BOUND([INT16_MAX], [32767],
222 [Define if <stdint.h> doesn't define it.])
223 gl_STDINT_MISSING_BOUND([UINT16_MAX], [65535],
224 [Define if <stdint.h> doesn't define it.])
225 gl_STDINT_MISSING_BOUND([INT32_MIN], [(~INT32_MAX)],
226 [Define if <stdint.h> doesn't define it.])
227 gl_STDINT_MISSING_BOUND([INT32_MAX], [2147483647],
228 [Define if <stdint.h> doesn't define it.])
229 gl_STDINT_MISSING_BOUND([UINT32_MAX], [4294967295U],
230 [Define if <stdint.h> doesn't define it.])
231 if test $gl_cv_stdint_int64_t = yes; then
232 gl_STDINT_MISSING_BOUND([INT64_MIN], [(~INT64_MAX)],
233 [Define if <stdint.h> doesn't define it but has the int64_t type.])
234 gl_STDINT_MISSING_BOUND([INT64_MAX], [9223372036854775807${suff64}],
235 [Define if <stdint.h> doesn't define it but has the int64_t type.])
237 if test $gl_cv_stdint_uint64_t = yes; then
238 gl_STDINT_MISSING_BOUND([UINT64_MAX], [18446744073709551615${suffu64}],
239 [Define if <stdint.h> doesn't define it but has the uint64_t type.])
241 dnl Here we assume a standard architecture where the hardware integer
242 dnl types have 8, 16, 32, optionally 64 bits. Therefore the leastN_t types
243 dnl are the same as the corresponding N_t types.
244 gl_STDINT_MISSING_BOUND([INT_LEAST8_MIN], [INT8_MIN],
245 [Define if <stdint.h> doesn't define it.])
246 gl_STDINT_MISSING_BOUND([INT_LEAST8_MAX], [INT8_MAX],
247 [Define if <stdint.h> doesn't define it.])
248 gl_STDINT_MISSING_BOUND([UINT_LEAST8_MAX], [UINT8_MAX],
249 [Define if <stdint.h> doesn't define it.])
250 gl_STDINT_MISSING_BOUND([INT_LEAST16_MIN], [INT16_MIN],
251 [Define if <stdint.h> doesn't define it.])
252 gl_STDINT_MISSING_BOUND([INT_LEAST16_MAX], [INT16_MAX],
253 [Define if <stdint.h> doesn't define it.])
254 gl_STDINT_MISSING_BOUND([UINT_LEAST16_MAX], [UINT16_MAX],
255 [Define if <stdint.h> doesn't define it.])
256 gl_STDINT_MISSING_BOUND([INT_LEAST32_MIN], [INT32_MIN],
257 [Define if <stdint.h> doesn't define it.])
258 gl_STDINT_MISSING_BOUND([INT_LEAST32_MAX], [INT32_MAX],
259 [Define if <stdint.h> doesn't define it.])
260 gl_STDINT_MISSING_BOUND([UINT_LEAST32_MAX], [UINT32_MAX],
261 [Define if <stdint.h> doesn't define it.])
262 if test $gl_cv_stdint_int_least64_t = yes; then
263 gl_STDINT_MISSING_BOUND([INT_LEAST64_MIN], [INT64_MIN],
264 [Define if <stdint.h> doesn't define it but has the int_least64_t type.])
265 gl_STDINT_MISSING_BOUND([INT_LEAST64_MAX], [INT64_MAX],
266 [Define if <stdint.h> doesn't define it but has the int_least64_t type.])
268 if test $gl_cv_stdint_uint_least64_t = yes; then
269 gl_STDINT_MISSING_BOUND([UINT_LEAST64_MAX], [UINT64_MAX],
270 [Define if <stdint.h> doesn't define it but has the uint_least64_t type.])
272 dnl Here we assume a standard architecture where the hardware integer
273 dnl types have 8, 16, 32, optionally 64 bits. Therefore the fastN_t types
274 dnl are taken from the same list of types.
275 gl_STDINT_MISSING_BOUNDS([INT_FAST8_MIN INT_FAST8_MAX UINT_FAST8_MAX \
276 INT_FAST16_MIN INT_FAST16_MAX UINT_FAST16_MAX \
277 INT_FAST32_MIN INT_FAST32_MAX UINT_FAST32_MAX])
278 if test $gl_cv_stdint_uint_fast64_t = yes; then
279 gl_STDINT_MISSING_BOUNDS([INT_FAST64_MIN INT_FAST64_MAX])
281 if test $gl_cv_stdint_uint_fast64_t = yes; then
282 gl_STDINT_MISSING_BOUNDS([UINT_FAST64_MAX])
284 gl_STDINT_MISSING_BOUNDS([INTPTR_MIN INTPTR_MAX UINTPTR_MAX \
285 INTMAX_MIN INTMAX_MAX UINTMAX_MAX])
286 gl_STDINT_MISSING_BOUNDS([PTRDIFF_MIN PTRDIFF_MAX], [#include <stddef.h>])
288 gl_STDINT_MISSING_BOUNDS2([SIG_ATOMIC_MIN SIG_ATOMIC_MAX],
289 [#include <signal.h>])
290 dnl Don't bother defining WCHAR_MIN and WCHAR_MAX, since they should
291 dnl already be defined in <stddef.h> or <wchar.h>.
292 dnl For wint_t we need <wchar.h>.
293 dnl Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included
294 dnl before <wchar.h>.
295 dnl BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
297 gl_STDINT_MISSING_BOUNDS2([WINT_MIN WINT_MAX], [
306 [int8_t int16_t int32_t int64_t \
307 uint8_t uint16_t uint32_t uint64_t \
308 int_least8_t int_least16_t int_least32_t int_least64_t \
309 uint_least8_t uint_least16_t uint_least32_t uint_least64_t \
310 int_fast8_t int_fast16_t int_fast32_t int_fast64_t \
311 uint_fast8_t uint_fast16_t uint_fast32_t uint_fast64_t \
316 gl_cv_type_unsigned_int=yes
318 gl_cv_type_unsigned_long=yes
319 gl_STDINT_BITSIZEOF([unsigned_int long unsigned_long],
320 [typedef unsigned int unsigned_int;
321 typedef unsigned long unsigned_long;])
323 AC_CHECK_TYPES([ptrdiff_t])
324 gl_cv_type_ptrdiff_t=$ac_cv_type_ptrdiff_t
325 AC_REQUIRE([AC_TYPE_SIZE_T])
326 gl_cv_type_size_t=yes
327 gl_STDINT_BITSIZEOF([ptrdiff_t size_t], [#include <stddef.h>])
328 gl_CHECK_TYPE_SAME([ptrdiff_t], [long], [#include <stddef.h>])
329 gl_CHECK_TYPE_SAME([size_t], [unsigned long], [#include <stddef.h>])
331 AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
332 gl_cv_type_sig_atomic_t=$ac_cv_type_sig_atomic_t
333 gl_STDINT_BITSIZEOF([sig_atomic_t], [#include <signal.h>])
334 gl_CHECK_TYPES_SIGNED([sig_atomic_t], [#include <signal.h>])
335 if test $HAVE_SIGNED_SIG_ATOMIC_T = 1; then
336 gl_CHECK_TYPE_SAME([sig_atomic_t], [long], [#include <signal.h>])
338 gl_CHECK_TYPE_SAME([sig_atomic_t], [unsigned long], [#include <signal.h>])
341 AC_REQUIRE([gt_TYPE_WCHAR_T])
342 gl_cv_type_wchar_t=$gt_cv_c_wchar_t
343 gl_STDINT_BITSIZEOF([wchar_t], [#include <stddef.h>])
344 gl_CHECK_TYPES_SIGNED([wchar_t], [#include <stddef.h>])
345 if test $HAVE_SIGNED_WCHAR_T = 1; then
346 gl_CHECK_TYPE_SAME([wchar_t], [long], [#include <stddef.h>])
348 gl_CHECK_TYPE_SAME([wchar_t], [unsigned long], [#include <stddef.h>])
351 dnl For wint_t we need <wchar.h>.
352 dnl Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included
353 dnl before <wchar.h>.
354 dnl BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before
356 AC_CHECK_TYPES([wint_t], , , [#include <stdio.h>
360 gl_cv_type_wint_t=$ac_cv_type_wint_t
361 gl_STDINT_BITSIZEOF([wint_t], [#include <stdio.h>
365 gl_CHECK_TYPES_SIGNED([wint_t], [#include <stdio.h>
369 if test $HAVE_SIGNED_WINT_T = 1; then
370 gl_CHECK_TYPE_SAME([wint_t], [long], [#include <stdio.h>
375 gl_CHECK_TYPE_SAME([wint_t], [unsigned long], [#include <stdio.h>
386 dnl Set gl_cv_header_stdint_h to yes and define HAVE_STDINT_H if
387 dnl <stdint.h> exists and doesn't clash with <sys/types.h>.
388 AC_DEFUN([gl_HEADER_STDINT_H],
390 dnl Check for <stdint.h> that doesn't clash with <sys/types.h>.
391 AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h, [
393 #include <sys/types.h>
394 #include <stdint.h>],
395 [], gl_cv_header_stdint_h=yes, gl_cv_header_stdint_h=no)
397 if test $gl_cv_header_stdint_h = yes; then
398 AC_DEFINE_UNQUOTED(HAVE_STDINT_H, 1,
399 [Define if <stdint.h> exists and doesn't clash with <sys/types.h>.])
403 dnl Set gl_cv_header_inttypes_h to yes and define HAVE_INTTYPES_H if
404 dnl <inttypes.h> exists and doesn't clash with <sys/types.h>.
405 AC_DEFUN([gl_HEADER_INTTYPES_H],
407 dnl Check for <inttypes.h> that doesn't clash with <sys/types.h>.
408 dnl On IRIX 5.3, <inttypes.h> conflicts with <sys/types.h>.
409 AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h, [
411 #include <sys/types.h>
412 #include <inttypes.h>],
413 [], gl_cv_header_inttypes_h=yes, gl_cv_header_inttypes_h=no)
415 if test $gl_cv_header_inttypes_h = yes; then
416 AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1,
417 [Define if <inttypes.h> exists and doesn't clash with <sys/types.h>.])
421 dnl gl_STDINT_CHECK_TYPES(TYPES, INCLUDES, CACHE_VAR_PREFIX, MACRO_SUFFIX, DESCRIPTION_SUFFIX)
422 dnl Check each of the given types, whether they are defined in the given
424 AC_DEFUN([gl_STDINT_CHECK_TYPES],
426 dnl Use a shell loop, to avoid bloating configure, and
427 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
429 dnl - extra AC_SUBST calls, so that the right substitutions are made.
430 AC_FOREACH([gltype], [$1],
431 [AH_TEMPLATE([HAVE_]translit(gltype,[abcdefghijklmnopqrstuvwxyz],[ABCDEFGHIJKLMNOPQRSTUVWXYZ])[$4],
432 [Define to 1 if the type ']gltype[' is already defined$5.])])
433 for gltype in $1 ; do
434 AC_MSG_CHECKING([for $gltype])
437 /* Test if the type exists. */
440 result=yes, result=no)
441 eval $3${gltype}=\$result
442 AC_MSG_RESULT($result)
443 GLTYPE=`echo "$gltype" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
444 if test $result = yes; then
445 AC_DEFINE_UNQUOTED([HAVE_${GLTYPE}$4], 1)
446 eval HAVE_${GLTYPE}$4=1
448 eval HAVE_${GLTYPE}$4=0
451 AC_FOREACH([gltype], [$1],
452 [AC_SUBST([HAVE_]translit(gltype,[abcdefghijklmnopqrstuvwxyz],[ABCDEFGHIJKLMNOPQRSTUVWXYZ])[$4])])
455 dnl gl_STDINT_MISSING_BOUND(TYPE_BOUND, DEFAULT, DESCRIPTION)
456 dnl assumes an otherwise complete <stdint.h> and defines TYPE_BOUND if
457 dnl <stdint.h> doesn't define it.
458 AC_DEFUN([gl_STDINT_MISSING_BOUND],
460 AC_CACHE_CHECK([for $1], [gl_cv_stdint_$1],
461 [AC_EGREP_CPP([found it], [#include <stdint.h>
465 ], [gl_cv_stdint_$1=yes], [gl_cv_stdint_$1="$2"])])
466 if test "$gl_cv_stdint_$1" != yes; then
467 AC_DEFINE_UNQUOTED([$1], [$2], [$3])
471 dnl gl_STDINT_MISSING_BOUNDS(BOUNDS, INCLUDES)
472 dnl assumes an otherwise complete <stdint.h> and defines each element of BOUNDS
473 dnl if <stdint.h> doesn't define it.
474 dnl Use this for types whose signedness is determined by the first letter
476 AC_DEFUN([gl_STDINT_MISSING_BOUNDS],
478 dnl Use a shell loop, to avoid bloating configure, and
479 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
481 AC_FOREACH([bound], [$1],
482 [AH_TEMPLATE(bound, [Define if <stdint.h> doesn't define it.])])
484 sed_unsigned='s,^\(U*\).*,\1,'
485 sed_limitkind='s,^.*\(_[^_]*\)$,\1,'
488 type=`echo $bound | sed -e 's,_MAX,_t,' -e 's,_MIN,_t,' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
489 unsigned=`echo $bound | sed -e "$sed_unsigned" | tr U u`
490 width=`echo $bound | sed -e 's,^U*INT,,' -e 's,_MIN,,' -e 's,_MAX,,'`
491 limitkind=`echo $bound | sed -e "$sed_limitkind"`
492 AC_CACHE_CHECK([for $bound], [gl_cv_stdint_$bound],
493 [AC_EGREP_CPP([found it], [#include <stdint.h>
497 ], [eval gl_cv_stdint_$bound=yes],
500 *8) widthlist="8 16 32 64" ;;
501 *16) widthlist="16 32 64" ;;
502 *32 | PTR | MAX | PTRDIFF) widthlist="32 64" ;;
503 *64) widthlist="64" ;;
505 for w in $widthlist; do
506 if test -z "$result"; then
507 AC_COMPILE_IFELSE([[$2
509 int verify[2 * (sizeof ($type) == sizeof (${unsigned}int${w}_t)) - 1];
510 ]], [result=`echo "$unsigned" | tr u U`INT${w}${limitkind}])
515 if test -z "$result"; then
518 eval gl_cv_stdint_$bound=\$result
520 eval result=\$gl_cv_stdint_$bound
521 if test "$result" != yes && test "$result" != no; then
522 AC_DEFINE_UNQUOTED([$bound], [$result],
523 [Define if <stdint.h> doesn't define it.])
528 dnl gl_STDINT_MISSING_BOUNDS2(BOUNDS, INCLUDES)
529 dnl assumes an otherwise complete <stdint.h> and defines each element of BOUNDS
530 dnl if <stdint.h> doesn't define it.
531 dnl Use this for types whose signedness is a priori unknown.
532 AC_DEFUN([gl_STDINT_MISSING_BOUNDS2],
534 dnl Use a shell loop, to avoid bloating configure, and
535 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
537 AC_FOREACH([bound], [$1],
538 [AH_TEMPLATE(bound, [Define if <stdint.h> doesn't define it.])])
540 sed_limitkind='s,^.*\(_[^_]*\)$,\1,'
543 type=`echo $bound | sed -e 's,_MAX,_t,' -e 's,_MIN,_t,' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
544 limitkind=`echo $bound | sed -e "$sed_limitkind"`
545 AC_CACHE_CHECK([for $bound], [gl_cv_stdint_$bound],
546 [AC_EGREP_CPP([found it], [#include <stdint.h>
550 ], [eval gl_cv_stdint_$bound=yes],
552 AC_COMPILE_IFELSE([[$2
553 int verify[2 * (($type) -1 >= ($type) 0) - 1];
555 [eval gl_cv_${type}_signed=no],
556 [eval gl_cv_${type}_signed=yes])
557 if eval test \$gl_cv_${type}_signed = yes; then
558 for w in 8 16 32 64; do
559 if test -z "$result"; then
560 AC_COMPILE_IFELSE([[$2
562 int verify[2 * (sizeof ($type) == sizeof (int${w}_t)) - 1];
563 ]], [result=INT${w}${limitkind}])
569 if test ${limitkind} = _MIN; then
572 for w in 8 16 32 64; do
573 if test -z "$result"; then
574 AC_COMPILE_IFELSE([[$2
576 int verify[2 * (sizeof ($type) == sizeof (uint${w}_t)) - 1];
577 ]], [result=UINT${w}${limitkind}])
584 if test -z "$result"; then
587 eval gl_cv_stdint_$bound=\$result
589 eval result=\$gl_cv_stdint_$bound
590 if test "$result" != yes && test "$result" != no; then
591 AC_DEFINE_UNQUOTED([$bound], [$result],
592 [Define if <stdint.h> doesn't define it.])
597 dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
598 dnl Determine the size of each of the given types in bits.
599 AC_DEFUN([gl_STDINT_BITSIZEOF],
601 dnl Use a shell loop, to avoid bloating configure, and
602 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
604 dnl - extra AC_SUBST calls, so that the right substitutions are made.
605 AC_FOREACH([gltype], [$1],
606 [AH_TEMPLATE([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
607 [Define to the number of bits in type ']gltype['.])])
608 for gltype in $1 ; do
609 if eval test \$gl_cv_type_${gltype} = yes; then
610 AC_CACHE_CHECK([for bit size of $gltype], [gl_cv_bitsizeof_${gltype}],
611 [_AC_COMPUTE_INT([sizeof ($gltype) * CHAR_BIT], result,
613 #include <limits.h>], result=unknown)
614 eval gl_cv_bitsizeof_${gltype}=\$result
616 eval result=\$gl_cv_bitsizeof_${gltype}
617 GLTYPE=`echo "$gltype" | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
618 AC_DEFINE_UNQUOTED([BITSIZEOF_${GLTYPE}], [$result])
619 eval BITSIZEOF_${GLTYPE}=\$result
622 AC_FOREACH([gltype], [$1],
623 [AC_SUBST([BITSIZEOF_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
626 dnl gl_CHECK_TYPES_SIGNED(TYPES, INCLUDES)
627 dnl Determine the signedness of each of the given types.
628 dnl Define HAVE_SIGNED_TYPE if type is signed.
629 AC_DEFUN([gl_CHECK_TYPES_SIGNED],
631 dnl Use a shell loop, to avoid bloating configure, and
632 dnl - extra AH_TEMPLATE calls, so that autoheader knows what to put into
634 dnl - extra AC_SUBST calls, so that the right substitutions are made.
635 AC_FOREACH([gltype], [$1],
636 [AH_TEMPLATE([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]),
637 [Define to 1 if ']gltype[' is a signed integer type.])])
638 for gltype in $1 ; do
639 AC_CACHE_CHECK([whether $gltype is signed], [gl_cv_type_${gltype}_signed],
641 [AC_LANG_PROGRAM([[$2
642 int verify[2 * (($1) -1 < ($1) 0) - 1];
644 result=yes, result=no)
645 eval gl_cv_type_${gltype}_signed=\$result
647 eval result=\$gl_cv_type_${gltype}_signed
648 GLTYPE=`echo $gltype | tr 'abcdefghijklmnopqrstuvwxyz ' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_'`
649 if test "$result" = yes; then
650 AC_DEFINE_UNQUOTED([HAVE_SIGNED_${GLTYPE}], 1)
651 eval HAVE_SIGNED_${GLTYPE}=1
653 eval HAVE_SIGNED_${GLTYPE}=0
656 AC_FOREACH([gltype], [$1],
657 [AC_SUBST([HAVE_SIGNED_]translit(gltype,[abcdefghijklmnopqrstuvwxyz ],[ABCDEFGHIJKLMNOPQRSTUVWXYZ_]))])
660 dnl gl_CHECK_TYPE_SAME(TYPE, KNOWNTYPE, INCLUDES)
661 dnl Determines whether two types are the same.
662 AC_DEFUN([gl_CHECK_TYPE_SAME],
667 [SAME_TYPE_]AS_TR_CPP([$1])[_]AS_TR_CPP([$2])[=1],
668 [SAME_TYPE_]AS_TR_CPP([$1])[_]AS_TR_CPP([$2])[=0])
669 AC_SUBST([SAME_TYPE_]AS_TR_CPP([$1])[_]AS_TR_CPP([$2]))