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)])
647 # Shell function body for _AC_TYPE_INT.
648 m4_define([_AC_TYPE_INT_BODY],
649 [ AS_LINENO_PUSH([$[]1])
650 AC_CACHE_CHECK([for int$[]2${ac_nonexistent_var}_t], [$[]3],
651 [AS_VAR_SET([$[]3], [no])
652 for ac_type in int$[]2""_t 'int' 'long int' \
653 'long long int' 'short int' 'signed char'; do
655 [AC_LANG_BOOL_COMPILE_TRY(
656 [AC_INCLUDES_DEFAULT],
657 [0 < ($ac_type) (((($ac_type) 1 << ($[]2 - 2)) - 1) * 2 + 1)])],
659 [AC_LANG_BOOL_COMPILE_TRY(
660 [AC_INCLUDES_DEFAULT],
661 [($ac_type) (((($ac_type) 1 << ($[]2 - 2)) - 1) * 2 + 1)
662 < ($ac_type) (((($ac_type) 1 << ($[]2 - 2)) - 1) * 2 + 2)])],
664 [AS_CASE([$ac_type], [int$[]2""_t],
665 [AS_VAR_SET([$[]3], [yes])],
666 [AS_VAR_SET([$[]3], [$ac_type])])])])
667 AS_VAR_IF([$[]3], [no], [], [break])
670 ])# _AC_TYPE_INT_BODY
672 # _AC_TYPE_INT(NBITS)
673 # -------------------
674 # Set a variable ac_cv_c_intNBITS_t to `yes' if intNBITS_t is available,
675 # `no' if it is not and no replacement types could be found, and a C type
676 # if it is not available but a replacement signed integer type of width
677 # exactly NBITS bits was found. In the third case, intNBITS_t is AC_DEFINEd
679 AC_DEFUN([_AC_TYPE_INT],
680 [AC_REQUIRE_SHELL_FN([ac_func_c_find_intX_t],
681 [AS_FUNCTION_DESCRIBE([ac_func_c_find_intX_t], [LINENO BITS VAR],
682 [Finds a signed integer type with width BITS, setting cache variable VAR
685 [ac_func_c_find_intX_t "$LINENO" "$1" "ac_cv_c_int$1_t"
686 case $ac_cv_c_int$1_t in #(
689 AC_DEFINE_UNQUOTED([int$1_t], [$ac_cv_c_int$1_t],
690 [Define to the type of a signed integer type of width exactly $1 bits
691 if such a type exists and the standard includes do not define it.]);;
695 # _AC_TYPE_UNSIGNED_INT_BODY
696 # --------------------------
697 # Shell function body for _AC_TYPE_UNSIGNED_INT.
698 m4_define([_AC_TYPE_UNSIGNED_INT_BODY],
699 [ AS_LINENO_PUSH([$[]1])
700 AC_CACHE_CHECK([for uint$[]2${ac_nonexistent_var}_t], $[]3,
701 [AS_VAR_SET([$[]3], [no])
702 for ac_type in uint$[]2""_t 'unsigned int' 'unsigned long int' \
703 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
705 [AC_LANG_BOOL_COMPILE_TRY(
706 [AC_INCLUDES_DEFAULT],
707 [($ac_type) -1 >> ($[]2 - 1) == 1])],
708 [AS_CASE([$ac_type], [uint$[]2""_t],
709 [AS_VAR_SET([$[]3], [yes])],
710 [AS_VAR_SET([$[]3], [$ac_type])])])
711 AS_VAR_IF([$[]3], [no], [], [break])
714 ])# _AC_TYPE_UNSIGNED_INT_BODY
717 # _AC_TYPE_UNSIGNED_INT(NBITS)
718 # ----------------------------
719 # Set a variable ac_cv_c_uintNBITS_t to `yes' if uintNBITS_t is available,
720 # `no' if it is not and no replacement types could be found, and a C type
721 # if it is not available but a replacement unsigned integer type of width
722 # exactly NBITS bits was found. In the third case, uintNBITS_t is AC_DEFINEd
724 AC_DEFUN([_AC_TYPE_UNSIGNED_INT],
725 [AC_REQUIRE_SHELL_FN([ac_func_c_find_uintX_t],
726 [AS_FUNCTION_DESCRIBE([ac_func_c_find_uintX_t], [LINENO BITS VAR],
727 [Finds an unsigned integer type with width BITS, setting cache variable VAR
730 [ac_func_c_find_uintX_t "$LINENO" "$1" "ac_cv_c_uint$1_t"
731 case $ac_cv_c_uint$1_t in #(
734 m4_bmatch([$1], [^\(8\|32\|64\)$],
735 [AC_DEFINE([_UINT$1_T], 1,
736 [Define for Solaris 2.5.1 so the uint$1_t typedef from
737 <sys/synch.h>, <pthread.h>, or <semaphore.h> is not used.
738 If the typedef were allowed, the #define below would cause a
740 AC_DEFINE_UNQUOTED([uint$1_t], [$ac_cv_c_uint$1_t],
741 [Define to the type of an unsigned integer type of width exactly $1 bits
742 if such a type exists and the standard includes do not define it.]);;
744 ])# _AC_TYPE_UNSIGNED_INT
748 # Note that identifiers starting with SIG are reserved by ANSI C.
749 # C89 requires signal handlers to return void; only K&R returned int;
750 # modern code does not need to worry about using this macro (not to
751 # mention that sigaction is better than signal).
752 AU_DEFUN([AC_TYPE_SIGNAL],
753 [AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
755 [AC_LANG_PROGRAM([#include <sys/types.h>
758 [return *(signal (0, 0)) (0) == 1;])],
759 [ac_cv_type_signal=int],
760 [ac_cv_type_signal=void])])
761 AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal,
762 [Define as the return type of signal handlers
764 ], [your code may safely assume C89 semantics that RETSIGTYPE is void.
765 Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])
768 ## ------------------------ ##
769 ## Checking size of types. ##
770 ## ------------------------ ##
777 # AC_CHECK_SIZEOF(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
778 # ---------------------------------------------------------------
779 AC_DEFUN([AC_CHECK_SIZEOF],
780 [AS_LITERAL_IF([$1], [],
781 [m4_fatal([$0: requires literal arguments])])]dnl
782 [# The cast to long int works around a bug in the HP C Compiler
783 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
784 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
785 # This bug is HP SR number 8606223364.
786 _AC_CACHE_CHECK_INT([size of $1], [AS_TR_SH([ac_cv_sizeof_$1])],
787 [(long int) (sizeof ($1))],
788 [AC_INCLUDES_DEFAULT([$3])],
789 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
790 AC_MSG_FAILURE([cannot compute sizeof ($1)], 77)
792 AS_TR_SH([ac_cv_sizeof_$1])=0
795 AC_DEFINE_UNQUOTED(AS_TR_CPP(sizeof_$1), $AS_TR_SH([ac_cv_sizeof_$1]),
796 [The size of `$1', as computed by sizeof.])
800 # AC_CHECK_ALIGNOF(TYPE, [INCLUDES = DEFAULT-INCLUDES])
801 # -----------------------------------------------------
802 AC_DEFUN([AC_CHECK_ALIGNOF],
803 [AS_LITERAL_IF([$1], [],
804 [m4_fatal([$0: requires literal arguments])])]dnl
805 [# The cast to long int works around a bug in the HP C Compiler,
806 # see AC_CHECK_SIZEOF for more information.
807 _AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$1])],
808 [(long int) offsetof (ac__type_alignof_, y)],
809 [AC_INCLUDES_DEFAULT([$2])
811 # define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
813 typedef struct { char x; $1 y; } ac__type_alignof_;],
814 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
815 AC_MSG_FAILURE([cannot compute alignment of $1], 77)
817 AS_TR_SH([ac_cv_alignof_$1])=0
820 AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$1), $AS_TR_SH([ac_cv_alignof_$1]),
821 [The normal alignment of `$1', in bytes.])
827 # What a great name :)
828 AU_DEFUN([AC_INT_16_BITS],
829 [AC_CHECK_SIZEOF([int])
830 test $ac_cv_sizeof_int = 2 &&
831 AC_DEFINE(INT_16_BITS, 1,
832 [Define to 1 if `sizeof (int)' = 2. Obsolete, use `SIZEOF_INT'.])
833 ], [your code should no longer depend upon `INT_16_BITS', but upon
834 `SIZEOF_INT == 2'. Remove this warning and the `AC_DEFINE' when you
838 # AU::AC_LONG_64_BITS
839 # -------------------
840 AU_DEFUN([AC_LONG_64_BITS],
841 [AC_CHECK_SIZEOF([long int])
842 test $ac_cv_sizeof_long_int = 8 &&
843 AC_DEFINE(LONG_64_BITS, 1,
844 [Define to 1 if `sizeof (long int)' = 8. Obsolete, use
846 ], [your code should no longer depend upon `LONG_64_BITS', but upon
847 `SIZEOF_LONG_INT == 8'. Remove this warning and the `AC_DEFINE' when
848 you adjust the code.])
852 ## -------------------------- ##
853 ## Generic structure checks. ##
854 ## -------------------------- ##
861 # _AC_CHECK_MEMBER_BODY
862 # ---------------------
863 # Shell function body for AC_CHECK_MEMBER.
864 m4_define([_AC_CHECK_MEMBER_BODY],
865 [ AS_LINENO_PUSH([$[]1])
866 AC_CACHE_CHECK([for $[]2.$[]3], [$[]4],
867 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]5],
868 [static $[]2 ac_aggr;
871 [AS_VAR_SET([$[]4], [yes])],
872 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]5],
873 [static $[]2 ac_aggr;
874 if (sizeof ac_aggr.$[]3)
876 [AS_VAR_SET([$[]4], [yes])],
877 [AS_VAR_SET([$[]4], [no])])])])
881 # AC_CHECK_MEMBER(AGGREGATE.MEMBER,
882 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
883 # [INCLUDES = DEFAULT-INCLUDES])
884 # ---------------------------------------------------------
885 # AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
886 # variables are not a valid argument.
887 AC_DEFUN([AC_CHECK_MEMBER],
888 [AC_REQUIRE_SHELL_FN([ac_func_]_AC_LANG_ABBREV[_check_member],
889 [AS_FUNCTION_DESCRIBE([ac_func_]_AC_LANG_ABBREV[_check_member],
890 [LINENO AGGR MEMBER VAR INCLUDES],
891 [Tries to find if the field MEMBER exists in type AGGR, after including
892 INCLUDES, setting cache variable VAR accordingly.])],
894 [AS_LITERAL_IF([$1], [], [m4_fatal([$0: requires literal arguments])])]dnl
895 [m4_if(m4_index([$1], [.]), -1, [m4_fatal([$0: Did not see any dot in `$1'])])]dnl
896 [AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])]dnl
897 [ac_func_[]_AC_LANG_ABBREV[]_check_member "$LINENO" ]dnl
898 [m4_bpatsubst([$1], [^\([^.]*\)\.\(.*\)], ["\1" "\2"]) "ac_Member" ]dnl
899 ["AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])"
900 AS_VAR_IF([ac_Member], [yes], [$2], [$3])
901 AS_VAR_POPDEF([ac_Member])dnl
905 # AC_CHECK_MEMBERS([AGGREGATE.MEMBER, ...],
906 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]
907 # [INCLUDES = DEFAULT-INCLUDES])
908 # ---------------------------------------------------------
909 # The first argument is an m4 list.
910 AC_DEFUN([AC_CHECK_MEMBERS],
911 [m4_foreach([AC_Member], [$1],
912 [AC_CHECK_MEMBER(AC_Member,
913 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Member), 1,
914 [Define to 1 if `]m4_bpatsubst(AC_Member,
916 member of `]m4_bpatsubst(AC_Member, [\..*])['.])
923 # ------------------------------------------------------- #
924 # Members that ought to be tested with AC_CHECK_MEMBERS. #
925 # ------------------------------------------------------- #
927 AN_IDENTIFIER([st_blksize], [AC_CHECK_MEMBERS([struct stat.st_blksize])])
928 AN_IDENTIFIER([st_rdev], [AC_CHECK_MEMBERS([struct stat.st_rdev])])
931 # Alphabetic order, please.
933 # _AC_STRUCT_DIRENT(MEMBER)
934 # -------------------------
935 AC_DEFUN([_AC_STRUCT_DIRENT],
937 AC_REQUIRE([AC_HEADER_DIRENT])
938 AC_CHECK_MEMBERS([struct dirent.$1], [], [],
940 #include <sys/types.h>
944 # define dirent direct
945 # ifdef HAVE_SYS_NDIR_H
946 # include <sys/ndir.h>
948 # ifdef HAVE_SYS_DIR_H
949 # include <sys/dir.h>
958 # AC_STRUCT_DIRENT_D_INO
959 # -----------------------------------
960 AC_DEFUN([AC_STRUCT_DIRENT_D_INO], [_AC_STRUCT_DIRENT([d_ino])])
962 # AC_STRUCT_DIRENT_D_TYPE
963 # ------------------------------------
964 AC_DEFUN([AC_STRUCT_DIRENT_D_TYPE], [_AC_STRUCT_DIRENT([d_type])])
967 # AC_STRUCT_ST_BLKSIZE
968 # --------------------
969 AU_DEFUN([AC_STRUCT_ST_BLKSIZE],
970 [AC_CHECK_MEMBERS([struct stat.st_blksize],
971 [AC_DEFINE(HAVE_ST_BLKSIZE, 1,
972 [Define to 1 if your `struct stat' has
973 `st_blksize'. Deprecated, use
974 `HAVE_STRUCT_STAT_ST_BLKSIZE' instead.])])
975 ], [your code should no longer depend upon `HAVE_ST_BLKSIZE', but
976 `HAVE_STRUCT_STAT_ST_BLKSIZE'. Remove this warning and
977 the `AC_DEFINE' when you adjust the code.])# AC_STRUCT_ST_BLKSIZE
980 # AC_STRUCT_ST_BLOCKS
981 # -------------------
982 # If `struct stat' contains an `st_blocks' member, define
983 # HAVE_STRUCT_STAT_ST_BLOCKS. Otherwise, add `fileblocks.o' to the
984 # output variable LIBOBJS. We still define HAVE_ST_BLOCKS for backward
985 # compatibility. In the future, we will activate specializations for
986 # this macro, so don't obsolete it right now.
988 # AC_OBSOLETE([$0], [; replace it with
989 # AC_CHECK_MEMBERS([struct stat.st_blocks],
990 # [AC_LIBOBJ([fileblocks])])
991 # Please note that it will define `HAVE_STRUCT_STAT_ST_BLOCKS',
992 # and not `HAVE_ST_BLOCKS'.])dnl
994 AN_IDENTIFIER([st_blocks], [AC_STRUCT_ST_BLOCKS])
995 AC_DEFUN([AC_STRUCT_ST_BLOCKS],
996 [AC_CHECK_MEMBERS([struct stat.st_blocks],
997 [AC_DEFINE(HAVE_ST_BLOCKS, 1,
998 [Define to 1 if your `struct stat' has
999 `st_blocks'. Deprecated, use
1000 `HAVE_STRUCT_STAT_ST_BLOCKS' instead.])],
1001 [AC_LIBOBJ([fileblocks])])
1002 ])# AC_STRUCT_ST_BLOCKS
1007 AU_DEFUN([AC_STRUCT_ST_RDEV],
1008 [AC_CHECK_MEMBERS([struct stat.st_rdev],
1009 [AC_DEFINE(HAVE_ST_RDEV, 1,
1010 [Define to 1 if your `struct stat' has `st_rdev'.
1011 Deprecated, use `HAVE_STRUCT_STAT_ST_RDEV'
1013 ], [your code should no longer depend upon `HAVE_ST_RDEV', but
1014 `HAVE_STRUCT_STAT_ST_RDEV'. Remove this warning and
1015 the `AC_DEFINE' when you adjust the code.])# AC_STRUCT_ST_RDEV
1020 # FIXME: This macro is badly named, it should be AC_CHECK_TYPE_STRUCT_TM.
1021 # Or something else, but what? AC_CHECK_TYPE_STRUCT_TM_IN_SYS_TIME?
1022 AC_DEFUN([AC_STRUCT_TM],
1023 [AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
1025 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
1029 int *p = &tm.tm_sec;
1031 [ac_cv_struct_tm=time.h],
1032 [ac_cv_struct_tm=sys/time.h])])
1033 if test $ac_cv_struct_tm = sys/time.h; then
1034 AC_DEFINE(TM_IN_SYS_TIME, 1,
1035 [Define to 1 if your <sys/time.h> declares `struct tm'.])
1040 # AC_STRUCT_TIMEZONE
1041 # ------------------
1042 # Figure out how to get the current timezone. If `struct tm' has a
1043 # `tm_zone' member, define `HAVE_TM_ZONE'. Otherwise, if the
1044 # external array `tzname' is found, define `HAVE_TZNAME'.
1045 AN_IDENTIFIER([tm_zone], [AC_STRUCT_TIMEZONE])
1046 AC_DEFUN([AC_STRUCT_TIMEZONE],
1047 [AC_REQUIRE([AC_STRUCT_TM])dnl
1048 AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
1049 #include <$ac_cv_struct_tm>
1051 if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
1052 AC_DEFINE(HAVE_TM_ZONE, 1,
1053 [Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
1054 `HAVE_STRUCT_TM_TM_ZONE' instead.])
1056 AC_CHECK_DECLS([tzname], , , [#include <time.h>])
1057 AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
1058 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
1060 #if !HAVE_DECL_TZNAME
1061 extern char *tzname[];
1064 [[return tzname[0][0];]])],
1065 [ac_cv_var_tzname=yes],
1066 [ac_cv_var_tzname=no])])
1067 if test $ac_cv_var_tzname = yes; then
1068 AC_DEFINE(HAVE_TZNAME, 1,
1069 [Define to 1 if you don't have `tm_zone' but do have the external
1073 ])# AC_STRUCT_TIMEZONE