Prefer HTTPS to FTP and HTTP
[autoconf.git] / lib / autoconf / types.m4
blob494f69ccdedd521e717ddccda1dd180752f73ba0
1 # This file is part of Autoconf.                        -*- Autoconf -*-
2 # Type related macros: existence, sizeof, and structure members.
4 # Copyright (C) 2000-2002, 2004-2017 Free Software Foundation, Inc.
6 # This file is part of Autoconf.  This program is free
7 # software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the
9 # Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
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 # Under Section 7 of GPL version 3, you are granted additional
18 # permissions described in the Autoconf Configure Script Exception,
19 # version 3.0, as published by the Free Software Foundation.
21 # You should have received a copy of the GNU General Public License
22 # and a copy of the Autoconf Configure Script Exception along with
23 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
24 # respectively.  If not, see <https://www.gnu.org/licenses/>.
26 # Written by David MacKenzie, with help from
27 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
28 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
31 ## ---------------- ##
32 ## Type existence.  ##
33 ## ---------------- ##
35 # ---------------- #
36 # General checks.  #
37 # ---------------- #
39 # Up to 2.13 included, Autoconf used to provide the macro
41 #    AC_CHECK_TYPE(TYPE, DEFAULT)
43 # Since, it provides another version which fits better with the other
44 # AC_CHECK_ families:
46 #    AC_CHECK_TYPE(TYPE,
47 #                  [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
48 #                  [INCLUDES = DEFAULT-INCLUDES])
50 # In order to provide backward compatibility, the new scheme is
51 # implemented as _AC_CHECK_TYPE_NEW, the old scheme as _AC_CHECK_TYPE_OLD,
52 # and AC_CHECK_TYPE branches to one or the other, depending upon its
53 # arguments.
56 # _AC_CHECK_TYPE_NEW_BODY
57 # -----------------------
58 # Shell function body for _AC_CHECK_TYPE_NEW.  This macro implements the
59 # former task of AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE
60 # used to grep in the headers, which, BTW, led to many problems until the
61 # extended regular expression was correct and did not give false positives.
62 # It turned out there are even portability issues with egrep...
64 # The most obvious way to check for a TYPE is just to compile a variable
65 # definition:
67 #         TYPE my_var;
69 # (TYPE being the second parameter to the shell function, hence $[]2 in m4).
70 # Unfortunately this does not work for const qualified types in C++, where
71 # you need an initializer.  So you think of
73 #         TYPE my_var = (TYPE) 0;
75 # Unfortunately, again, this is not valid for some C++ classes.
77 # Then you look for another scheme.  For instance you think of declaring
78 # a function which uses a parameter of type TYPE:
80 #         int foo (TYPE param);
82 # but of course you soon realize this does not make it with K&R
83 # compilers.  And by no means do you want to use this:
85 #         int foo (param)
86 #           TYPE param
87 #         { ; }
89 # since C++ would complain loudly.
91 # Don't even think of using a function return type, since K&R cries
92 # there too.  So you start thinking of declaring a *pointer* to this TYPE:
94 #         TYPE *p;
96 # but you know fairly well that this is legal in C for aggregates which
97 # are unknown (TYPE = struct does-not-exist).
99 # Then you think of using sizeof to make sure the TYPE is really
100 # defined:
102 #         sizeof (TYPE);
104 # That is great, but has one drawback: it succeeds when TYPE happens
105 # to be a variable: you'd get the size of the variable's type.
106 # Obviously, we must not accept a variable in place of a type name.
108 # So, to filter out the last possibility, we will require that this fail:
110 #         sizeof ((TYPE));
112 # This evokes a syntax error when TYPE is a type, but succeeds if TYPE
113 # is actually a variable.
115 # Also note that we use
117 #         if (sizeof (TYPE))
119 # to `read' sizeof (to avoid warnings), while not depending on its type
120 # (not necessarily size_t etc.).
122 # C++ disallows defining types inside `sizeof ()', but that's OK,
123 # since we don't want to consider unnamed structs to be types for C++,
124 # precisely because they don't work in cases like that.
125 m4_define([_AC_CHECK_TYPE_NEW_BODY],
126 [  AS_LINENO_PUSH([$[]1])
127   AC_CACHE_CHECK([for $[]2], [$[]3],
128   [AS_VAR_SET([$[]3], [no])
129   AC_COMPILE_IFELSE(
130     [AC_LANG_PROGRAM([$[]4],
131        [if (sizeof ($[]2))
132          return 0;])],
133     [AC_COMPILE_IFELSE(
134        [AC_LANG_PROGRAM([$[]4],
135           [if (sizeof (($[]2)))
136             return 0;])],
137        [],
138        [AS_VAR_SET([$[]3], [yes])])])])
139   AS_LINENO_POP
140 ])dnl
142 # _AC_CHECK_TYPE_NEW(TYPE,
143 #                    [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
144 #                    [INCLUDES = DEFAULT-INCLUDES])
145 # ------------------------------------------------------------
146 # Check whether the type TYPE is supported by the system, maybe via the
147 # the provided includes.
148 AC_DEFUN([_AC_CHECK_TYPE_NEW],
149 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_type],
150   [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_type],
151     [LINENO TYPE VAR INCLUDES],
152     [Tests whether TYPE exists after having included INCLUDES, setting
153      cache variable VAR accordingly.])],
154     [$0_BODY])]dnl
155 [AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])]dnl
156 [ac_fn_[]_AC_LANG_ABBREV[]_check_type "$LINENO" "$1" "ac_Type" ]dnl
157 ["AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])"
158 AS_VAR_IF([ac_Type], [yes], [$2], [$3])
159 AS_VAR_POPDEF([ac_Type])dnl
160 ])# _AC_CHECK_TYPE_NEW
163 # _AC_CHECK_TYPES(TYPE)
164 # ---------------------
165 # Helper to AC_CHECK_TYPES, which generates two of the four arguments
166 # to _AC_CHECK_TYPE_NEW that are based on TYPE.
167 m4_define([_AC_CHECK_TYPES],
168 [[$1], [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), [1],
169   [Define to 1 if the system has the type `$1'.])]])
172 # AC_CHECK_TYPES(TYPES,
173 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
174 #                [INCLUDES = DEFAULT-INCLUDES])
175 # --------------------------------------------------------
176 # TYPES is an m4 list.  There are no ambiguities here, we mean the newer
177 # AC_CHECK_TYPE.
178 AC_DEFUN([AC_CHECK_TYPES],
179 [m4_map_args_sep([_AC_CHECK_TYPE_NEW(_$0(], [)[
180 $2], [$3], [$4])], [], $1)])
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-use backward compatibility.
203 m4_define([_AC_CHECK_TYPE_REPLACEMENT_TYPE_P],
204 [m4_bmatch([$1],
205           [^\(_Bool\|bool\|char\|double\|float\|int\|long\|short\|\(un\)?signed\|[_a-zA-Z][_a-zA-Z0-9]*_t\)[][_a-zA-Z0-9() *]*$],
206           1, 0)dnl
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() *]\|\[\|\]\)*$],
215           1, 0)dnl
216 ])# _AC_CHECK_TYPE_MAYBE_TYPE_P
219 # AC_CHECK_TYPE(TYPE, DEFAULT)
220 #  or
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
231 # 4. default                         => NEW
232 AC_DEFUN([AC_CHECK_TYPE],
233 [m4_cond([$#], [3],
234   [_AC_CHECK_TYPE_NEW],
235          [$#], [4],
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])($@)])# AC_CHECK_TYPE
246 # ---------------------------- #
247 # Types that must be checked.  #
248 # ---------------------------- #
250 AN_IDENTIFIER([ptrdiff_t], [AC_CHECK_TYPES])
253 # ----------------- #
254 # Specific checks.  #
255 # ----------------- #
257 # AC_TYPE_GETGROUPS
258 # -----------------
259 AC_DEFUN([AC_TYPE_GETGROUPS],
260 [AC_REQUIRE([AC_TYPE_UID_T])dnl
261 AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
262 [AC_RUN_IFELSE([AC_LANG_SOURCE(
263 [[/* Thanks to Mike Rendell for this test.  */
264 ]AC_INCLUDES_DEFAULT[
265 #define NGID 256
266 #undef MAX
267 #define MAX(x, y) ((x) > (y) ? (x) : (y))
270 main (void)
272   gid_t gidset[NGID];
273   int i, n;
274   union { gid_t gval; long int lval; }  val;
276   val.lval = -1;
277   for (i = 0; i < NGID; i++)
278     gidset[i] = val.gval;
279   n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
280                  gidset);
281   /* Exit non-zero if getgroups seems to require an array of ints.  This
282      happens when gid_t is short int but getgroups modifies an array
283      of ints.  */
284   return n > 0 && gidset[n] != val.gval;
285 }]])],
286                [ac_cv_type_getgroups=gid_t],
287                [ac_cv_type_getgroups=int],
288                [ac_cv_type_getgroups=cross])
289 if test $ac_cv_type_getgroups = cross; then
290   dnl When we can't run the test program (we are cross compiling), presume
291   dnl that <unistd.h> has either an accurate prototype for getgroups or none.
292   dnl Old systems without prototypes probably use int.
293   AC_EGREP_HEADER([getgroups.*int.*gid_t], unistd.h,
294                   ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int)
295 fi])
296 AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups,
297                    [Define to the type of elements in the array set by
298                     `getgroups'. Usually this is either `int' or `gid_t'.])
299 ])# AC_TYPE_GETGROUPS
302 # AU::AM_TYPE_PTRDIFF_T
303 # ---------------------
304 AU_DEFUN([AM_TYPE_PTRDIFF_T],
305 [AC_CHECK_TYPES(ptrdiff_t)])
308 # AC_TYPE_INTMAX_T
309 # ----------------
310 AC_DEFUN([AC_TYPE_INTMAX_T],
312   AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
313   AC_CHECK_TYPE([intmax_t],
314     [AC_DEFINE([HAVE_INTMAX_T], 1,
315        [Define to 1 if the system has the type `intmax_t'.])],
316     [test $ac_cv_type_long_long_int = yes \
317        && ac_type='long long int' \
318        || ac_type='long int'
319      AC_DEFINE_UNQUOTED([intmax_t], [$ac_type],
320        [Define to the widest signed integer type
321         if <stdint.h> and <inttypes.h> do not define.])])
325 # AC_TYPE_UINTMAX_T
326 # -----------------
327 AC_DEFUN([AC_TYPE_UINTMAX_T],
329   AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
330   AC_CHECK_TYPE([uintmax_t],
331     [AC_DEFINE([HAVE_UINTMAX_T], 1,
332        [Define to 1 if the system has the type `uintmax_t'.])],
333     [test $ac_cv_type_unsigned_long_long_int = yes \
334        && ac_type='unsigned long long int' \
335        || ac_type='unsigned long int'
336      AC_DEFINE_UNQUOTED([uintmax_t], [$ac_type],
337        [Define to the widest unsigned integer type
338         if <stdint.h> and <inttypes.h> do not define.])])
342 # AC_TYPE_INTPTR_T
343 # ----------------
344 AC_DEFUN([AC_TYPE_INTPTR_T],
346   AC_CHECK_TYPE([intptr_t],
347     [AC_DEFINE([HAVE_INTPTR_T], 1,
348        [Define to 1 if the system has the type `intptr_t'.])],
349     [for ac_type in 'int' 'long int' 'long long int'; do
350        AC_COMPILE_IFELSE(
351          [AC_LANG_BOOL_COMPILE_TRY(
352             [AC_INCLUDES_DEFAULT],
353             [[sizeof (void *) <= sizeof ($ac_type)]])],
354          [AC_DEFINE_UNQUOTED([intptr_t], [$ac_type],
355             [Define to the type of a signed integer type wide enough to
356              hold a pointer, if such a type exists, and if the system
357              does not define it.])
358           ac_type=])
359        test -z "$ac_type" && break
360      done])
364 # AC_TYPE_UINTPTR_T
365 # -----------------
366 AC_DEFUN([AC_TYPE_UINTPTR_T],
368   AC_CHECK_TYPE([uintptr_t],
369     [AC_DEFINE([HAVE_UINTPTR_T], 1,
370        [Define to 1 if the system has the type `uintptr_t'.])],
371     [for ac_type in 'unsigned int' 'unsigned long int' \
372         'unsigned long long int'; do
373        AC_COMPILE_IFELSE(
374          [AC_LANG_BOOL_COMPILE_TRY(
375             [AC_INCLUDES_DEFAULT],
376             [[sizeof (void *) <= sizeof ($ac_type)]])],
377          [AC_DEFINE_UNQUOTED([uintptr_t], [$ac_type],
378             [Define to the type of an unsigned integer type wide enough to
379              hold a pointer, if such a type exists, and if the system
380              does not define it.])
381           ac_type=])
382        test -z "$ac_type" && break
383      done])
387 # AC_TYPE_LONG_DOUBLE
388 # -------------------
389 AC_DEFUN([AC_TYPE_LONG_DOUBLE],
391   AC_CACHE_CHECK([for long double], [ac_cv_type_long_double],
392     [if test "$GCC" = yes; then
393        ac_cv_type_long_double=yes
394      else
395        AC_COMPILE_IFELSE(
396          [AC_LANG_BOOL_COMPILE_TRY(
397             [[/* The Stardent Vistra knows sizeof (long double), but does
398                  not support it.  */
399               long double foo = 0.0L;]],
400             [[/* On Ultrix 4.3 cc, long double is 4 and double is 8.  */
401               sizeof (double) <= sizeof (long double)]])],
402          [ac_cv_type_long_double=yes],
403          [ac_cv_type_long_double=no])
404      fi])
405   if test $ac_cv_type_long_double = yes; then
406     AC_DEFINE([HAVE_LONG_DOUBLE], 1,
407       [Define to 1 if the system has the type `long double'.])
408   fi
412 # AC_TYPE_LONG_DOUBLE_WIDER
413 # -------------------------
414 AC_DEFUN([AC_TYPE_LONG_DOUBLE_WIDER],
416   AC_CACHE_CHECK(
417     [for long double with more range or precision than double],
418     [ac_cv_type_long_double_wider],
419     [AC_COMPILE_IFELSE(
420        [AC_LANG_BOOL_COMPILE_TRY(
421           [[#include <float.h>
422             long double const a[] =
423               {
424                  0.0L, DBL_MIN, DBL_MAX, DBL_EPSILON,
425                  LDBL_MIN, LDBL_MAX, LDBL_EPSILON
426               };
427             long double
428             f (long double x)
429             {
430                return ((x + (unsigned long int) 10) * (-1 / x) + a[0]
431                         + (x ? f (x) : 'c'));
432             }
433           ]],
434           [[(0 < ((DBL_MAX_EXP < LDBL_MAX_EXP)
435                    + (DBL_MANT_DIG < LDBL_MANT_DIG)
436                    - (LDBL_MAX_EXP < DBL_MAX_EXP)
437                    - (LDBL_MANT_DIG < DBL_MANT_DIG)))
438             && (int) LDBL_EPSILON == 0
439           ]])],
440        ac_cv_type_long_double_wider=yes,
441        ac_cv_type_long_double_wider=no)])
442   if test $ac_cv_type_long_double_wider = yes; then
443     AC_DEFINE([HAVE_LONG_DOUBLE_WIDER], 1,
444       [Define to 1 if the type `long double' works and has more range or
445        precision than `double'.])
446   fi
447 ])# AC_TYPE_LONG_DOUBLE_WIDER
450 # AC_C_LONG_DOUBLE
451 # ----------------
452 AU_DEFUN([AC_C_LONG_DOUBLE],
453   [
454     AC_TYPE_LONG_DOUBLE_WIDER
455     ac_cv_c_long_double=$ac_cv_type_long_double_wider
456     if test $ac_cv_c_long_double = yes; then
457       AC_DEFINE([HAVE_LONG_DOUBLE], 1,
458         [Define to 1 if the type `long double' works and has more range or
459          precision than `double'.])
460     fi
461   ],
462   [The macro `AC_C_LONG_DOUBLE' is obsolete.
463 You should use `AC_TYPE_LONG_DOUBLE' or `AC_TYPE_LONG_DOUBLE_WIDER' instead.]
467 # _AC_TYPE_LONG_LONG_SNIPPET
468 # --------------------------
469 # Expands to a C program that can be used to test for simultaneous support
470 # of 'long long' and 'unsigned long long'. We don't want to say that
471 # 'long long' is available if 'unsigned long long' is not, or vice versa,
472 # because too many programs rely on the symmetry between signed and unsigned
473 # integer types (excluding 'bool').
474 AC_DEFUN([_AC_TYPE_LONG_LONG_SNIPPET],
476   AC_LANG_PROGRAM(
477     [[/* For now, do not test the preprocessor; as of 2007 there are too many
478          implementations with broken preprocessors.  Perhaps this can
479          be revisited in 2012.  In the meantime, code should not expect
480          #if to work with literals wider than 32 bits.  */
481       /* Test literals.  */
482       long long int ll = 9223372036854775807ll;
483       long long int nll = -9223372036854775807LL;
484       unsigned long long int ull = 18446744073709551615ULL;
485       /* Test constant expressions.   */
486       typedef int a[((-9223372036854775807LL < 0 && 0 < 9223372036854775807ll)
487                      ? 1 : -1)];
488       typedef int b[(18446744073709551615ULL <= (unsigned long long int) -1
489                      ? 1 : -1)];
490       int i = 63;]],
491     [[/* Test availability of runtime routines for shift and division.  */
492       long long int llmax = 9223372036854775807ll;
493       unsigned long long int ullmax = 18446744073709551615ull;
494       return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
495               | (llmax / ll) | (llmax % ll)
496               | (ull << 63) | (ull >> 63) | (ull << i) | (ull >> i)
497               | (ullmax / ull) | (ullmax % ull));]])
501 # AC_TYPE_LONG_LONG_INT
502 # ---------------------
503 AC_DEFUN([AC_TYPE_LONG_LONG_INT],
505   AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
506   AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
507      [ac_cv_type_long_long_int=yes
508       case $ac_prog_cc_stdc in
509         no | c89) ;;
510         *)
511           ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
512           if test $ac_cv_type_long_long_int = yes; then
513             dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
514             dnl If cross compiling, assume the bug is not important, since
515             dnl nobody cross compiles for this platform as far as we know.
516             AC_RUN_IFELSE(
517               [AC_LANG_PROGRAM(
518                  [[@%:@include <limits.h>
519                    @%:@ifndef LLONG_MAX
520                    @%:@ define HALF \
521                             (1LL << (sizeof (long long int) * CHAR_BIT - 2))
522                    @%:@ define LLONG_MAX (HALF - 1 + HALF)
523                    @%:@endif]],
524                  [[long long int n = 1;
525                    int i;
526                    for (i = 0; ; i++)
527                      {
528                        long long int m = n << i;
529                        if (m >> i != n)
530                          return 1;
531                        if (LLONG_MAX / 2 < m)
532                          break;
533                      }
534                    return 0;]])],
535               [],
536               [ac_cv_type_long_long_int=no],
537               [:])
538           fi;;
539       esac])
540   if test $ac_cv_type_long_long_int = yes; then
541     AC_DEFINE([HAVE_LONG_LONG_INT], [1],
542       [Define to 1 if the system has the type `long long int'.])
543   fi
547 # AC_TYPE_UNSIGNED_LONG_LONG_INT
548 # ------------------------------
549 AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT],
551   AC_CACHE_CHECK([for unsigned long long int],
552     [ac_cv_type_unsigned_long_long_int],
553     [ac_cv_type_unsigned_long_long_int=yes
554      case $ac_prog_cc_stdc in
555        no | c89) ;;
556        *)
557          AC_LINK_IFELSE(
558            [_AC_TYPE_LONG_LONG_SNIPPET],
559            [],
560            [ac_cv_type_unsigned_long_long_int=no]);;
561      esac])
562   if test $ac_cv_type_unsigned_long_long_int = yes; then
563     AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
564       [Define to 1 if the system has the type `unsigned long long int'.])
565   fi
569 # AC_TYPE_MBSTATE_T
570 # -----------------
571 AC_DEFUN([AC_TYPE_MBSTATE_T],
572   [AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
573      [AC_COMPILE_IFELSE(
574         [AC_LANG_PROGRAM(
575            [AC_INCLUDES_DEFAULT
576 #           include <wchar.h>],
577            [mbstate_t x; return sizeof x;])],
578         [ac_cv_type_mbstate_t=yes],
579         [ac_cv_type_mbstate_t=no])])
580    if test $ac_cv_type_mbstate_t = yes; then
581      AC_DEFINE([HAVE_MBSTATE_T], 1,
582                [Define to 1 if <wchar.h> declares mbstate_t.])
583    else
584      AC_DEFINE([mbstate_t], int,
585                [Define to a type if <wchar.h> does not define.])
586    fi])
589 # AC_TYPE_UID_T
590 # -------------
591 # FIXME: Rewrite using AC_CHECK_TYPE.
592 AN_IDENTIFIER([gid_t], [AC_TYPE_UID_T])
593 AN_IDENTIFIER([uid_t], [AC_TYPE_UID_T])
594 AC_DEFUN([AC_TYPE_UID_T],
595 [AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
596 [AC_EGREP_HEADER(uid_t, sys/types.h,
597   ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
598 if test $ac_cv_type_uid_t = no; then
599   AC_DEFINE(uid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
600   AC_DEFINE(gid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
605 AN_IDENTIFIER([size_t], [AC_TYPE_SIZE_T])
606 AC_DEFUN([AC_TYPE_SIZE_T], [AC_CHECK_TYPE(size_t, unsigned int)])
608 AN_IDENTIFIER([ssize_t], [AC_TYPE_SSIZE_T])
609 AC_DEFUN([AC_TYPE_SSIZE_T], [AC_CHECK_TYPE(ssize_t, int)])
611 AN_IDENTIFIER([pid_t], [AC_TYPE_PID_T])
612 AC_DEFUN([AC_TYPE_PID_T],  [AC_CHECK_TYPE(pid_t,  int)])
614 AN_IDENTIFIER([off_t], [AC_TYPE_OFF_T])
615 AC_DEFUN([AC_TYPE_OFF_T],  [AC_CHECK_TYPE(off_t,  long int)])
617 AN_IDENTIFIER([mode_t], [AC_TYPE_MODE_T])
618 AC_DEFUN([AC_TYPE_MODE_T], [AC_CHECK_TYPE(mode_t, int)])
620 AN_IDENTIFIER([int8_t], [AC_TYPE_INT8_T])
621 AN_IDENTIFIER([int16_t], [AC_TYPE_INT16_T])
622 AN_IDENTIFIER([int32_t], [AC_TYPE_INT32_T])
623 AN_IDENTIFIER([int64_t], [AC_TYPE_INT64_T])
624 AN_IDENTIFIER([uint8_t], [AC_TYPE_UINT8_T])
625 AN_IDENTIFIER([uint16_t], [AC_TYPE_UINT16_T])
626 AN_IDENTIFIER([uint32_t], [AC_TYPE_UINT32_T])
627 AN_IDENTIFIER([uint64_t], [AC_TYPE_UINT64_T])
628 AC_DEFUN([AC_TYPE_INT8_T], [_AC_TYPE_INT(8)])
629 AC_DEFUN([AC_TYPE_INT16_T], [_AC_TYPE_INT(16)])
630 AC_DEFUN([AC_TYPE_INT32_T], [_AC_TYPE_INT(32)])
631 AC_DEFUN([AC_TYPE_INT64_T], [_AC_TYPE_INT(64)])
632 AC_DEFUN([AC_TYPE_UINT8_T], [_AC_TYPE_UNSIGNED_INT(8)])
633 AC_DEFUN([AC_TYPE_UINT16_T], [_AC_TYPE_UNSIGNED_INT(16)])
634 AC_DEFUN([AC_TYPE_UINT32_T], [_AC_TYPE_UNSIGNED_INT(32)])
635 AC_DEFUN([AC_TYPE_UINT64_T], [_AC_TYPE_UNSIGNED_INT(64)])
637 # _AC_TYPE_INT_BODY
638 # -----------------
639 # Shell function body for _AC_TYPE_INT.
640 m4_define([_AC_TYPE_INT_BODY],
641 [  AS_LINENO_PUSH([$[]1])
642   AC_CACHE_CHECK([for int$[]2_t], [$[]3],
643     [AS_VAR_SET([$[]3], [no])
644      # Order is important - never check a type that is potentially smaller
645      # than half of the expected target width.
646      for ac_type in int$[]2_t 'int' 'long int' \
647          'long long int' 'short int' 'signed char'; do
648        AC_COMPILE_IFELSE(
649          [AC_LANG_BOOL_COMPILE_TRY(
650             [AC_INCLUDES_DEFAULT
651              enum { N = $[]2 / 2 - 1 };],
652             [0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)])],
653          [AC_COMPILE_IFELSE(
654             [AC_LANG_BOOL_COMPILE_TRY(
655                [AC_INCLUDES_DEFAULT
656                 enum { N = $[]2 / 2 - 1 };],
657                [($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)
658                  < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2)])],
659             [],
660             [AS_CASE([$ac_type], [int$[]2_t],
661                [AS_VAR_SET([$[]3], [yes])],
662                [AS_VAR_SET([$[]3], [$ac_type])])])])
663        AS_VAR_IF([$[]3], [no], [], [break])
664      done])
665   AS_LINENO_POP
666 ])# _AC_TYPE_INT_BODY
668 # _AC_TYPE_INT(NBITS)
669 # -------------------
670 # Set a variable ac_cv_c_intNBITS_t to `yes' if intNBITS_t is available,
671 # `no' if it is not and no replacement types could be found, and a C type
672 # if it is not available but a replacement signed integer type of width
673 # exactly NBITS bits was found.  In the third case, intNBITS_t is AC_DEFINEd
674 # to type, as well.
675 AC_DEFUN([_AC_TYPE_INT],
676 [AC_REQUIRE_SHELL_FN([ac_fn_c_find_intX_t],
677   [AS_FUNCTION_DESCRIBE([ac_fn_c_find_intX_t], [LINENO BITS VAR],
678     [Finds a signed integer type with width BITS, setting cache variable VAR
679      accordingly.])],
680     [$0_BODY])]dnl
681 [ac_fn_c_find_intX_t "$LINENO" "$1" "ac_cv_c_int$1_t"
682 case $ac_cv_c_int$1_t in #(
683   no|yes) ;; #(
684   *)
685     AC_DEFINE_UNQUOTED([int$1_t], [$ac_cv_c_int$1_t],
686       [Define to the type of a signed integer type of width exactly $1 bits
687        if such a type exists and the standard includes do not define it.]);;
688 esac
689 ])# _AC_TYPE_INT
691 # _AC_TYPE_UNSIGNED_INT_BODY
692 # --------------------------
693 # Shell function body for _AC_TYPE_UNSIGNED_INT.
694 m4_define([_AC_TYPE_UNSIGNED_INT_BODY],
695 [  AS_LINENO_PUSH([$[]1])
696   AC_CACHE_CHECK([for uint$[]2_t], $[]3,
697     [AS_VAR_SET([$[]3], [no])
698      # Order is important - never check a type that is potentially smaller
699      # than half of the expected target width.
700      for ac_type in uint$[]2_t 'unsigned int' 'unsigned long int' \
701          'unsigned long long int' 'unsigned short int' 'unsigned char'; do
702        AC_COMPILE_IFELSE(
703          [AC_LANG_BOOL_COMPILE_TRY(
704             [AC_INCLUDES_DEFAULT],
705             [(($ac_type) -1 >> ($[]2 / 2 - 1)) >> ($[]2 / 2 - 1) == 3])],
706          [AS_CASE([$ac_type], [uint$[]2_t],
707             [AS_VAR_SET([$[]3], [yes])],
708             [AS_VAR_SET([$[]3], [$ac_type])])])
709        AS_VAR_IF([$[]3], [no], [], [break])
710      done])
711   AS_LINENO_POP
712 ])# _AC_TYPE_UNSIGNED_INT_BODY
715 # _AC_TYPE_UNSIGNED_INT(NBITS)
716 # ----------------------------
717 # Set a variable ac_cv_c_uintNBITS_t to `yes' if uintNBITS_t is available,
718 # `no' if it is not and no replacement types could be found, and a C type
719 # if it is not available but a replacement unsigned integer type of width
720 # exactly NBITS bits was found.  In the third case, uintNBITS_t is AC_DEFINEd
721 # to type, as well.
722 AC_DEFUN([_AC_TYPE_UNSIGNED_INT],
723 [AC_REQUIRE_SHELL_FN([ac_fn_c_find_uintX_t],
724   [AS_FUNCTION_DESCRIBE([ac_fn_c_find_uintX_t], [LINENO BITS VAR],
725     [Finds an unsigned integer type with width BITS, setting cache variable VAR
726      accordingly.])],
727   [$0_BODY])]dnl
728 [ac_fn_c_find_uintX_t "$LINENO" "$1" "ac_cv_c_uint$1_t"
729 case $ac_cv_c_uint$1_t in #(
730   no|yes) ;; #(
731   *)
732     m4_bmatch([$1], [^\(8\|32\|64\)$],
733       [AC_DEFINE([_UINT$1_T], 1,
734          [Define for Solaris 2.5.1 so the uint$1_t typedef from
735           <sys/synch.h>, <pthread.h>, or <semaphore.h> is not used.
736           If the typedef were allowed, the #define below would cause a
737           syntax error.])])
738     AC_DEFINE_UNQUOTED([uint$1_t], [$ac_cv_c_uint$1_t],
739       [Define to the type of an unsigned integer type of width exactly $1 bits
740        if such a type exists and the standard includes do not define it.]);;
741   esac
742 ])# _AC_TYPE_UNSIGNED_INT
744 # AC_TYPE_SIGNAL
745 # --------------
746 # Note that identifiers starting with SIG are reserved by ANSI C.
747 # C89 requires signal handlers to return void; only K&R returned int;
748 # modern code does not need to worry about using this macro (not to
749 # mention that sigaction is better than signal).
750 AU_DEFUN([AC_TYPE_SIGNAL],
751 [AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
752 [AC_COMPILE_IFELSE(
753 [AC_LANG_PROGRAM([#include <sys/types.h>
754 #include <signal.h>
756                  [return *(signal (0, 0)) (0) == 1;])],
757                    [ac_cv_type_signal=int],
758                    [ac_cv_type_signal=void])])
759 AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal,
760                    [Define as the return type of signal handlers
761                     (`int' or `void').])
762 ], [your code may safely assume C89 semantics that RETSIGTYPE is void.
763 Remove this warning and the `AC_CACHE_CHECK' when you adjust the code.])
766 ## ------------------------ ##
767 ## Checking size of types.  ##
768 ## ------------------------ ##
770 # ---------------- #
771 # Generic checks.  #
772 # ---------------- #
775 # AC_CHECK_SIZEOF(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
776 # ---------------------------------------------------------------
777 AC_DEFUN([AC_CHECK_SIZEOF],
778 [AS_LITERAL_IF(m4_translit([[$1]], [*], [p]), [],
779                [m4_fatal([$0: requires literal arguments])])]dnl
780 [# The cast to long int works around a bug in the HP C Compiler
781 # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
782 # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
783 # This bug is HP SR number 8606223364.
784 _AC_CACHE_CHECK_INT([size of $1], [AS_TR_SH([ac_cv_sizeof_$1])],
785   [(long int) (sizeof ($1))],
786   [AC_INCLUDES_DEFAULT([$3])],
787   [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
788      AC_MSG_FAILURE([cannot compute sizeof ($1)], 77)
789    else
790      AS_TR_SH([ac_cv_sizeof_$1])=0
791    fi])
793 AC_DEFINE_UNQUOTED(AS_TR_CPP(sizeof_$1), $AS_TR_SH([ac_cv_sizeof_$1]),
794                    [The size of `$1', as computed by sizeof.])
795 ])# AC_CHECK_SIZEOF
798 # AC_CHECK_ALIGNOF(TYPE, [INCLUDES = DEFAULT-INCLUDES])
799 # -----------------------------------------------------
800 # TYPE can include braces and semicolon, which AS_TR_CPP and AS_TR_SH
801 # (correctly) recognize as potential shell metacharacters.  So we
802 # have to flatten problematic characters ourselves to guarantee that
803 # AC_DEFINE_UNQUOTED will see a literal.
804 AC_DEFUN([AC_CHECK_ALIGNOF],
805 [m4_if(m4_index(m4_translit([[$1]], [`\"], [$]), [$]), [-1], [],
806        [m4_fatal([$0: requires literal arguments])])]dnl
807 [_$0([$1], [$2], m4_translit([[$1]], [{;}], [___]))])
809 m4_define([_AC_CHECK_ALIGNOF],
810 [# The cast to long int works around a bug in the HP C Compiler,
811 # see AC_CHECK_SIZEOF for more information.
812 _AC_CACHE_CHECK_INT([alignment of $1], [AS_TR_SH([ac_cv_alignof_$3])],
813   [(long int) offsetof (ac__type_alignof_, y)],
814   [AC_INCLUDES_DEFAULT([$2])
815 typedef struct { char x; $1 y; } ac__type_alignof_;],
816   [if test "$AS_TR_SH([ac_cv_type_$3])" = yes; then
817      AC_MSG_FAILURE([cannot compute alignment of $1], 77)
818    else
819      AS_TR_SH([ac_cv_alignof_$3])=0
820    fi])
822 AC_DEFINE_UNQUOTED(AS_TR_CPP(alignof_$3), $AS_TR_SH([ac_cv_alignof_$3]),
823                    [The normal alignment of `$1', in bytes.])
824 ])# AC_CHECK_ALIGNOF
827 # AU::AC_INT_16_BITS
828 # ------------------
829 # What a great name :)
830 AU_DEFUN([AC_INT_16_BITS],
831 [AC_CHECK_SIZEOF([int])
832 test $ac_cv_sizeof_int = 2 &&
833   AC_DEFINE(INT_16_BITS, 1,
834             [Define to 1 if `sizeof (int)' = 2.  Obsolete, use `SIZEOF_INT'.])
835 ], [your code should no longer depend upon `INT_16_BITS', but upon
836 `SIZEOF_INT == 2'.  Remove this warning and the `AC_DEFINE' when you
837 adjust the code.])
840 # AU::AC_LONG_64_BITS
841 # -------------------
842 AU_DEFUN([AC_LONG_64_BITS],
843 [AC_CHECK_SIZEOF([long int])
844 test $ac_cv_sizeof_long_int = 8 &&
845   AC_DEFINE(LONG_64_BITS, 1,
846             [Define to 1 if `sizeof (long int)' = 8.  Obsolete, use
847              `SIZEOF_LONG_INT'.])
848 ], [your code should no longer depend upon `LONG_64_BITS', but upon
849 `SIZEOF_LONG_INT == 8'.  Remove this warning and the `AC_DEFINE' when
850 you adjust the code.])
854 ## -------------------------- ##
855 ## Generic structure checks.  ##
856 ## -------------------------- ##
859 # ---------------- #
860 # Generic checks.  #
861 # ---------------- #
863 # _AC_CHECK_MEMBER_BODY
864 # ---------------------
865 # Shell function body for AC_CHECK_MEMBER.
866 m4_define([_AC_CHECK_MEMBER_BODY],
867 [  AS_LINENO_PUSH([$[]1])
868   AC_CACHE_CHECK([for $[]2.$[]3], [$[]4],
869   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]5],
870 [static $[]2 ac_aggr;
871 if (ac_aggr.$[]3)
872 return 0;])],
873                 [AS_VAR_SET([$[]4], [yes])],
874   [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$[]5],
875 [static $[]2 ac_aggr;
876 if (sizeof ac_aggr.$[]3)
877 return 0;])],
878                 [AS_VAR_SET([$[]4], [yes])],
879                 [AS_VAR_SET([$[]4], [no])])])])
880   AS_LINENO_POP
881 ])dnl
883 # AC_CHECK_MEMBER(AGGREGATE.MEMBER,
884 #                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
885 #                 [INCLUDES = DEFAULT-INCLUDES])
886 # ---------------------------------------------------------
887 # AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
888 # variables are not a valid argument.
889 AC_DEFUN([AC_CHECK_MEMBER],
890 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_member],
891   [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_member],
892     [LINENO AGGR MEMBER VAR INCLUDES],
893     [Tries to find if the field MEMBER exists in type AGGR, after including
894      INCLUDES, setting cache variable VAR accordingly.])],
895     [_$0_BODY])]dnl
896 [AS_LITERAL_IF([$1], [], [m4_fatal([$0: requires literal arguments])])]dnl
897 [m4_if(m4_index([$1], [.]), [-1],
898   [m4_fatal([$0: Did not see any dot in `$1'])])]dnl
899 [AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])]dnl
900 [ac_fn_[]_AC_LANG_ABBREV[]_check_member "$LINENO" ]dnl
901 [m4_bpatsubst([$1], [^\([^.]*\)\.\(.*\)], ["\1" "\2"]) "ac_Member" ]dnl
902 ["AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])"
903 AS_VAR_IF([ac_Member], [yes], [$2], [$3])
904 AS_VAR_POPDEF([ac_Member])dnl
905 ])# AC_CHECK_MEMBER
908 # _AC_CHECK_MEMBERS(AGGREGATE.MEMBER)
909 # -----------------------------------
910 # Helper to AC_CHECK_MEMBERS, which generates two of the four
911 # arguments to AC_CHECK_MEMBER that are based on AGGREGATE and MEMBER.
912 m4_define([_AC_CHECK_MEMBERS],
913 [[$1], [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]), [1],
914   [Define to 1 if `]m4_bpatsubst([$1],
915     [^\([^.]*\)\.\(.*\)], [[\2' is a member of `\1]])['.])]])
917 # AC_CHECK_MEMBERS([AGGREGATE.MEMBER, ...],
918 #                  [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
919 #                  [INCLUDES = DEFAULT-INCLUDES])
920 # ----------------------------------------------------------
921 # The first argument is an m4 list.
922 AC_DEFUN([AC_CHECK_MEMBERS],
923 [m4_map_args_sep([AC_CHECK_MEMBER(_$0(], [)[
924 $2], [$3], [$4])], [], $1)])
928 # ------------------------------------------------------- #
929 # Members that ought to be tested with AC_CHECK_MEMBERS.  #
930 # ------------------------------------------------------- #
932 AN_IDENTIFIER([st_blksize], [AC_CHECK_MEMBERS([struct stat.st_blksize])])
933 AN_IDENTIFIER([st_rdev],    [AC_CHECK_MEMBERS([struct stat.st_rdev])])
936 # Alphabetic order, please.
938 # _AC_STRUCT_DIRENT(MEMBER)
939 # -------------------------
940 AC_DEFUN([_AC_STRUCT_DIRENT],
942   AC_REQUIRE([AC_HEADER_DIRENT])
943   AC_CHECK_MEMBERS([struct dirent.$1], [], [],
944     [[
945 #include <sys/types.h>
946 #ifdef HAVE_DIRENT_H
947 # include <dirent.h>
948 #else
949 # define dirent direct
950 # ifdef HAVE_SYS_NDIR_H
951 #  include <sys/ndir.h>
952 # endif
953 # ifdef HAVE_SYS_DIR_H
954 #  include <sys/dir.h>
955 # endif
956 # ifdef HAVE_NDIR_H
957 #  include <ndir.h>
958 # endif
959 #endif
960     ]])
963 # AC_STRUCT_DIRENT_D_INO
964 # ----------------------
965 AC_DEFUN([AC_STRUCT_DIRENT_D_INO], [_AC_STRUCT_DIRENT([d_ino])])
967 # AC_STRUCT_DIRENT_D_TYPE
968 # -----------------------
969 AC_DEFUN([AC_STRUCT_DIRENT_D_TYPE], [_AC_STRUCT_DIRENT([d_type])])
972 # AC_STRUCT_ST_BLKSIZE
973 # --------------------
974 AU_DEFUN([AC_STRUCT_ST_BLKSIZE],
975 [AC_CHECK_MEMBERS([struct stat.st_blksize],
976                  [AC_DEFINE(HAVE_ST_BLKSIZE, 1,
977                             [Define to 1 if your `struct stat' has
978                              `st_blksize'.  Deprecated, use
979                              `HAVE_STRUCT_STAT_ST_BLKSIZE' instead.])])
980 ], [your code should no longer depend upon `HAVE_ST_BLKSIZE', but
981 `HAVE_STRUCT_STAT_ST_BLKSIZE'.  Remove this warning and
982 the `AC_DEFINE' when you adjust the code.])# AC_STRUCT_ST_BLKSIZE
985 # AC_STRUCT_ST_BLOCKS
986 # -------------------
987 # If `struct stat' contains an `st_blocks' member, define
988 # HAVE_STRUCT_STAT_ST_BLOCKS.  Otherwise, add `fileblocks.o' to the
989 # output variable LIBOBJS.  We still define HAVE_ST_BLOCKS for backward
990 # compatibility.  In the future, we will activate specializations for
991 # this macro, so don't obsolete it right now.
993 # AC_OBSOLETE([$0], [; replace it with
994 #   AC_CHECK_MEMBERS([struct stat.st_blocks],
995 #                     [AC_LIBOBJ([fileblocks])])
996 # Please note that it will define `HAVE_STRUCT_STAT_ST_BLOCKS',
997 # and not `HAVE_ST_BLOCKS'.])dnl
999 AN_IDENTIFIER([st_blocks],  [AC_STRUCT_ST_BLOCKS])
1000 AC_DEFUN([AC_STRUCT_ST_BLOCKS],
1001 [AC_CHECK_MEMBERS([struct stat.st_blocks],
1002                   [AC_DEFINE(HAVE_ST_BLOCKS, 1,
1003                              [Define to 1 if your `struct stat' has
1004                               `st_blocks'.  Deprecated, use
1005                               `HAVE_STRUCT_STAT_ST_BLOCKS' instead.])],
1006                   [AC_LIBOBJ([fileblocks])])
1007 ])# AC_STRUCT_ST_BLOCKS
1010 # AC_STRUCT_ST_RDEV
1011 # -----------------
1012 AU_DEFUN([AC_STRUCT_ST_RDEV],
1013 [AC_CHECK_MEMBERS([struct stat.st_rdev],
1014                  [AC_DEFINE(HAVE_ST_RDEV, 1,
1015                             [Define to 1 if your `struct stat' has `st_rdev'.
1016                              Deprecated, use `HAVE_STRUCT_STAT_ST_RDEV'
1017                              instead.])])
1018 ], [your code should no longer depend upon `HAVE_ST_RDEV', but
1019 `HAVE_STRUCT_STAT_ST_RDEV'.  Remove this warning and
1020 the `AC_DEFINE' when you adjust the code.])# AC_STRUCT_ST_RDEV
1023 # AC_STRUCT_TM
1024 # ------------
1025 # FIXME: This macro is badly named, it should be AC_CHECK_TYPE_STRUCT_TM.
1026 # Or something else, but what? AC_CHECK_TYPE_STRUCT_TM_IN_SYS_TIME?
1027 AC_DEFUN([AC_STRUCT_TM],
1028 [AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
1029   ac_cv_struct_tm,
1030 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
1031 #include <time.h>
1033                                     [struct tm tm;
1034                                      int *p = &tm.tm_sec;
1035                                      return !p;])],
1036                    [ac_cv_struct_tm=time.h],
1037                    [ac_cv_struct_tm=sys/time.h])])
1038 if test $ac_cv_struct_tm = sys/time.h; then
1039   AC_DEFINE(TM_IN_SYS_TIME, 1,
1040             [Define to 1 if your <sys/time.h> declares `struct tm'.])
1042 ])# AC_STRUCT_TM
1045 # AC_STRUCT_TIMEZONE
1046 # ------------------
1047 # Figure out how to get the current timezone.  If `struct tm' has a
1048 # `tm_zone' member, define `HAVE_TM_ZONE'.  Otherwise, if the
1049 # external array `tzname' is found, define `HAVE_TZNAME'.
1050 AN_IDENTIFIER([tm_zone], [AC_STRUCT_TIMEZONE])
1051 AC_DEFUN([AC_STRUCT_TIMEZONE],
1052 [AC_REQUIRE([AC_STRUCT_TM])dnl
1053 AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
1054 #include <$ac_cv_struct_tm>
1056 if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
1057   AC_DEFINE(HAVE_TM_ZONE, 1,
1058             [Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
1059              `HAVE_STRUCT_TM_TM_ZONE' instead.])
1060 else
1061   AC_CHECK_DECLS([tzname], , , [#include <time.h>])
1062   AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
1063 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
1064 [[#include <time.h>
1065 #if !HAVE_DECL_TZNAME
1066 extern char *tzname[];
1067 #endif
1069 [[return tzname[0][0];]])],
1070                 [ac_cv_var_tzname=yes],
1071                 [ac_cv_var_tzname=no])])
1072   if test $ac_cv_var_tzname = yes; then
1073     AC_DEFINE(HAVE_TZNAME, 1,
1074               [Define to 1 if you don't have `tm_zone' but do have the external
1075                array `tzname'.])
1076   fi
1078 ])# AC_STRUCT_TIMEZONE