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 Free Software
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
80 # _AC_CHECK_TYPE_NEW(TYPE,
81 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
82 # [INCLUDES = DEFAULT-INCLUDES])
83 # ------------------------------------------------------------
84 # Check whether the type TYPE is supported by the system, maybe via the
85 # the provided includes. This macro implements the former task of
86 # AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was
87 # grepping in the headers, which, BTW, led to many problems until the
88 # extended regular expression was correct and did not given false positives.
89 # It turned out there are even portability issues with egrep...
91 # The most obvious way to check for a TYPE is just to compile a variable
96 # Unfortunately this does not work for const qualified types in C++,
97 # where you need an initializer. So you think of
99 # TYPE my_var = (TYPE) 0;
101 # Unfortunately, again, this is not valid for some C++ classes.
103 # Then you look for another scheme. For instance you think of declaring
104 # a function which uses a parameter of type TYPE:
106 # int foo (TYPE param);
108 # but of course you soon realize this does not make it with K&R
109 # compilers. And by no ways you want to
115 # since this time it's C++ who is not happy.
117 # Don't even think of the return type of a function, since K&R cries
118 # there too. So you start thinking of declaring a *pointer* to this TYPE:
122 # but you know fairly well that this is legal in C for aggregates which
123 # are unknown (TYPE = struct does-not-exist).
125 # Then you think of using sizeof to make sure the TYPE is really
130 # But this succeeds if TYPE is a variable: you get the size of the
133 # This time you tell yourself the last two options *together* will make
134 # it. And indeed this is the solution invented by Alexandre Oliva.
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.). Equally, instead of defining an unused
142 # variable, we just use a cast to avoid warnings from the compiler.
143 # Suggested by Paul Eggert.
145 # Now, the next issue is that C++ disallows defining types inside casts
146 # and inside `sizeof()', but we would like to allow unnamed structs, for
147 # use inside AC_CHECK_SIZEOF, for example. So we create a typedef of the
148 # new type. Note that this does not obviate the need for the other
149 # constructs in general.
150 m4_define([_AC_CHECK_TYPE_NEW],
151 [AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
152 AC_CACHE_CHECK([for $1], ac_Type,
153 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])
154 typedef $1 ac__type_new_;],
155 [if ((ac__type_new_ *) 0)
157 if (sizeof (ac__type_new_))
159 [AS_VAR_SET(ac_Type, yes)],
160 [AS_VAR_SET(ac_Type, no)])])
161 AS_IF([test AS_VAR_GET(ac_Type) = yes], [$2], [$3])[]dnl
162 AS_VAR_POPDEF([ac_Type])dnl
163 ])# _AC_CHECK_TYPE_NEW
166 # AC_CHECK_TYPES(TYPES,
167 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
168 # [INCLUDES = DEFAULT-INCLUDES])
169 # --------------------------------------------------------
170 # TYPES is an m4 list. There are no ambiguities here, we mean the newer
172 AC_DEFUN([AC_CHECK_TYPES],
173 [m4_foreach([AC_Type], [$1],
174 [_AC_CHECK_TYPE_NEW(AC_Type,
175 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Type), 1,
176 [Define to 1 if the system has the
183 # _AC_CHECK_TYPE_OLD(TYPE, DEFAULT)
184 # ---------------------------------
185 # FIXME: This is an extremely badly chosen name, since this
186 # macro actually performs an AC_REPLACE_TYPE. Some day we
187 # have to clean this up.
188 m4_define([_AC_CHECK_TYPE_OLD],
189 [_AC_CHECK_TYPE_NEW([$1],,
190 [AC_DEFINE_UNQUOTED([$1], [$2],
191 [Define to `$2' if <sys/types.h> does not define.])])dnl
192 ])# _AC_CHECK_TYPE_OLD
195 # _AC_CHECK_TYPE_REPLACEMENT_TYPE_P(STRING)
196 # -----------------------------------------
197 # Return `1' if STRING seems to be a builtin C/C++ type, i.e., if it
198 # starts with `_Bool', `bool', `char', `double', `float', `int',
199 # `long', `short', `signed', or `unsigned' followed by characters
200 # that are defining types.
201 # Because many people have used `off_t' and `size_t' too, they are added
202 # for better common-useward backward compatibility.
203 m4_define([_AC_CHECK_TYPE_REPLACEMENT_TYPE_P],
205 [^\(_Bool\|bool\|char\|double\|float\|int\|long\|short\|\(un\)?signed\|[_a-zA-Z][_a-zA-Z0-9]*_t\)[][_a-zA-Z0-9() *]*$],
207 ])# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P
210 # _AC_CHECK_TYPE_MAYBE_TYPE_P(STRING)
211 # -----------------------------------
212 # Return `1' if STRING looks like a C/C++ type.
213 m4_define([_AC_CHECK_TYPE_MAYBE_TYPE_P],
214 [m4_bmatch([$1], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$],
216 ])# _AC_CHECK_TYPE_MAYBE_TYPE_P
219 # AC_CHECK_TYPE(TYPE, DEFAULT)
221 # AC_CHECK_TYPE(TYPE,
222 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
223 # [INCLUDES = DEFAULT-INCLUDES])
224 # -------------------------------------------------------
226 # Dispatch respectively to _AC_CHECK_TYPE_OLD or _AC_CHECK_TYPE_NEW.
227 # 1. More than two arguments => NEW
228 # 2. $2 seems to be replacement type => OLD
229 # See _AC_CHECK_TYPE_REPLACEMENT_TYPE_P for `replacement type'.
230 # 3. $2 seems to be a type => NEW plus a warning
232 AC_DEFUN([AC_CHECK_TYPE],
234 [_AC_CHECK_TYPE_NEW($@)],
236 [_AC_CHECK_TYPE_NEW($@)],
237 _AC_CHECK_TYPE_REPLACEMENT_TYPE_P([$2]), 1,
238 [_AC_CHECK_TYPE_OLD($@)],
239 _AC_CHECK_TYPE_MAYBE_TYPE_P([$2]), 1,
240 [AC_DIAGNOSE([syntax],
241 [$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)],
242 [_AC_CHECK_TYPE_NEW($@)])[]dnl
247 # ---------------------------- #
248 # Types that must be checked. #
249 # ---------------------------- #
251 AN_IDENTIFIER([ptrdiff_t], [AC_CHECK_TYPES])
254 # ----------------- #
256 # ----------------- #
260 AC_DEFUN([AC_TYPE_GETGROUPS],
261 [AC_REQUIRE([AC_TYPE_UID_T])dnl
262 AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
263 [AC_RUN_IFELSE([AC_LANG_SOURCE(
264 [[/* Thanks to Mike Rendell for this test. */
265 ]AC_INCLUDES_DEFAULT[
268 #define MAX(x, y) ((x) > (y) ? (x) : (y))
275 union { gid_t gval; long int lval; } val;
278 for (i = 0; i < NGID; i++)
279 gidset[i] = val.gval;
280 n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
282 /* Exit non-zero if getgroups seems to require an array of ints. This
283 happens when gid_t is short int but getgroups modifies an array
285 return n > 0 && gidset[n] != val.gval;
287 [ac_cv_type_getgroups=gid_t],
288 [ac_cv_type_getgroups=int],
289 [ac_cv_type_getgroups=cross])
290 if test $ac_cv_type_getgroups = cross; then
291 dnl When we can't run the test program (we are cross compiling), presume
292 dnl that <unistd.h> has either an accurate prototype for getgroups or none.
293 dnl Old systems without prototypes probably use int.
294 AC_EGREP_HEADER([getgroups.*int.*gid_t], unistd.h,
295 ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int)
297 AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups,
298 [Define to the type of elements in the array set by
299 `getgroups'. Usually this is either `int' or `gid_t'.])
300 ])# AC_TYPE_GETGROUPS
303 # AU::AM_TYPE_PTRDIFF_T
304 # ---------------------
305 AU_DEFUN([AM_TYPE_PTRDIFF_T],
306 [AC_CHECK_TYPES(ptrdiff_t)])
311 AC_DEFUN([AC_TYPE_INTMAX_T],
313 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
314 AC_CHECK_TYPE([intmax_t],
315 [AC_DEFINE([HAVE_INTMAX_T], 1,
316 [Define to 1 if the system has the type `intmax_t'.])],
317 [test $ac_cv_type_long_long_int = yes \
318 && ac_type='long long int' \
319 || ac_type='long int'
320 AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
321 [Define to the widest signed integer type
322 if <stdint.h> and <inttypes.h> do not define.])])
328 AC_DEFUN([AC_TYPE_UINTMAX_T],
330 AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
331 AC_CHECK_TYPE([uintmax_t],
332 [AC_DEFINE([HAVE_UINTMAX_T], 1,
333 [Define to 1 if the system has the type `uintmax_t'.])],
334 [test $ac_cv_type_unsigned_long_long_int = yes \
335 && ac_type='unsigned long long int' \
336 || ac_type='unsigned long int'
337 AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
338 [Define to the widest unsigned integer type
339 if <stdint.h> and <inttypes.h> do not define.])])
345 AC_DEFUN([AC_TYPE_INTPTR_T],
347 AC_CHECK_TYPE([intptr_t],
348 [AC_DEFINE([HAVE_INTPTR_T], 1,
349 [Define to 1 if the system has the type `intptr_t'.])],
350 [for ac_type in 'int' 'long int' 'long long int'; do
352 [AC_LANG_BOOL_COMPILE_TRY(
353 [AC_INCLUDES_DEFAULT],
354 [[sizeof (void *) <= sizeof ($ac_type)]])],
355 [AC_DEFINE_UNQUOTED([intptr_t], [$ac_type],
356 [Define to the type of a signed integer type wide enough to
357 hold a pointer, if such a type exists, and if the system
358 does not define it.])
360 test -z "$ac_type" && break
367 AC_DEFUN([AC_TYPE_UINTPTR_T],
369 AC_CHECK_TYPE([uintptr_t],
370 [AC_DEFINE([HAVE_UINTPTR_T], 1,
371 [Define to 1 if the system has the type `uintptr_t'.])],
372 [for ac_type in 'unsigned int' 'unsigned long int' \
373 'unsigned long long int'; do
375 [AC_LANG_BOOL_COMPILE_TRY(
376 [AC_INCLUDES_DEFAULT],
377 [[sizeof (void *) <= sizeof ($ac_type)]])],
378 [AC_DEFINE_UNQUOTED([uintptr_t], [$ac_type],
379 [Define to the type of an unsigned integer type wide enough to
380 hold a pointer, if such a type exists, and if the system
381 does not define it.])
383 test -z "$ac_type" && break
388 # AC_TYPE_LONG_DOUBLE
389 # -------------------
390 AC_DEFUN([AC_TYPE_LONG_DOUBLE],
392 AC_CACHE_CHECK([for long double], [ac_cv_type_long_double],
393 [if test "$GCC" = yes; then
394 ac_cv_type_long_double=yes
397 [AC_LANG_BOOL_COMPILE_TRY(
398 [[/* The Stardent Vistra knows sizeof (long double), but does
400 long double foo = 0.0L;]],
401 [[/* On Ultrix 4.3 cc, long double is 4 and double is 8. */
402 sizeof (double) <= sizeof (long double)]])],
403 [ac_cv_type_long_double=yes],
404 [ac_cv_type_long_double=no])
406 if test $ac_cv_type_long_double = yes; then
407 AC_DEFINE([HAVE_LONG_DOUBLE], 1,
408 [Define to 1 if the system has the type `long double'.])
413 # AC_TYPE_LONG_DOUBLE_WIDER
414 # -------------------------
415 AC_DEFUN([AC_TYPE_LONG_DOUBLE_WIDER],
418 [for long double with more range or precision than double],
419 [ac_cv_type_long_double_wider],
421 [AC_LANG_BOOL_COMPILE_TRY(
423 long double const a[] =
425 0.0L, DBL_MIN, DBL_MAX, DBL_EPSILON,
426 LDBL_MIN, LDBL_MAX, LDBL_EPSILON
431 return ((x + (unsigned long int) 10) * (-1 / x) + a[0]
432 + (x ? f (x) : 'c'));
435 [[(0 < ((DBL_MAX_EXP < LDBL_MAX_EXP)
436 + (DBL_MANT_DIG < LDBL_MANT_DIG)
437 - (LDBL_MAX_EXP < DBL_MAX_EXP)
438 - (LDBL_MANT_DIG < DBL_MANT_DIG)))
439 && (int) LDBL_EPSILON == 0
441 ac_cv_type_long_double_wider=yes,
442 ac_cv_type_long_double_wider=no)])
443 if test $ac_cv_type_long_double_wider = yes; then
444 AC_DEFINE([HAVE_LONG_DOUBLE_WIDER], 1,
445 [Define to 1 if the type `long double' works and has more range or
446 precision than `double'.])
448 ])# AC_TYPE_LONG_DOUBLE_WIDER
453 AU_DEFUN([AC_C_LONG_DOUBLE],
455 AC_TYPE_LONG_DOUBLE_WIDER
456 ac_cv_c_long_double=$ac_cv_type_long_double_wider
457 if test $ac_cv_c_long_double = yes; then
458 AC_DEFINE([HAVE_LONG_DOUBLE], 1,
459 [Define to 1 if the type `long double' works and has more range or
460 precision than `double'.])
463 [The macro `AC_C_LONG_DOUBLE' is obsolete.
464 You should use `AC_TYPE_LONG_DOUBLE' or `AC_TYPE_LONG_DOUBLE_WIDER' instead.]
468 # AC_TYPE_LONG_LONG_INT
469 # ---------------------
470 AC_DEFUN([AC_TYPE_LONG_LONG_INT],
472 AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
475 [[long long int ll = 9223372036854775807ll;
476 long long int nll = -9223372036854775807LL;
477 typedef int a[((-9223372036854775807LL < 0
478 && 0 < 9223372036854775807ll)
481 [[long long int llmax = 9223372036854775807ll;
482 return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
483 | llmax / ll | llmax % ll);]])],
484 [ac_cv_type_long_long_int=yes],
485 [ac_cv_type_long_long_int=no])])
486 if test $ac_cv_type_long_long_int = yes; then
487 AC_DEFINE([HAVE_LONG_LONG_INT], 1,
488 [Define to 1 if the system has the type `long long int'.])
493 # AC_TYPE_UNSIGNED_LONG_LONG_INT
494 # ------------------------------
495 AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
497 AC_CACHE_CHECK([for unsigned long long int],
498 [ac_cv_type_unsigned_long_long_int],
501 [[unsigned long long int ull = 18446744073709551615ULL;
502 typedef int a[(18446744073709551615ULL <= (unsigned long long int) -1
505 [[unsigned long long int ullmax = 18446744073709551615ull;
506 return (ull << 63 | ull >> 63 | ull << i | ull >> i
507 | ullmax / ull | ullmax % ull);]])],
508 [ac_cv_type_unsigned_long_long_int=yes],
509 [ac_cv_type_unsigned_long_long_int=no])])
510 if test $ac_cv_type_unsigned_long_long_int = yes; then
511 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], 1,
512 [Define to 1 if the system has the type `unsigned long long int'.])
519 AC_DEFUN([AC_TYPE_MBSTATE_T],
520 [AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
524 # include <wchar.h>],
525 [mbstate_t x; return sizeof x;])],
526 [ac_cv_type_mbstate_t=yes],
527 [ac_cv_type_mbstate_t=no])])
528 if test $ac_cv_type_mbstate_t = yes; then
529 AC_DEFINE([HAVE_MBSTATE_T], 1,
530 [Define to 1 if <wchar.h> declares mbstate_t.])
532 AC_DEFINE([mbstate_t], int,
533 [Define to a type if <wchar.h> does not define.])
539 # FIXME: Rewrite using AC_CHECK_TYPE.
540 AN_IDENTIFIER([gid_t], [AC_TYPE_UID_T])
541 AN_IDENTIFIER([uid_t], [AC_TYPE_UID_T])
542 AC_DEFUN([AC_TYPE_UID_T],
543 [AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
544 [AC_EGREP_HEADER(uid_t, sys/types.h,
545 ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
546 if test $ac_cv_type_uid_t = no; then
547 AC_DEFINE(uid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
548 AC_DEFINE(gid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
553 AN_IDENTIFIER([size_t], [AC_TYPE_SIZE_T])
554 AC_DEFUN([AC_TYPE_SIZE_T], [AC_CHECK_TYPE(size_t, unsigned int)])
556 AN_IDENTIFIER([ssize_t], [AC_TYPE_SSIZE_T])
557 AC_DEFUN([AC_TYPE_SSIZE_T], [AC_CHECK_TYPE(ssize_t, int)])
559 AN_IDENTIFIER([pid_t], [AC_TYPE_PID_T])
560 AC_DEFUN([AC_TYPE_PID_T], [AC_CHECK_TYPE(pid_t, int)])
562 AN_IDENTIFIER([off_t], [AC_TYPE_OFF_T])
563 AC_DEFUN([AC_TYPE_OFF_T], [AC_CHECK_TYPE(off_t, long int)])
565 AN_IDENTIFIER([mode_t], [AC_TYPE_MODE_T])
566 AC_DEFUN([AC_TYPE_MODE_T], [AC_CHECK_TYPE(mode_t, int)])
568 AN_IDENTIFIER([int8_t], [AC_TYPE_INT8_T])
569 AN_IDENTIFIER([int16_t], [AC_TYPE_INT16_T])
570 AN_IDENTIFIER([int32_t], [AC_TYPE_INT32_T])
571 AN_IDENTIFIER([int64_t], [AC_TYPE_INT64_T])
572 AN_IDENTIFIER([uint8_t], [AC_TYPE_UINT8_T])
573 AN_IDENTIFIER([uint16_t], [AC_TYPE_UINT16_T])
574 AN_IDENTIFIER([uint32_t], [AC_TYPE_UINT32_T])
575 AN_IDENTIFIER([uint64_t], [AC_TYPE_UINT64_T])
576 AC_DEFUN([AC_TYPE_INT8_T], [_AC_TYPE_INT(8)])
577 AC_DEFUN([AC_TYPE_INT16_T], [_AC_TYPE_INT(16)])
578 AC_DEFUN([AC_TYPE_INT32_T], [_AC_TYPE_INT(32)])
579 AC_DEFUN([AC_TYPE_INT64_T], [_AC_TYPE_INT(64)])
580 AC_DEFUN([AC_TYPE_UINT8_T], [_AC_TYPE_UNSIGNED_INT(8)])
581 AC_DEFUN([AC_TYPE_UINT16_T], [_AC_TYPE_UNSIGNED_INT(16)])
582 AC_DEFUN([AC_TYPE_UINT32_T], [_AC_TYPE_UNSIGNED_INT(32)])
583 AC_DEFUN([AC_TYPE_UINT64_T], [_AC_TYPE_UNSIGNED_INT(64)])
585 # _AC_TYPE_INT(NBITS)
586 # -------------------
587 AC_DEFUN([_AC_TYPE_INT],
589 AC_CACHE_CHECK([for int$1_t], [ac_cv_c_int$1_t],
591 for ac_type in 'int$1_t' 'int' 'long int' \
592 'long long int' 'short int' 'signed char'; do
594 [AC_LANG_BOOL_COMPILE_TRY(
595 [AC_INCLUDES_DEFAULT],
596 [[0 < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)]])],
598 [AC_LANG_BOOL_COMPILE_TRY(
599 [AC_INCLUDES_DEFAULT],
600 [[($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)
601 < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 2)]])],
603 [AS_CASE([$ac_type], [int$1_t],
604 [ac_cv_c_int$1_t=yes],
605 [ac_cv_c_int$1_t=$ac_type])])])
606 test "$ac_cv_c_int$1_t" != no && break
608 case $ac_cv_c_int$1_t in #(
611 AC_DEFINE_UNQUOTED([int$1_t], [$ac_cv_c_int$1_t],
612 [Define to the type of a signed integer type of width exactly $1 bits
613 if such a type exists and the standard includes do not define it.]);;
617 # _AC_TYPE_UNSIGNED_INT(NBITS)
618 # ----------------------------
619 AC_DEFUN([_AC_TYPE_UNSIGNED_INT],
621 AC_CACHE_CHECK([for uint$1_t], [ac_cv_c_uint$1_t],
623 for ac_type in 'uint$1_t' 'unsigned int' 'unsigned long int' \
624 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
626 [AC_LANG_BOOL_COMPILE_TRY(
627 [AC_INCLUDES_DEFAULT],
628 [[($ac_type) -1 >> ($1 - 1) == 1]])],
629 [AS_CASE([$ac_type], [uint$1_t],
630 [ac_cv_c_uint$1_t=yes],
631 [ac_cv_c_uint$1_t=$ac_type])])
632 test "$ac_cv_c_uint$1_t" != no && break
634 case $ac_cv_c_uint$1_t in #(
637 m4_bmatch([$1], [^\(8\|32\|64\)$],
638 [AC_DEFINE([_UINT$1_T], 1,
639 [Define for Solaris 2.5.1 so the uint$1_t typedef from
640 <sys/synch.h>, <pthread.h>, or <semaphore.h> is not used.
641 If the typedef was allowed, the #define below would cause a
643 AC_DEFINE_UNQUOTED([uint$1_t], [$ac_cv_c_uint$1_t],
644 [Define to the type of an unsigned integer type of width exactly $1 bits
645 if such a type exists and the standard includes do not define it.]);;
647 ])# _AC_TYPE_UNSIGNED_INT
651 # Note that identifiers starting with SIG are reserved by ANSI C.
652 AN_FUNCTION([signal], [AC_TYPE_SIGNAL])
653 AC_DEFUN([AC_TYPE_SIGNAL],
654 [AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
656 [AC_LANG_PROGRAM([#include <sys/types.h>
659 [return *(signal (0, 0)) (0) == 1;])],
660 [ac_cv_type_signal=int],
661 [ac_cv_type_signal=void])])
662 AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal,
663 [Define as the return type of signal handlers
668 ## ------------------------ ##
669 ## Checking size of types. ##
670 ## ------------------------ ##
677 # AC_CHECK_SIZEOF(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
678 # ---------------------------------------------------------------
679 AC_DEFUN([AC_CHECK_SIZEOF],
680 [AS_LITERAL_IF([$1], [],
681 [AC_FATAL([$0: requires literal arguments])])dnl
682 AC_CHECK_TYPE([$1], [], [], [$3])
683 # The cast to long int works around a bug in the HP C Compiler
684 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
685 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
686 # This bug is HP SR number 8606223364.
687 AC_CACHE_CHECK_INT([size of $1], [AS_TR_SH([ac_cv_sizeof_$1])],
688 [(long int) (sizeof (ac__type_sizeof_))],
689 [AC_INCLUDES_DEFAULT([$3])
690 typedef $1 ac__type_sizeof_;],
691 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
692 AC_MSG_FAILURE([cannot compute sizeof ($1)], 77)
694 AS_TR_SH([ac_cv_sizeof_$1])=0
697 AC_DEFINE_UNQUOTED(AS_TR_CPP(sizeof_$1), $AS_TR_SH([ac_cv_sizeof_$1]),
698 [The size of `$1', as computed by sizeof.])
702 # AC_CHECK_ALIGNOF(TYPE, [INCLUDES = DEFAULT-INCLUDES])
703 # -----------------------------------------------------
704 AC_DEFUN([AC_CHECK_ALIGNOF],
705 [AS_LITERAL_IF([$1], [],
706 [AC_FATAL([$0: requires literal arguments])])dnl
707 AC_CHECK_TYPE([$1], [], [], [$2])
708 # The cast to long int works around a bug in the HP C Compiler,
709 # see AC_CHECK_SIZEOF for more information.
710 AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$1])],
711 [(long int) offsetof (ac__type_alignof_, y)],
712 [AC_INCLUDES_DEFAULT([$2])
714 # define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
716 typedef struct { char x; $1 y; } ac__type_alignof_;],
717 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
718 AC_MSG_FAILURE([cannot compute alignment of $1], 77)
720 AS_TR_SH([ac_cv_alignof_$1])=0
723 AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$1), $AS_TR_SH([ac_cv_alignof_$1]),
724 [The normal alignment of `$1', in bytes.])
730 # What a great name :)
731 AU_DEFUN([AC_INT_16_BITS],
732 [AC_CHECK_SIZEOF([int])
733 test $ac_cv_sizeof_int = 2 &&
734 AC_DEFINE(INT_16_BITS, 1,
735 [Define to 1 if `sizeof (int)' = 2. Obsolete, use `SIZEOF_INT'.])
736 ], [your code should no longer depend upon `INT_16_BITS', but upon
737 `SIZEOF_INT == 2'. Remove this warning and the `AC_DEFINE' when you
741 # AU::AC_LONG_64_BITS
742 # -------------------
743 AU_DEFUN([AC_LONG_64_BITS],
744 [AC_CHECK_SIZEOF([long int])
745 test $ac_cv_sizeof_long_int = 8 &&
746 AC_DEFINE(LONG_64_BITS, 1,
747 [Define to 1 if `sizeof (long int)' = 8. Obsolete, use
749 ], [your code should no longer depend upon `LONG_64_BITS', but upon
750 `SIZEOF_LONG_INT == 8'. Remove this warning and the `AC_DEFINE' when
751 you adjust the code.])
755 ## -------------------------- ##
756 ## Generic structure checks. ##
757 ## -------------------------- ##
764 # AC_CHECK_MEMBER(AGGREGATE.MEMBER,
765 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
766 # [INCLUDES = DEFAULT-INCLUDES])
767 # ---------------------------------------------------------
768 # AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
769 # variables are not a valid argument.
770 AC_DEFUN([AC_CHECK_MEMBER],
771 [AS_LITERAL_IF([$1], [],
772 [AC_FATAL([$0: requires literal arguments])])dnl
773 m4_bmatch([$1], [\.], ,
774 [m4_fatal([$0: Did not see any dot in `$1'])])dnl
775 AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
776 dnl Extract the aggregate name, and the member name
777 AC_CACHE_CHECK([for $1], ac_Member,
778 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
779 [dnl AGGREGATE ac_aggr;
780 static m4_bpatsubst([$1], [\..*]) ac_aggr;
782 if (ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))
784 [AS_VAR_SET(ac_Member, yes)],
785 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
786 [dnl AGGREGATE ac_aggr;
787 static m4_bpatsubst([$1], [\..*]) ac_aggr;
788 dnl sizeof ac_aggr.MEMBER;
789 if (sizeof ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))
791 [AS_VAR_SET(ac_Member, yes)],
792 [AS_VAR_SET(ac_Member, no)])])])
793 AS_IF([test AS_VAR_GET(ac_Member) = yes], [$2], [$3])dnl
794 AS_VAR_POPDEF([ac_Member])dnl
798 # AC_CHECK_MEMBERS([AGGREGATE.MEMBER, ...],
799 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]
800 # [INCLUDES = DEFAULT-INCLUDES])
801 # ---------------------------------------------------------
802 # The first argument is an m4 list.
803 AC_DEFUN([AC_CHECK_MEMBERS],
804 [m4_foreach([AC_Member], [$1],
805 [AC_CHECK_MEMBER(AC_Member,
806 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Member), 1,
807 [Define to 1 if `]m4_bpatsubst(AC_Member,
809 member of `]m4_bpatsubst(AC_Member, [\..*])['.])
816 # ------------------------------------------------------- #
817 # Members that ought to be tested with AC_CHECK_MEMBERS. #
818 # ------------------------------------------------------- #
820 AN_IDENTIFIER([st_blksize], [AC_CHECK_MEMBERS([struct stat.st_blksize])])
821 AN_IDENTIFIER([st_rdev], [AC_CHECK_MEMBERS([struct stat.st_rdev])])
824 # Alphabetic order, please.
826 # _AC_STRUCT_DIRENT(MEMBER)
827 # -------------------------
828 AC_DEFUN([_AC_STRUCT_DIRENT],
830 AC_REQUIRE([AC_HEADER_DIRENT])
831 AC_CHECK_MEMBERS([struct dirent.$1], [], [],
833 #include <sys/types.h>
837 # define dirent direct
838 # ifdef HAVE_SYS_NDIR_H
839 # include <sys/ndir.h>
841 # ifdef HAVE_SYS_DIR_H
842 # include <sys/dir.h>
851 # AC_STRUCT_DIRENT_D_INO
852 # -----------------------------------
853 AC_DEFUN([AC_STRUCT_DIRENT_D_INO], [_AC_STRUCT_DIRENT([d_ino])])
855 # AC_STRUCT_DIRENT_D_TYPE
856 # ------------------------------------
857 AC_DEFUN([AC_STRUCT_DIRENT_D_TYPE], [_AC_STRUCT_DIRENT([d_type])])
860 # AC_STRUCT_ST_BLKSIZE
861 # --------------------
862 AU_DEFUN([AC_STRUCT_ST_BLKSIZE],
863 [AC_CHECK_MEMBERS([struct stat.st_blksize],
864 [AC_DEFINE(HAVE_ST_BLKSIZE, 1,
865 [Define to 1 if your `struct stat' has
866 `st_blksize'. Deprecated, use
867 `HAVE_STRUCT_STAT_ST_BLKSIZE' instead.])])
868 ], [your code should no longer depend upon `HAVE_ST_BLKSIZE', but
869 `HAVE_STRUCT_STAT_ST_BLKSIZE'. Remove this warning and
870 the `AC_DEFINE' when you adjust the code.])# AC_STRUCT_ST_BLKSIZE
873 # AC_STRUCT_ST_BLOCKS
874 # -------------------
875 # If `struct stat' contains an `st_blocks' member, define
876 # HAVE_STRUCT_STAT_ST_BLOCKS. Otherwise, add `fileblocks.o' to the
877 # output variable LIBOBJS. We still define HAVE_ST_BLOCKS for backward
878 # compatibility. In the future, we will activate specializations for
879 # this macro, so don't obsolete it right now.
881 # AC_OBSOLETE([$0], [; replace it with
882 # AC_CHECK_MEMBERS([struct stat.st_blocks],
883 # [AC_LIBOBJ([fileblocks])])
884 # Please note that it will define `HAVE_STRUCT_STAT_ST_BLOCKS',
885 # and not `HAVE_ST_BLOCKS'.])dnl
887 AN_IDENTIFIER([st_blocks], [AC_STRUCT_ST_BLOCKS])
888 AC_DEFUN([AC_STRUCT_ST_BLOCKS],
889 [AC_CHECK_MEMBERS([struct stat.st_blocks],
890 [AC_DEFINE(HAVE_ST_BLOCKS, 1,
891 [Define to 1 if your `struct stat' has
892 `st_blocks'. Deprecated, use
893 `HAVE_STRUCT_STAT_ST_BLOCKS' instead.])],
894 [AC_LIBOBJ([fileblocks])])
895 ])# AC_STRUCT_ST_BLOCKS
900 AU_DEFUN([AC_STRUCT_ST_RDEV],
901 [AC_CHECK_MEMBERS([struct stat.st_rdev],
902 [AC_DEFINE(HAVE_ST_RDEV, 1,
903 [Define to 1 if your `struct stat' has `st_rdev'.
904 Deprecated, use `HAVE_STRUCT_STAT_ST_RDEV'
906 ], [your code should no longer depend upon `HAVE_ST_RDEV', but
907 `HAVE_STRUCT_STAT_ST_RDEV'. Remove this warning and
908 the `AC_DEFINE' when you adjust the code.])# AC_STRUCT_ST_RDEV
913 # FIXME: This macro is badly named, it should be AC_CHECK_TYPE_STRUCT_TM.
914 # Or something else, but what? AC_CHECK_TYPE_STRUCT_TM_IN_SYS_TIME?
915 AN_IDENTIFIER([tm], [AC_STRUCT_TM])
916 AC_DEFUN([AC_STRUCT_TM],
917 [AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
919 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
925 [ac_cv_struct_tm=time.h],
926 [ac_cv_struct_tm=sys/time.h])])
927 if test $ac_cv_struct_tm = sys/time.h; then
928 AC_DEFINE(TM_IN_SYS_TIME, 1,
929 [Define to 1 if your <sys/time.h> declares `struct tm'.])
936 # Figure out how to get the current timezone. If `struct tm' has a
937 # `tm_zone' member, define `HAVE_TM_ZONE'. Otherwise, if the
938 # external array `tzname' is found, define `HAVE_TZNAME'.
939 AN_IDENTIFIER([tm_zone], [AC_STRUCT_TIMEZONE])
940 AC_DEFUN([AC_STRUCT_TIMEZONE],
941 [AC_REQUIRE([AC_STRUCT_TM])dnl
942 AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
943 #include <$ac_cv_struct_tm>
945 if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
946 AC_DEFINE(HAVE_TM_ZONE, 1,
947 [Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
948 `HAVE_STRUCT_TM_TM_ZONE' instead.])
950 AC_CHECK_DECLS([tzname], , , [#include <time.h>])
951 AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
952 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
954 #if !HAVE_DECL_TZNAME
955 extern char *tzname[];
958 [[return tzname[0][0];]])],
959 [ac_cv_var_tzname=yes],
960 [ac_cv_var_tzname=no])])
961 if test $ac_cv_var_tzname = yes; then
962 AC_DEFINE(HAVE_TZNAME, 1,
963 [Define to 1 if you don't have `tm_zone' but do have the external
967 ])# AC_STRUCT_TIMEZONE