1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Type related macros: existence, sizeof, and structure members.
4 # Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008 Free
5 # Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 # As a special exception, the Free Software Foundation gives unlimited
23 # permission to copy, distribute and modify the configure scripts that
24 # are the output of Autoconf. You need not follow the terms of the GNU
25 # General Public License when using or distributing such scripts, even
26 # though portions of the text of Autoconf appear in them. The GNU
27 # General Public License (GPL) does govern all other use of the material
28 # that constitutes the Autoconf program.
30 # Certain portions of the Autoconf source text are designed to be copied
31 # (in certain cases, depending on the input) into the output of
32 # Autoconf. We call these the "data" portions. The rest of the Autoconf
33 # source text consists of comments plus executable code that decides which
34 # of the data portions to output in any given case. We call these
35 # comments and executable code the "non-data" portions. Autoconf never
36 # copies any of the non-data portions into its output.
38 # This special exception to the GPL applies to versions of Autoconf
39 # released by the Free Software Foundation. When you make and
40 # distribute a modified version of Autoconf, you may extend this special
41 # exception to the GPL to apply to your modified version as well, *unless*
42 # your modified version has the potential to copy into its output some
43 # of the text that was the non-data portion of the version that you started
44 # with. (In other words, unless your change moves or copies text from
45 # the non-data portions to the data portions.) If your modification has
46 # such potential, you must delete any notice of this special exception
47 # to the GPL from your modified version.
49 # Written by David MacKenzie, with help from
50 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
51 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
54 ## ---------------- ##
56 ## ---------------- ##
62 # Up to 2.13 included, Autoconf used to provide the macro
64 # AC_CHECK_TYPE(TYPE, DEFAULT)
66 # Since, it provides another version which fits better with the other
70 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
71 # [INCLUDES = DEFAULT-INCLUDES])
73 # In order to provide backward compatibility, the new scheme is
74 # implemented as _AC_CHECK_TYPE_NEW, the old scheme as _AC_CHECK_TYPE_OLD,
75 # and AC_CHECK_TYPE branches to one or the other, depending upon its
79 # _AC_CHECK_TYPE_NEW_BODY
80 # -----------------------
81 # Shell function body for _AC_CHECK_TYPE_NEW. This macro implements the
82 # former task of AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE
83 # used to grep in the headers, which, BTW, led to many problems until the
84 # extended regular expression was correct and did not give false positives.
85 # It turned out there are even portability issues with egrep...
87 # The most obvious way to check for a TYPE is just to compile a variable
92 # (TYPE being the second parameter to the shell function, hence $[]2 in m4).
93 # Unfortunately this does not work for const qualified types in C++, where
94 # you need an initializer. So you think of
96 # TYPE my_var = (TYPE) 0;
98 # Unfortunately, again, this is not valid for some C++ classes.
100 # Then you look for another scheme. For instance you think of declaring
101 # a function which uses a parameter of type TYPE:
103 # int foo (TYPE param);
105 # but of course you soon realize this does not make it with K&R
106 # compilers. And by no ways you want to
112 # since this time it's C++ who is not happy.
114 # Don't even think of the return type of a function, since K&R cries
115 # there too. So you start thinking of declaring a *pointer* to this TYPE:
119 # but you know fairly well that this is legal in C for aggregates which
120 # are unknown (TYPE = struct does-not-exist).
122 # Then you think of using sizeof to make sure the TYPE is really
127 # But this succeeds if TYPE is a variable: you get the size of the
130 # So, to filter out the last possibility, you try this too:
134 # This fails if TYPE is a type, but succeeds if TYPE is actually a variable.
136 # Also note that we use
140 # to `read' sizeof (to avoid warnings), while not depending on its type
141 # (not necessarily size_t etc.).
143 # C++ disallows defining types inside `sizeof ()', but that's OK,
144 # since we don't want to consider unnamed structs to be types for C++,
145 # precisely because they don't work in cases like that.
146 m4_define([_AC_CHECK_TYPE_NEW_BODY],
147 [ AS_LINENO_PUSH([$[]1])
148 AC_CACHE_CHECK([for $[]2], [$[]3],
149 [AS_VAR_SET([$[]3], [no])
151 [AC_LANG_PROGRAM([$[]4],
155 [AC_LANG_PROGRAM([$[]4],
156 [if (sizeof (($[]2)))
159 [AS_VAR_SET([$[]3], [yes])])])])
163 # _AC_CHECK_TYPE_NEW(TYPE,
164 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
165 # [INCLUDES = DEFAULT-INCLUDES])
166 # ------------------------------------------------------------
167 # Check whether the type TYPE is supported by the system, maybe via the
168 # the provided includes.
169 AC_DEFUN([_AC_CHECK_TYPE_NEW],
170 [AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_type],
171 [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_type],
172 [LINENO TYPE VAR INCLUDES],
173 [Tests whether TYPE exists after having included INCLUDES, setting
174 cache variable VAR accordingly.])],
176 [AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])]dnl
177 [ac_func_[]_AC_LANG_ABBREV[]_check_type "$LINENO" "$1" "ac_Type" ]dnl
178 ["AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])"
179 AS_VAR_IF([ac_Type], [yes], [$2], [$3])
180 AS_VAR_POPDEF([ac_Type])dnl
181 ])# _AC_CHECK_TYPE_NEW
184 # AC_CHECK_TYPES(TYPES,
185 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
186 # [INCLUDES = DEFAULT-INCLUDES])
187 # --------------------------------------------------------
188 # TYPES is an m4 list. There are no ambiguities here, we mean the newer
190 AC_DEFUN([AC_CHECK_TYPES],
191 [m4_foreach([AC_Type], [$1],
192 [_AC_CHECK_TYPE_NEW(AC_Type,
193 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Type), 1,
194 [Define to 1 if the system has the
201 # _AC_CHECK_TYPE_OLD(TYPE, DEFAULT)
202 # ---------------------------------
203 # FIXME: This is an extremely badly chosen name, since this
204 # macro actually performs an AC_REPLACE_TYPE. Some day we
205 # have to clean this up.
206 m4_define([_AC_CHECK_TYPE_OLD],
207 [_AC_CHECK_TYPE_NEW([$1],,
208 [AC_DEFINE_UNQUOTED([$1], [$2],
209 [Define to `$2' if <sys/types.h> does not define.])])dnl
210 ])# _AC_CHECK_TYPE_OLD
213 # _AC_CHECK_TYPE_REPLACEMENT_TYPE_P(STRING)
214 # -----------------------------------------
215 # Return `1' if STRING seems to be a builtin C/C++ type, i.e., if it
216 # starts with `_Bool', `bool', `char', `double', `float', `int',
217 # `long', `short', `signed', or `unsigned' followed by characters
218 # that are defining types.
219 # Because many people have used `off_t' and `size_t' too, they are added
220 # for better common-useward backward compatibility.
221 m4_define([_AC_CHECK_TYPE_REPLACEMENT_TYPE_P],
223 [^\(_Bool\|bool\|char\|double\|float\|int\|long\|short\|\(un\)?signed\|[_a-zA-Z][_a-zA-Z0-9]*_t\)[][_a-zA-Z0-9() *]*$],
225 ])# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P
228 # _AC_CHECK_TYPE_MAYBE_TYPE_P(STRING)
229 # -----------------------------------
230 # Return `1' if STRING looks like a C/C++ type.
231 m4_define([_AC_CHECK_TYPE_MAYBE_TYPE_P],
232 [m4_bmatch([$1], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$],
234 ])# _AC_CHECK_TYPE_MAYBE_TYPE_P
237 # AC_CHECK_TYPE(TYPE, DEFAULT)
239 # AC_CHECK_TYPE(TYPE,
240 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
241 # [INCLUDES = DEFAULT-INCLUDES])
242 # -------------------------------------------------------
244 # Dispatch respectively to _AC_CHECK_TYPE_OLD or _AC_CHECK_TYPE_NEW.
245 # 1. More than two arguments => NEW
246 # 2. $2 seems to be replacement type => OLD
247 # See _AC_CHECK_TYPE_REPLACEMENT_TYPE_P for `replacement type'.
248 # 3. $2 seems to be a type => NEW plus a warning
250 AC_DEFUN([AC_CHECK_TYPE],
252 [_AC_CHECK_TYPE_NEW($@)],
254 [_AC_CHECK_TYPE_NEW($@)],
255 _AC_CHECK_TYPE_REPLACEMENT_TYPE_P([$2]), 1,
256 [_AC_CHECK_TYPE_OLD($@)],
257 _AC_CHECK_TYPE_MAYBE_TYPE_P([$2]), 1,
258 [AC_DIAGNOSE([syntax],
259 [$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)],
260 [_AC_CHECK_TYPE_NEW($@)])[]dnl
265 # ---------------------------- #
266 # Types that must be checked. #
267 # ---------------------------- #
269 AN_IDENTIFIER([ptrdiff_t], [AC_CHECK_TYPES])
272 # ----------------- #
274 # ----------------- #
278 AC_DEFUN([AC_TYPE_GETGROUPS],
279 [AC_REQUIRE([AC_TYPE_UID_T])dnl
280 AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
281 [AC_RUN_IFELSE([AC_LANG_SOURCE(
282 [[/* Thanks to Mike Rendell for this test. */
283 ]AC_INCLUDES_DEFAULT[
286 #define MAX(x, y) ((x) > (y) ? (x) : (y))
293 union { gid_t gval; long int lval; } val;
296 for (i = 0; i < NGID; i++)
297 gidset[i] = val.gval;
298 n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
300 /* Exit non-zero if getgroups seems to require an array of ints. This
301 happens when gid_t is short int but getgroups modifies an array
303 return n > 0 && gidset[n] != val.gval;
305 [ac_cv_type_getgroups=gid_t],
306 [ac_cv_type_getgroups=int],
307 [ac_cv_type_getgroups=cross])
308 if test $ac_cv_type_getgroups = cross; then
309 dnl When we can't run the test program (we are cross compiling), presume
310 dnl that <unistd.h> has either an accurate prototype for getgroups or none.
311 dnl Old systems without prototypes probably use int.
312 AC_EGREP_HEADER([getgroups.*int.*gid_t], unistd.h,
313 ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int)
315 AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups,
316 [Define to the type of elements in the array set by
317 `getgroups'. Usually this is either `int' or `gid_t'.])
318 ])# AC_TYPE_GETGROUPS
321 # AU::AM_TYPE_PTRDIFF_T
322 # ---------------------
323 AU_DEFUN([AM_TYPE_PTRDIFF_T],
324 [AC_CHECK_TYPES(ptrdiff_t)])
329 AC_DEFUN([AC_TYPE_INTMAX_T],
331 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
332 AC_CHECK_TYPE([intmax_t],
333 [AC_DEFINE([HAVE_INTMAX_T], 1,
334 [Define to 1 if the system has the type `intmax_t'.])],
335 [test $ac_cv_type_long_long_int = yes \
336 && ac_type='long long int' \
337 || ac_type='long int'
338 AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
339 [Define to the widest signed integer type
340 if <stdint.h> and <inttypes.h> do not define.])])
346 AC_DEFUN([AC_TYPE_UINTMAX_T],
348 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
349 AC_CHECK_TYPE([uintmax_t],
350 [AC_DEFINE([HAVE_UINTMAX_T], 1,
351 [Define to 1 if the system has the type `uintmax_t'.])],
352 [test $ac_cv_type_unsigned_long_long_int = yes \
353 && ac_type='unsigned long long int' \
354 || ac_type='unsigned long int'
355 AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
356 [Define to the widest unsigned integer type
357 if <stdint.h> and <inttypes.h> do not define.])])
363 AC_DEFUN([AC_TYPE_INTPTR_T],
365 AC_CHECK_TYPE([intptr_t],
366 [AC_DEFINE([HAVE_INTPTR_T], 1,
367 [Define to 1 if the system has the type `intptr_t'.])],
368 [for ac_type in 'int' 'long int' 'long long int'; do
370 [AC_LANG_BOOL_COMPILE_TRY(
371 [AC_INCLUDES_DEFAULT],
372 [[sizeof (void *) <= sizeof ($ac_type)]])],
373 [AC_DEFINE_UNQUOTED([intptr_t], [$ac_type],
374 [Define to the type of a signed integer type wide enough to
375 hold a pointer, if such a type exists, and if the system
376 does not define it.])
378 test -z "$ac_type" && break
385 AC_DEFUN([AC_TYPE_UINTPTR_T],
387 AC_CHECK_TYPE([uintptr_t],
388 [AC_DEFINE([HAVE_UINTPTR_T], 1,
389 [Define to 1 if the system has the type `uintptr_t'.])],
390 [for ac_type in 'unsigned int' 'unsigned long int' \
391 'unsigned long long int'; do
393 [AC_LANG_BOOL_COMPILE_TRY(
394 [AC_INCLUDES_DEFAULT],
395 [[sizeof (void *) <= sizeof ($ac_type)]])],
396 [AC_DEFINE_UNQUOTED([uintptr_t], [$ac_type],
397 [Define to the type of an unsigned integer type wide enough to
398 hold a pointer, if such a type exists, and if the system
399 does not define it.])
401 test -z "$ac_type" && break
406 # AC_TYPE_LONG_DOUBLE
407 # -------------------
408 AC_DEFUN([AC_TYPE_LONG_DOUBLE],
410 AC_CACHE_CHECK([for long double], [ac_cv_type_long_double],
411 [if test "$GCC" = yes; then
412 ac_cv_type_long_double=yes
415 [AC_LANG_BOOL_COMPILE_TRY(
416 [[/* The Stardent Vistra knows sizeof (long double), but does
418 long double foo = 0.0L;]],
419 [[/* On Ultrix 4.3 cc, long double is 4 and double is 8. */
420 sizeof (double) <= sizeof (long double)]])],
421 [ac_cv_type_long_double=yes],
422 [ac_cv_type_long_double=no])
424 if test $ac_cv_type_long_double = yes; then
425 AC_DEFINE([HAVE_LONG_DOUBLE], 1,
426 [Define to 1 if the system has the type `long double'.])
431 # AC_TYPE_LONG_DOUBLE_WIDER
432 # -------------------------
433 AC_DEFUN([AC_TYPE_LONG_DOUBLE_WIDER],
436 [for long double with more range or precision than double],
437 [ac_cv_type_long_double_wider],
439 [AC_LANG_BOOL_COMPILE_TRY(
441 long double const a[] =
443 0.0L, DBL_MIN, DBL_MAX, DBL_EPSILON,
444 LDBL_MIN, LDBL_MAX, LDBL_EPSILON
449 return ((x + (unsigned long int) 10) * (-1 / x) + a[0]
450 + (x ? f (x) : 'c'));
453 [[(0 < ((DBL_MAX_EXP < LDBL_MAX_EXP)
454 + (DBL_MANT_DIG < LDBL_MANT_DIG)
455 - (LDBL_MAX_EXP < DBL_MAX_EXP)
456 - (LDBL_MANT_DIG < DBL_MANT_DIG)))
457 && (int) LDBL_EPSILON == 0
459 ac_cv_type_long_double_wider=yes,
460 ac_cv_type_long_double_wider=no)])
461 if test $ac_cv_type_long_double_wider = yes; then
462 AC_DEFINE([HAVE_LONG_DOUBLE_WIDER], 1,
463 [Define to 1 if the type `long double' works and has more range or
464 precision than `double'.])
466 ])# AC_TYPE_LONG_DOUBLE_WIDER
471 AU_DEFUN([AC_C_LONG_DOUBLE],
473 AC_TYPE_LONG_DOUBLE_WIDER
474 ac_cv_c_long_double=$ac_cv_type_long_double_wider
475 if test $ac_cv_c_long_double = yes; then
476 AC_DEFINE([HAVE_LONG_DOUBLE], 1,
477 [Define to 1 if the type `long double' works and has more range or
478 precision than `double'.])
481 [The macro `AC_C_LONG_DOUBLE' is obsolete.
482 You should use `AC_TYPE_LONG_DOUBLE' or `AC_TYPE_LONG_DOUBLE_WIDER' instead.]
486 # _AC_TYPE_LONG_LONG_SNIPPET
487 # --------------------------
488 # Expands to a C program that can be used to test for simultaneous support
489 # of 'long long' and 'unsigned long long'. We don't want to say that
490 # 'long long' is available if 'unsigned long long' is not, or vice versa,
491 # because too many programs rely on the symmetry between signed and unsigned
492 # integer types (excluding 'bool').
493 AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
496 [[/* For now, do not test the preprocessor; as of 2007 there are too many
497 implementations with broken preprocessors. Perhaps this can
498 be revisited in 2012. In the meantime, code should not expect
499 #if to work with literals wider than 32 bits. */
501 long long int ll = 9223372036854775807ll;
502 long long int nll = -9223372036854775807LL;
503 unsigned long long int ull = 18446744073709551615ULL;
504 /* Test constant expressions. */
505 typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
507 typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
510 [[/* Test availability of runtime routines for shift and division. */
511 long long int llmax = 9223372036854775807ll;
512 unsigned long long int ullmax = 18446744073709551615ull;
513 return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
514 | (llmax / ll) | (llmax % ll)
515 | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
516 | (ullmax / ull) | (ullmax % ull));]])
520 # AC_TYPE_LONG_LONG_INT
521 # ---------------------
522 AC_DEFUN([AC_TYPE_LONG_LONG_INT],
524 AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
526 [_AC_TYPE_LONG_LONG_SNIPPET],
527 [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
528 dnl If cross compiling, assume the bug isn't important, since
529 dnl nobody cross compiles for this platform as far as we know.
532 [[@%:@include <limits.h>
535 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
536 @%:@ define LLONG_MAX (HALF - 1 + HALF)
538 [[long long int n = 1;
542 long long int m = n << i;
545 if (LLONG_MAX / 2 < m)
549 [ac_cv_type_long_long_int=yes],
550 [ac_cv_type_long_long_int=no],
551 [ac_cv_type_long_long_int=yes])],
552 [ac_cv_type_long_long_int=no])])
553 if test $ac_cv_type_long_long_int = yes; then
554 AC_DEFINE([HAVE_LONG_LONG_INT], 1,
555 [Define to 1 if the system has the type `long long int'.])
560 # AC_TYPE_UNSIGNED_LONG_LONG_INT
561 # ------------------------------
562 AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
564 AC_CACHE_CHECK([for unsigned long long int],
565 [ac_cv_type_unsigned_long_long_int],
567 [_AC_TYPE_LONG_LONG_SNIPPET],
568 [ac_cv_type_unsigned_long_long_int=yes],
569 [ac_cv_type_unsigned_long_long_int=no])])
570 if test $ac_cv_type_unsigned_long_long_int = yes; then
571 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], 1,
572 [Define to 1 if the system has the type `unsigned long long int'.])
579 AC_DEFUN([AC_TYPE_MBSTATE_T],
580 [AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
584 # include <wchar.h>],
585 [mbstate_t x; return sizeof x;])],
586 [ac_cv_type_mbstate_t=yes],
587 [ac_cv_type_mbstate_t=no])])
588 if test $ac_cv_type_mbstate_t = yes; then
589 AC_DEFINE([HAVE_MBSTATE_T], 1,
590 [Define to 1 if <wchar.h> declares mbstate_t.])
592 AC_DEFINE([mbstate_t], int,
593 [Define to a type if <wchar.h> does not define.])
599 # FIXME: Rewrite using AC_CHECK_TYPE.
600 AN_IDENTIFIER([gid_t], [AC_TYPE_UID_T])
601 AN_IDENTIFIER([uid_t], [AC_TYPE_UID_T])
602 AC_DEFUN([AC_TYPE_UID_T],
603 [AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
604 [AC_EGREP_HEADER(uid_t, sys/types.h,
605 ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
606 if test $ac_cv_type_uid_t = no; then
607 AC_DEFINE(uid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
608 AC_DEFINE(gid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
613 AN_IDENTIFIER([size_t], [AC_TYPE_SIZE_T])
614 AC_DEFUN([AC_TYPE_SIZE_T], [AC_CHECK_TYPE(size_t, unsigned int)])
616 AN_IDENTIFIER([ssize_t], [AC_TYPE_SSIZE_T])
617 AC_DEFUN([AC_TYPE_SSIZE_T], [AC_CHECK_TYPE(ssize_t, int)])
619 AN_IDENTIFIER([pid_t], [AC_TYPE_PID_T])
620 AC_DEFUN([AC_TYPE_PID_T], [AC_CHECK_TYPE(pid_t, int)])
622 AN_IDENTIFIER([off_t], [AC_TYPE_OFF_T])
623 AC_DEFUN([AC_TYPE_OFF_T], [AC_CHECK_TYPE(off_t, long int)])
625 AN_IDENTIFIER([mode_t], [AC_TYPE_MODE_T])
626 AC_DEFUN([AC_TYPE_MODE_T], [AC_CHECK_TYPE(mode_t, int)])
628 AN_IDENTIFIER([int8_t], [AC_TYPE_INT8_T])
629 AN_IDENTIFIER([int16_t], [AC_TYPE_INT16_T])
630 AN_IDENTIFIER([int32_t], [AC_TYPE_INT32_T])
631 AN_IDENTIFIER([int64_t], [AC_TYPE_INT64_T])
632 AN_IDENTIFIER([uint8_t], [AC_TYPE_UINT8_T])
633 AN_IDENTIFIER([uint16_t], [AC_TYPE_UINT16_T])
634 AN_IDENTIFIER([uint32_t], [AC_TYPE_UINT32_T])
635 AN_IDENTIFIER([uint64_t], [AC_TYPE_UINT64_T])
636 AC_DEFUN([AC_TYPE_INT8_T], [_AC_TYPE_INT(8)])
637 AC_DEFUN([AC_TYPE_INT16_T], [_AC_TYPE_INT(16)])
638 AC_DEFUN([AC_TYPE_INT32_T], [_AC_TYPE_INT(32)])
639 AC_DEFUN([AC_TYPE_INT64_T], [_AC_TYPE_INT(64)])
640 AC_DEFUN([AC_TYPE_UINT8_T], [_AC_TYPE_UNSIGNED_INT(8)])
641 AC_DEFUN([AC_TYPE_UINT16_T], [_AC_TYPE_UNSIGNED_INT(16)])
642 AC_DEFUN([AC_TYPE_UINT32_T], [_AC_TYPE_UNSIGNED_INT(32)])
643 AC_DEFUN([AC_TYPE_UINT64_T], [_AC_TYPE_UNSIGNED_INT(64)])
645 # _AC_TYPE_INT(NBITS)
646 # -------------------
647 AC_DEFUN([_AC_TYPE_INT],
649 AC_CACHE_CHECK([for int$1_t], [ac_cv_c_int$1_t],
651 for ac_type in 'int$1_t' 'int' 'long int' \
652 'long long int' 'short int' 'signed char'; do
654 [AC_LANG_BOOL_COMPILE_TRY(
655 [AC_INCLUDES_DEFAULT],
656 [[0 < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)]])],
658 [AC_LANG_BOOL_COMPILE_TRY(
659 [AC_INCLUDES_DEFAULT],
660 [[($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)
661 < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 2)]])],
663 [AS_CASE([$ac_type], [int$1_t],
664 [ac_cv_c_int$1_t=yes],
665 [ac_cv_c_int$1_t=$ac_type])])])
666 test "$ac_cv_c_int$1_t" != no && break
668 case $ac_cv_c_int$1_t in #(
671 AC_DEFINE_UNQUOTED([int$1_t], [$ac_cv_c_int$1_t],
672 [Define to the type of a signed integer type of width exactly $1 bits
673 if such a type exists and the standard includes do not define it.]);;
677 # _AC_TYPE_UNSIGNED_INT(NBITS)
678 # ----------------------------
679 AC_DEFUN([_AC_TYPE_UNSIGNED_INT],
681 AC_CACHE_CHECK([for uint$1_t], [ac_cv_c_uint$1_t],
683 for ac_type in 'uint$1_t' 'unsigned int' 'unsigned long int' \
684 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
686 [AC_LANG_BOOL_COMPILE_TRY(
687 [AC_INCLUDES_DEFAULT],
688 [[($ac_type) -1 >> ($1 - 1) == 1]])],
689 [AS_CASE([$ac_type], [uint$1_t],
690 [ac_cv_c_uint$1_t=yes],
691 [ac_cv_c_uint$1_t=$ac_type])])
692 test "$ac_cv_c_uint$1_t" != no && break
694 case $ac_cv_c_uint$1_t in #(
697 m4_bmatch([$1], [^\(8\|32\|64\)$],
698 [AC_DEFINE([_UINT$1_T], 1,
699 [Define for Solaris 2.5.1 so the uint$1_t typedef from
700 <sys/synch.h>, <pthread.h>, or <semaphore.h> is not used.
701 If the typedef were allowed, the #define below would cause a
703 AC_DEFINE_UNQUOTED([uint$1_t], [$ac_cv_c_uint$1_t],
704 [Define to the type of an unsigned integer type of width exactly $1 bits
705 if such a type exists and the standard includes do not define it.]);;
707 ])# _AC_TYPE_UNSIGNED_INT
711 # Note that identifiers starting with SIG are reserved by ANSI C.
712 # C89 requires signal handlers to return void; only K&R returned int;
713 # modern code does not need to worry about using this macro (not to
714 # mention that sigaction is better than signal).
715 AU_DEFUN([AC_TYPE_SIGNAL],
716 [AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
718 [AC_LANG_PROGRAM([#include <sys/types.h>
721 [return *(signal (0, 0)) (0) == 1;])],
722 [ac_cv_type_signal=int],
723 [ac_cv_type_signal=void])])
724 AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal,
725 [Define as the return type of signal handlers
727 ], [your code may safely assume C89 semantics that RETSIGTYPE is void.
728 Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])
731 ## ------------------------ ##
732 ## Checking size of types. ##
733 ## ------------------------ ##
740 # AC_CHECK_SIZEOF(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
741 # ---------------------------------------------------------------
742 AC_DEFUN([AC_CHECK_SIZEOF],
743 [AS_LITERAL_IF([$1], [],
744 [m4_fatal([$0: requires literal arguments])])]dnl
745 [# The cast to long int works around a bug in the HP C Compiler
746 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
747 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
748 # This bug is HP SR number 8606223364.
749 _AC_CACHE_CHECK_INT([size of $1], [AS_TR_SH([ac_cv_sizeof_$1])],
750 [(long int) (sizeof ($1))],
751 [AC_INCLUDES_DEFAULT([$3])],
752 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
753 AC_MSG_FAILURE([cannot compute sizeof ($1)], 77)
755 AS_TR_SH([ac_cv_sizeof_$1])=0
758 AC_DEFINE_UNQUOTED(AS_TR_CPP(sizeof_$1), $AS_TR_SH([ac_cv_sizeof_$1]),
759 [The size of `$1', as computed by sizeof.])
763 # AC_CHECK_ALIGNOF(TYPE, [INCLUDES = DEFAULT-INCLUDES])
764 # -----------------------------------------------------
765 AC_DEFUN([AC_CHECK_ALIGNOF],
766 [AS_LITERAL_IF([$1], [],
767 [m4_fatal([$0: requires literal arguments])])]dnl
768 [# The cast to long int works around a bug in the HP C Compiler,
769 # see AC_CHECK_SIZEOF for more information.
770 _AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$1])],
771 [(long int) offsetof (ac__type_alignof_, y)],
772 [AC_INCLUDES_DEFAULT([$2])
774 # define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
776 typedef struct { char x; $1 y; } ac__type_alignof_;],
777 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
778 AC_MSG_FAILURE([cannot compute alignment of $1], 77)
780 AS_TR_SH([ac_cv_alignof_$1])=0
783 AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$1), $AS_TR_SH([ac_cv_alignof_$1]),
784 [The normal alignment of `$1', in bytes.])
790 # What a great name :)
791 AU_DEFUN([AC_INT_16_BITS],
792 [AC_CHECK_SIZEOF([int])
793 test $ac_cv_sizeof_int = 2 &&
794 AC_DEFINE(INT_16_BITS, 1,
795 [Define to 1 if `sizeof (int)' = 2. Obsolete, use `SIZEOF_INT'.])
796 ], [your code should no longer depend upon `INT_16_BITS', but upon
797 `SIZEOF_INT == 2'. Remove this warning and the `AC_DEFINE' when you
801 # AU::AC_LONG_64_BITS
802 # -------------------
803 AU_DEFUN([AC_LONG_64_BITS],
804 [AC_CHECK_SIZEOF([long int])
805 test $ac_cv_sizeof_long_int = 8 &&
806 AC_DEFINE(LONG_64_BITS, 1,
807 [Define to 1 if `sizeof (long int)' = 8. Obsolete, use
809 ], [your code should no longer depend upon `LONG_64_BITS', but upon
810 `SIZEOF_LONG_INT == 8'. Remove this warning and the `AC_DEFINE' when
811 you adjust the code.])
815 ## -------------------------- ##
816 ## Generic structure checks. ##
817 ## -------------------------- ##
824 # _AC_CHECK_MEMBER_BODY
825 # ---------------------
826 # Shell function body for AC_CHECK_MEMBER.
827 m4_define([_AC_CHECK_MEMBER_BODY],
828 [ AS_LINENO_PUSH([$[]1])
829 AC_CACHE_CHECK([for $[]2.$[]3], [$[]4],
830 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]5],
831 [static $[]2 ac_aggr;
834 [AS_VAR_SET([$[]4], [yes])],
835 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]5],
836 [static $[]2 ac_aggr;
837 if (sizeof ac_aggr.$[]3)
839 [AS_VAR_SET([$[]4], [yes])],
840 [AS_VAR_SET([$[]4], [no])])])])
844 # AC_CHECK_MEMBER(AGGREGATE.MEMBER,
845 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
846 # [INCLUDES = DEFAULT-INCLUDES])
847 # ---------------------------------------------------------
848 # AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
849 # variables are not a valid argument.
850 AC_DEFUN([AC_CHECK_MEMBER],
851 [AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_member],
852 [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_member],
853 [LINENO AGGR MEMBER VAR INCLUDES],
854 [Tries to find if the field MEMBER exists in type AGGR, after including
855 INCLUDES, setting cache variable VAR accordingly.])],
857 [AS_LITERAL_IF([$1], [], [m4_fatal([$0: requires literal arguments])])]dnl
858 [m4_if(m4_index([$1], [.]), -1, [m4_fatal([$0: Did not see any dot in `$1'])])]dnl
859 [AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])]dnl
860 [ac_func_[]_AC_LANG_ABBREV[]_check_member "$LINENO" ]dnl
861 [m4_bpatsubst([$1], [^\([^.]*\)\.\(.*\)], ["\1" "\2"]) "ac_Member" ]dnl
862 ["AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])"
863 AS_VAR_IF([ac_Member], [yes], [$2], [$3])
864 AS_VAR_POPDEF([ac_Member])dnl
868 # AC_CHECK_MEMBERS([AGGREGATE.MEMBER, ...],
869 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]
870 # [INCLUDES = DEFAULT-INCLUDES])
871 # ---------------------------------------------------------
872 # The first argument is an m4 list.
873 AC_DEFUN([AC_CHECK_MEMBERS],
874 [m4_foreach([AC_Member], [$1],
875 [AC_CHECK_MEMBER(AC_Member,
876 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Member), 1,
877 [Define to 1 if `]m4_bpatsubst(AC_Member,
879 member of `]m4_bpatsubst(AC_Member, [\..*])['.])
886 # ------------------------------------------------------- #
887 # Members that ought to be tested with AC_CHECK_MEMBERS. #
888 # ------------------------------------------------------- #
890 AN_IDENTIFIER([st_blksize], [AC_CHECK_MEMBERS([struct stat.st_blksize])])
891 AN_IDENTIFIER([st_rdev], [AC_CHECK_MEMBERS([struct stat.st_rdev])])
894 # Alphabetic order, please.
896 # _AC_STRUCT_DIRENT(MEMBER)
897 # -------------------------
898 AC_DEFUN([_AC_STRUCT_DIRENT],
900 AC_REQUIRE([AC_HEADER_DIRENT])
901 AC_CHECK_MEMBERS([struct dirent.$1], [], [],
903 #include <sys/types.h>
907 # define dirent direct
908 # ifdef HAVE_SYS_NDIR_H
909 # include <sys/ndir.h>
911 # ifdef HAVE_SYS_DIR_H
912 # include <sys/dir.h>
921 # AC_STRUCT_DIRENT_D_INO
922 # -----------------------------------
923 AC_DEFUN([AC_STRUCT_DIRENT_D_INO], [_AC_STRUCT_DIRENT([d_ino])])
925 # AC_STRUCT_DIRENT_D_TYPE
926 # ------------------------------------
927 AC_DEFUN([AC_STRUCT_DIRENT_D_TYPE], [_AC_STRUCT_DIRENT([d_type])])
930 # AC_STRUCT_ST_BLKSIZE
931 # --------------------
932 AU_DEFUN([AC_STRUCT_ST_BLKSIZE],
933 [AC_CHECK_MEMBERS([struct stat.st_blksize],
934 [AC_DEFINE(HAVE_ST_BLKSIZE, 1,
935 [Define to 1 if your `struct stat' has
936 `st_blksize'. Deprecated, use
937 `HAVE_STRUCT_STAT_ST_BLKSIZE' instead.])])
938 ], [your code should no longer depend upon `HAVE_ST_BLKSIZE', but
939 `HAVE_STRUCT_STAT_ST_BLKSIZE'. Remove this warning and
940 the `AC_DEFINE' when you adjust the code.])# AC_STRUCT_ST_BLKSIZE
943 # AC_STRUCT_ST_BLOCKS
944 # -------------------
945 # If `struct stat' contains an `st_blocks' member, define
946 # HAVE_STRUCT_STAT_ST_BLOCKS. Otherwise, add `fileblocks.o' to the
947 # output variable LIBOBJS. We still define HAVE_ST_BLOCKS for backward
948 # compatibility. In the future, we will activate specializations for
949 # this macro, so don't obsolete it right now.
951 # AC_OBSOLETE([$0], [; replace it with
952 # AC_CHECK_MEMBERS([struct stat.st_blocks],
953 # [AC_LIBOBJ([fileblocks])])
954 # Please note that it will define `HAVE_STRUCT_STAT_ST_BLOCKS',
955 # and not `HAVE_ST_BLOCKS'.])dnl
957 AN_IDENTIFIER([st_blocks], [AC_STRUCT_ST_BLOCKS])
958 AC_DEFUN([AC_STRUCT_ST_BLOCKS],
959 [AC_CHECK_MEMBERS([struct stat.st_blocks],
960 [AC_DEFINE(HAVE_ST_BLOCKS, 1,
961 [Define to 1 if your `struct stat' has
962 `st_blocks'. Deprecated, use
963 `HAVE_STRUCT_STAT_ST_BLOCKS' instead.])],
964 [AC_LIBOBJ([fileblocks])])
965 ])# AC_STRUCT_ST_BLOCKS
970 AU_DEFUN([AC_STRUCT_ST_RDEV],
971 [AC_CHECK_MEMBERS([struct stat.st_rdev],
972 [AC_DEFINE(HAVE_ST_RDEV, 1,
973 [Define to 1 if your `struct stat' has `st_rdev'.
974 Deprecated, use `HAVE_STRUCT_STAT_ST_RDEV'
976 ], [your code should no longer depend upon `HAVE_ST_RDEV', but
977 `HAVE_STRUCT_STAT_ST_RDEV'. Remove this warning and
978 the `AC_DEFINE' when you adjust the code.])# AC_STRUCT_ST_RDEV
983 # FIXME: This macro is badly named, it should be AC_CHECK_TYPE_STRUCT_TM.
984 # Or something else, but what? AC_CHECK_TYPE_STRUCT_TM_IN_SYS_TIME?
985 AC_DEFUN([AC_STRUCT_TM],
986 [AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
988 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
994 [ac_cv_struct_tm=time.h],
995 [ac_cv_struct_tm=sys/time.h])])
996 if test $ac_cv_struct_tm = sys/time.h; then
997 AC_DEFINE(TM_IN_SYS_TIME, 1,
998 [Define to 1 if your <sys/time.h> declares `struct tm'.])
1003 # AC_STRUCT_TIMEZONE
1004 # ------------------
1005 # Figure out how to get the current timezone. If `struct tm' has a
1006 # `tm_zone' member, define `HAVE_TM_ZONE'. Otherwise, if the
1007 # external array `tzname' is found, define `HAVE_TZNAME'.
1008 AN_IDENTIFIER([tm_zone], [AC_STRUCT_TIMEZONE])
1009 AC_DEFUN([AC_STRUCT_TIMEZONE],
1010 [AC_REQUIRE([AC_STRUCT_TM])dnl
1011 AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
1012 #include <$ac_cv_struct_tm>
1014 if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
1015 AC_DEFINE(HAVE_TM_ZONE, 1,
1016 [Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
1017 `HAVE_STRUCT_TM_TM_ZONE' instead.])
1019 AC_CHECK_DECLS([tzname], , , [#include <time.h>])
1020 AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
1021 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
1023 #if !HAVE_DECL_TZNAME
1024 extern char *tzname[];
1027 [[return tzname[0][0];]])],
1028 [ac_cv_var_tzname=yes],
1029 [ac_cv_var_tzname=no])])
1030 if test $ac_cv_var_tzname = yes; then
1031 AC_DEFINE(HAVE_TZNAME, 1,
1032 [Define to 1 if you don't have `tm_zone' but do have the external
1036 ])# AC_STRUCT_TIMEZONE