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 [dnl This catches a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
485 dnl If cross compiling, assume the bug isn't important, since
486 dnl nobody cross compiles for this platform as far as we know.
489 [[@%:@include <limits.h>
492 (1LL << (sizeof (long long int) * CHAR_BIT - 2))
493 @%:@ define LLONG_MAX (HALF - 1 + HALF)
495 [[long long int n = 1;
499 long long int m = n << i;
502 if (LLONG_MAX / 2 < m)
506 [ac_cv_type_long_long_int=yes],
507 [ac_cv_type_long_long_int=no],
508 [ac_cv_type_long_long_int=yes])],
509 [ac_cv_type_long_long_int=no])])
510 if test $ac_cv_type_long_long_int = yes; then
511 AC_DEFINE([HAVE_LONG_LONG_INT], 1,
512 [Define to 1 if the system has the type `long long int'.])
517 # AC_TYPE_UNSIGNED_LONG_LONG_INT
518 # ------------------------------
519 AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
521 AC_CACHE_CHECK([for unsigned long long int],
522 [ac_cv_type_unsigned_long_long_int],
525 [[unsigned long long int ull = 18446744073709551615ULL;
526 typedef int a[(18446744073709551615ULL <= (unsigned long long int) -1
529 [[unsigned long long int ullmax = 18446744073709551615ull;
530 return (ull << 63 | ull >> 63 | ull << i | ull >> i
531 | ullmax / ull | ullmax % ull);]])],
532 [ac_cv_type_unsigned_long_long_int=yes],
533 [ac_cv_type_unsigned_long_long_int=no])])
534 if test $ac_cv_type_unsigned_long_long_int = yes; then
535 AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], 1,
536 [Define to 1 if the system has the type `unsigned long long int'.])
543 AC_DEFUN([AC_TYPE_MBSTATE_T],
544 [AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
548 # include <wchar.h>],
549 [mbstate_t x; return sizeof x;])],
550 [ac_cv_type_mbstate_t=yes],
551 [ac_cv_type_mbstate_t=no])])
552 if test $ac_cv_type_mbstate_t = yes; then
553 AC_DEFINE([HAVE_MBSTATE_T], 1,
554 [Define to 1 if <wchar.h> declares mbstate_t.])
556 AC_DEFINE([mbstate_t], int,
557 [Define to a type if <wchar.h> does not define.])
563 # FIXME: Rewrite using AC_CHECK_TYPE.
564 AN_IDENTIFIER([gid_t], [AC_TYPE_UID_T])
565 AN_IDENTIFIER([uid_t], [AC_TYPE_UID_T])
566 AC_DEFUN([AC_TYPE_UID_T],
567 [AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
568 [AC_EGREP_HEADER(uid_t, sys/types.h,
569 ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
570 if test $ac_cv_type_uid_t = no; then
571 AC_DEFINE(uid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
572 AC_DEFINE(gid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
577 AN_IDENTIFIER([size_t], [AC_TYPE_SIZE_T])
578 AC_DEFUN([AC_TYPE_SIZE_T], [AC_CHECK_TYPE(size_t, unsigned int)])
580 AN_IDENTIFIER([ssize_t], [AC_TYPE_SSIZE_T])
581 AC_DEFUN([AC_TYPE_SSIZE_T], [AC_CHECK_TYPE(ssize_t, int)])
583 AN_IDENTIFIER([pid_t], [AC_TYPE_PID_T])
584 AC_DEFUN([AC_TYPE_PID_T], [AC_CHECK_TYPE(pid_t, int)])
586 AN_IDENTIFIER([off_t], [AC_TYPE_OFF_T])
587 AC_DEFUN([AC_TYPE_OFF_T], [AC_CHECK_TYPE(off_t, long int)])
589 AN_IDENTIFIER([mode_t], [AC_TYPE_MODE_T])
590 AC_DEFUN([AC_TYPE_MODE_T], [AC_CHECK_TYPE(mode_t, int)])
592 AN_IDENTIFIER([int8_t], [AC_TYPE_INT8_T])
593 AN_IDENTIFIER([int16_t], [AC_TYPE_INT16_T])
594 AN_IDENTIFIER([int32_t], [AC_TYPE_INT32_T])
595 AN_IDENTIFIER([int64_t], [AC_TYPE_INT64_T])
596 AN_IDENTIFIER([uint8_t], [AC_TYPE_UINT8_T])
597 AN_IDENTIFIER([uint16_t], [AC_TYPE_UINT16_T])
598 AN_IDENTIFIER([uint32_t], [AC_TYPE_UINT32_T])
599 AN_IDENTIFIER([uint64_t], [AC_TYPE_UINT64_T])
600 AC_DEFUN([AC_TYPE_INT8_T], [_AC_TYPE_INT(8)])
601 AC_DEFUN([AC_TYPE_INT16_T], [_AC_TYPE_INT(16)])
602 AC_DEFUN([AC_TYPE_INT32_T], [_AC_TYPE_INT(32)])
603 AC_DEFUN([AC_TYPE_INT64_T], [_AC_TYPE_INT(64)])
604 AC_DEFUN([AC_TYPE_UINT8_T], [_AC_TYPE_UNSIGNED_INT(8)])
605 AC_DEFUN([AC_TYPE_UINT16_T], [_AC_TYPE_UNSIGNED_INT(16)])
606 AC_DEFUN([AC_TYPE_UINT32_T], [_AC_TYPE_UNSIGNED_INT(32)])
607 AC_DEFUN([AC_TYPE_UINT64_T], [_AC_TYPE_UNSIGNED_INT(64)])
609 # _AC_TYPE_INT(NBITS)
610 # -------------------
611 AC_DEFUN([_AC_TYPE_INT],
613 AC_CACHE_CHECK([for int$1_t], [ac_cv_c_int$1_t],
615 for ac_type in 'int$1_t' 'int' 'long int' \
616 'long long int' 'short int' 'signed char'; do
618 [AC_LANG_BOOL_COMPILE_TRY(
619 [AC_INCLUDES_DEFAULT],
620 [[0 < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)]])],
622 [AC_LANG_BOOL_COMPILE_TRY(
623 [AC_INCLUDES_DEFAULT],
624 [[($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 1)
625 < ($ac_type) (((($ac_type) 1 << ($1 - 2)) - 1) * 2 + 2)]])],
627 [AS_CASE([$ac_type], [int$1_t],
628 [ac_cv_c_int$1_t=yes],
629 [ac_cv_c_int$1_t=$ac_type])])])
630 test "$ac_cv_c_int$1_t" != no && break
632 case $ac_cv_c_int$1_t in #(
635 AC_DEFINE_UNQUOTED([int$1_t], [$ac_cv_c_int$1_t],
636 [Define to the type of a signed integer type of width exactly $1 bits
637 if such a type exists and the standard includes do not define it.]);;
641 # _AC_TYPE_UNSIGNED_INT(NBITS)
642 # ----------------------------
643 AC_DEFUN([_AC_TYPE_UNSIGNED_INT],
645 AC_CACHE_CHECK([for uint$1_t], [ac_cv_c_uint$1_t],
647 for ac_type in 'uint$1_t' 'unsigned int' 'unsigned long int' \
648 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
650 [AC_LANG_BOOL_COMPILE_TRY(
651 [AC_INCLUDES_DEFAULT],
652 [[($ac_type) -1 >> ($1 - 1) == 1]])],
653 [AS_CASE([$ac_type], [uint$1_t],
654 [ac_cv_c_uint$1_t=yes],
655 [ac_cv_c_uint$1_t=$ac_type])])
656 test "$ac_cv_c_uint$1_t" != no && break
658 case $ac_cv_c_uint$1_t in #(
661 m4_bmatch([$1], [^\(8\|32\|64\)$],
662 [AC_DEFINE([_UINT$1_T], 1,
663 [Define for Solaris 2.5.1 so the uint$1_t typedef from
664 <sys/synch.h>, <pthread.h>, or <semaphore.h> is not used.
665 If the typedef was allowed, the #define below would cause a
667 AC_DEFINE_UNQUOTED([uint$1_t], [$ac_cv_c_uint$1_t],
668 [Define to the type of an unsigned integer type of width exactly $1 bits
669 if such a type exists and the standard includes do not define it.]);;
671 ])# _AC_TYPE_UNSIGNED_INT
675 # Note that identifiers starting with SIG are reserved by ANSI C.
676 AN_FUNCTION([signal], [AC_TYPE_SIGNAL])
677 AC_DEFUN([AC_TYPE_SIGNAL],
678 [AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
680 [AC_LANG_PROGRAM([#include <sys/types.h>
683 [return *(signal (0, 0)) (0) == 1;])],
684 [ac_cv_type_signal=int],
685 [ac_cv_type_signal=void])])
686 AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal,
687 [Define as the return type of signal handlers
692 ## ------------------------ ##
693 ## Checking size of types. ##
694 ## ------------------------ ##
701 # AC_CHECK_SIZEOF(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
702 # ---------------------------------------------------------------
703 AC_DEFUN([AC_CHECK_SIZEOF],
704 [AS_LITERAL_IF([$1], [],
705 [AC_FATAL([$0: requires literal arguments])])dnl
706 AC_CHECK_TYPE([$1], [], [], [$3])
707 # The cast to long int works around a bug in the HP C Compiler
708 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
709 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
710 # This bug is HP SR number 8606223364.
711 _AC_CACHE_CHECK_INT([size of $1], [AS_TR_SH([ac_cv_sizeof_$1])],
712 [(long int) (sizeof (ac__type_sizeof_))],
713 [AC_INCLUDES_DEFAULT([$3])
714 typedef $1 ac__type_sizeof_;],
715 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
716 AC_MSG_FAILURE([cannot compute sizeof ($1)], 77)
718 AS_TR_SH([ac_cv_sizeof_$1])=0
721 AC_DEFINE_UNQUOTED(AS_TR_CPP(sizeof_$1), $AS_TR_SH([ac_cv_sizeof_$1]),
722 [The size of `$1', as computed by sizeof.])
726 # AC_CHECK_ALIGNOF(TYPE, [INCLUDES = DEFAULT-INCLUDES])
727 # -----------------------------------------------------
728 AC_DEFUN([AC_CHECK_ALIGNOF],
729 [AS_LITERAL_IF([$1], [],
730 [AC_FATAL([$0: requires literal arguments])])dnl
731 AC_CHECK_TYPE([$1], [], [], [$2])
732 # The cast to long int works around a bug in the HP C Compiler,
733 # see AC_CHECK_SIZEOF for more information.
734 _AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$1])],
735 [(long int) offsetof (ac__type_alignof_, y)],
736 [AC_INCLUDES_DEFAULT([$2])
738 # define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
740 typedef struct { char x; $1 y; } ac__type_alignof_;],
741 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
742 AC_MSG_FAILURE([cannot compute alignment of $1], 77)
744 AS_TR_SH([ac_cv_alignof_$1])=0
747 AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$1), $AS_TR_SH([ac_cv_alignof_$1]),
748 [The normal alignment of `$1', in bytes.])
754 # What a great name :)
755 AU_DEFUN([AC_INT_16_BITS],
756 [AC_CHECK_SIZEOF([int])
757 test $ac_cv_sizeof_int = 2 &&
758 AC_DEFINE(INT_16_BITS, 1,
759 [Define to 1 if `sizeof (int)' = 2. Obsolete, use `SIZEOF_INT'.])
760 ], [your code should no longer depend upon `INT_16_BITS', but upon
761 `SIZEOF_INT == 2'. Remove this warning and the `AC_DEFINE' when you
765 # AU::AC_LONG_64_BITS
766 # -------------------
767 AU_DEFUN([AC_LONG_64_BITS],
768 [AC_CHECK_SIZEOF([long int])
769 test $ac_cv_sizeof_long_int = 8 &&
770 AC_DEFINE(LONG_64_BITS, 1,
771 [Define to 1 if `sizeof (long int)' = 8. Obsolete, use
773 ], [your code should no longer depend upon `LONG_64_BITS', but upon
774 `SIZEOF_LONG_INT == 8'. Remove this warning and the `AC_DEFINE' when
775 you adjust the code.])
779 ## -------------------------- ##
780 ## Generic structure checks. ##
781 ## -------------------------- ##
788 # AC_CHECK_MEMBER(AGGREGATE.MEMBER,
789 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
790 # [INCLUDES = DEFAULT-INCLUDES])
791 # ---------------------------------------------------------
792 # AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
793 # variables are not a valid argument.
794 AC_DEFUN([AC_CHECK_MEMBER],
795 [AS_LITERAL_IF([$1], [],
796 [AC_FATAL([$0: requires literal arguments])])dnl
797 m4_bmatch([$1], [\.], ,
798 [m4_fatal([$0: Did not see any dot in `$1'])])dnl
799 AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
800 dnl Extract the aggregate name, and the member name
801 AC_CACHE_CHECK([for $1], [ac_Member],
802 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
803 [dnl AGGREGATE ac_aggr;
804 static m4_bpatsubst([$1], [\..*]) ac_aggr;
806 if (ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))
808 [AS_VAR_SET([ac_Member], [yes])],
809 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
810 [dnl AGGREGATE ac_aggr;
811 static m4_bpatsubst([$1], [\..*]) ac_aggr;
812 dnl sizeof ac_aggr.MEMBER;
813 if (sizeof ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))
815 [AS_VAR_SET([ac_Member], [yes])],
816 [AS_VAR_SET([ac_Member], [no])])])])
817 AS_IF([test AS_VAR_GET([ac_Member]) = yes], [$2], [$3])dnl
818 AS_VAR_POPDEF([ac_Member])dnl
822 # AC_CHECK_MEMBERS([AGGREGATE.MEMBER, ...],
823 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]
824 # [INCLUDES = DEFAULT-INCLUDES])
825 # ---------------------------------------------------------
826 # The first argument is an m4 list.
827 AC_DEFUN([AC_CHECK_MEMBERS],
828 [m4_foreach([AC_Member], [$1],
829 [AC_CHECK_MEMBER(AC_Member,
830 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Member), 1,
831 [Define to 1 if `]m4_bpatsubst(AC_Member,
833 member of `]m4_bpatsubst(AC_Member, [\..*])['.])
840 # ------------------------------------------------------- #
841 # Members that ought to be tested with AC_CHECK_MEMBERS. #
842 # ------------------------------------------------------- #
844 AN_IDENTIFIER([st_blksize], [AC_CHECK_MEMBERS([struct stat.st_blksize])])
845 AN_IDENTIFIER([st_rdev], [AC_CHECK_MEMBERS([struct stat.st_rdev])])
848 # Alphabetic order, please.
850 # _AC_STRUCT_DIRENT(MEMBER)
851 # -------------------------
852 AC_DEFUN([_AC_STRUCT_DIRENT],
854 AC_REQUIRE([AC_HEADER_DIRENT])
855 AC_CHECK_MEMBERS([struct dirent.$1], [], [],
857 #include <sys/types.h>
861 # define dirent direct
862 # ifdef HAVE_SYS_NDIR_H
863 # include <sys/ndir.h>
865 # ifdef HAVE_SYS_DIR_H
866 # include <sys/dir.h>
875 # AC_STRUCT_DIRENT_D_INO
876 # -----------------------------------
877 AC_DEFUN([AC_STRUCT_DIRENT_D_INO], [_AC_STRUCT_DIRENT([d_ino])])
879 # AC_STRUCT_DIRENT_D_TYPE
880 # ------------------------------------
881 AC_DEFUN([AC_STRUCT_DIRENT_D_TYPE], [_AC_STRUCT_DIRENT([d_type])])
884 # AC_STRUCT_ST_BLKSIZE
885 # --------------------
886 AU_DEFUN([AC_STRUCT_ST_BLKSIZE],
887 [AC_CHECK_MEMBERS([struct stat.st_blksize],
888 [AC_DEFINE(HAVE_ST_BLKSIZE, 1,
889 [Define to 1 if your `struct stat' has
890 `st_blksize'. Deprecated, use
891 `HAVE_STRUCT_STAT_ST_BLKSIZE' instead.])])
892 ], [your code should no longer depend upon `HAVE_ST_BLKSIZE', but
893 `HAVE_STRUCT_STAT_ST_BLKSIZE'. Remove this warning and
894 the `AC_DEFINE' when you adjust the code.])# AC_STRUCT_ST_BLKSIZE
897 # AC_STRUCT_ST_BLOCKS
898 # -------------------
899 # If `struct stat' contains an `st_blocks' member, define
900 # HAVE_STRUCT_STAT_ST_BLOCKS. Otherwise, add `fileblocks.o' to the
901 # output variable LIBOBJS. We still define HAVE_ST_BLOCKS for backward
902 # compatibility. In the future, we will activate specializations for
903 # this macro, so don't obsolete it right now.
905 # AC_OBSOLETE([$0], [; replace it with
906 # AC_CHECK_MEMBERS([struct stat.st_blocks],
907 # [AC_LIBOBJ([fileblocks])])
908 # Please note that it will define `HAVE_STRUCT_STAT_ST_BLOCKS',
909 # and not `HAVE_ST_BLOCKS'.])dnl
911 AN_IDENTIFIER([st_blocks], [AC_STRUCT_ST_BLOCKS])
912 AC_DEFUN([AC_STRUCT_ST_BLOCKS],
913 [AC_CHECK_MEMBERS([struct stat.st_blocks],
914 [AC_DEFINE(HAVE_ST_BLOCKS, 1,
915 [Define to 1 if your `struct stat' has
916 `st_blocks'. Deprecated, use
917 `HAVE_STRUCT_STAT_ST_BLOCKS' instead.])],
918 [AC_LIBOBJ([fileblocks])])
919 ])# AC_STRUCT_ST_BLOCKS
924 AU_DEFUN([AC_STRUCT_ST_RDEV],
925 [AC_CHECK_MEMBERS([struct stat.st_rdev],
926 [AC_DEFINE(HAVE_ST_RDEV, 1,
927 [Define to 1 if your `struct stat' has `st_rdev'.
928 Deprecated, use `HAVE_STRUCT_STAT_ST_RDEV'
930 ], [your code should no longer depend upon `HAVE_ST_RDEV', but
931 `HAVE_STRUCT_STAT_ST_RDEV'. Remove this warning and
932 the `AC_DEFINE' when you adjust the code.])# AC_STRUCT_ST_RDEV
937 # FIXME: This macro is badly named, it should be AC_CHECK_TYPE_STRUCT_TM.
938 # Or something else, but what? AC_CHECK_TYPE_STRUCT_TM_IN_SYS_TIME?
939 AN_IDENTIFIER([tm], [AC_STRUCT_TM])
940 AC_DEFUN([AC_STRUCT_TM],
941 [AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
943 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
949 [ac_cv_struct_tm=time.h],
950 [ac_cv_struct_tm=sys/time.h])])
951 if test $ac_cv_struct_tm = sys/time.h; then
952 AC_DEFINE(TM_IN_SYS_TIME, 1,
953 [Define to 1 if your <sys/time.h> declares `struct tm'.])
960 # Figure out how to get the current timezone. If `struct tm' has a
961 # `tm_zone' member, define `HAVE_TM_ZONE'. Otherwise, if the
962 # external array `tzname' is found, define `HAVE_TZNAME'.
963 AN_IDENTIFIER([tm_zone], [AC_STRUCT_TIMEZONE])
964 AC_DEFUN([AC_STRUCT_TIMEZONE],
965 [AC_REQUIRE([AC_STRUCT_TM])dnl
966 AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
967 #include <$ac_cv_struct_tm>
969 if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
970 AC_DEFINE(HAVE_TM_ZONE, 1,
971 [Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
972 `HAVE_STRUCT_TM_TM_ZONE' instead.])
974 AC_CHECK_DECLS([tzname], , , [#include <time.h>])
975 AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
976 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
978 #if !HAVE_DECL_TZNAME
979 extern char *tzname[];
982 [[return tzname[0][0];]])],
983 [ac_cv_var_tzname=yes],
984 [ac_cv_var_tzname=no])])
985 if test $ac_cv_var_tzname = yes; then
986 AC_DEFINE(HAVE_TZNAME, 1,
987 [Define to 1 if you don't have `tm_zone' but do have the external
991 ])# AC_STRUCT_TIMEZONE