Install msysDTK-1.0.1
[msysgit.git] / share / autoconf / autoconf / types.m4
blob86d48b7267e52ba03978824287d05a4a051c97d4
1 # This file is part of Autoconf.                       -*- Autoconf -*-
2 # Type related macros: existence, sizeof, and structure members.
3 # Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 # 02111-1307, USA.
20 # As a special exception, the Free Software Foundation gives unlimited
21 # permission to copy, distribute and modify the configure scripts that
22 # are the output of Autoconf.  You need not follow the terms of the GNU
23 # General Public License when using or distributing such scripts, even
24 # though portions of the text of Autoconf appear in them.  The GNU
25 # General Public License (GPL) does govern all other use of the material
26 # that constitutes the Autoconf program.
28 # Certain portions of the Autoconf source text are designed to be copied
29 # (in certain cases, depending on the input) into the output of
30 # Autoconf.  We call these the "data" portions.  The rest of the Autoconf
31 # source text consists of comments plus executable code that decides which
32 # of the data portions to output in any given case.  We call these
33 # comments and executable code the "non-data" portions.  Autoconf never
34 # copies any of the non-data portions into its output.
36 # This special exception to the GPL applies to versions of Autoconf
37 # released by the Free Software Foundation.  When you make and
38 # distribute a modified version of Autoconf, you may extend this special
39 # exception to the GPL to apply to your modified version as well, *unless*
40 # your modified version has the potential to copy into its output some
41 # of the text that was the non-data portion of the version that you started
42 # with.  (In other words, unless your change moves or copies text from
43 # the non-data portions to the data portions.)  If your modification has
44 # such potential, you must delete any notice of this special exception
45 # to the GPL from your modified version.
47 # Written by David MacKenzie, with help from
48 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
49 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
52 ## ---------------- ##
53 ## Type existence.  ##
54 ## ---------------- ##
56 # ---------------- #
57 # General checks.  #
58 # ---------------- #
60 # Up to 2.13 included, Autoconf used to provide the macro
62 #    AC_CHECK_TYPE(TYPE, DEFAULT)
64 # Since, it provides another version which fits better with the other
65 # AC_CHECK_ families:
67 #    AC_CHECK_TYPE(TYPE,
68 #                  [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
69 #                  [INCLUDES])
71 # In order to provide backward compatibility, the new scheme is
72 # implemented as _AC_CHECK_TYPE_NEW, the old scheme as _AC_CHECK_TYPE_OLD,
73 # and AC_CHECK_TYPE branches to one or the other, depending upon its
74 # arguments.
78 # _AC_CHECK_TYPE_NEW(TYPE,
79 #                    [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
80 #                    [INCLUDES = DEFAULT-INCLUDES])
81 # ------------------------------------------------------------
82 # Check whether the type TYPE is supported by the system, maybe via the
83 # the provided includes.  This macro implements the former task of
84 # AC_CHECK_TYPE, with one big difference though: AC_CHECK_TYPE was
85 # grepping in the headers, which, BTW, led to many problems until the
86 # extended regular expression was correct and did not given false positives.
87 # It turned out there are even portability issues with egrep...
89 # The most obvious way to check for a TYPE is just to compile a variable
90 # definition:
92 #         TYPE my_var;
94 # Unfortunately this does not work for const qualified types in C++,
95 # where you need an initializer.  So you think of
97 #         TYPE my_var = (TYPE) 0;
99 # Unfortunately, again, this is not valid for some C++ classes.
101 # Then you look for another scheme.  For instance you think of declaring
102 # a function which uses a parameter of type TYPE:
104 #         int foo (TYPE param);
106 # but of course you soon realize this does not make it with K&R
107 # compilers.  And by no ways you want to
109 #         int foo (param)
110 #           TYPE param
111 #         { ; }
113 # since this time it's C++ who is not happy.
115 # Don't even think of the return type of a function, since K&R cries
116 # there too.  So you start thinking of declaring a *pointer* to this TYPE:
118 #         TYPE *p;
120 # but you know fairly well that this is legal in C for aggregates which
121 # are unknown (TYPE = struct does-not-exist).
123 # Then you think of using sizeof to make sure the TYPE is really
124 # defined:
126 #         sizeof (TYPE);
128 # But this succeeds if TYPE is a variable: you get the size of the
129 # variable's type!!!
131 # This time you tell yourself the last two options *together* will make
132 # it.  And indeed this is the solution invented by Alexandre Oliva.
134 # Also note that we use
136 #         if (sizeof (TYPE))
138 # to `read' sizeof (to avoid warnings), while not depending on its type
139 # (not necessarily size_t etc.).  Equally, instead of defining an unused
140 # variable, we just use a cast to avoid warnings from the compiler.
141 # Suggested by Paul Eggert.
142 m4_define([_AC_CHECK_TYPE_NEW],
143 [AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
144 AC_CACHE_CHECK([for $1], ac_Type,
145 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
146 [if (($1 *) 0)
147   return 0;
148 if (sizeof ($1))
149   return 0;])],
150                    [AS_VAR_SET(ac_Type, yes)],
151                    [AS_VAR_SET(ac_Type, no)])])
152 AS_IF([test AS_VAR_GET(ac_Type) = yes], [$2], [$3])[]dnl
153 AS_VAR_POPDEF([ac_Type])dnl
154 ])# _AC_CHECK_TYPE_NEW
157 # AC_CHECK_TYPES(TYPES,
158 #                [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
159 #                [INCLUDES = DEFAULT-INCLUDES])
160 # --------------------------------------------------------
161 # TYPES is an m4 list.  There are no ambiguities here, we mean the newer
162 # AC_CHECK_TYPE.
163 AC_DEFUN([AC_CHECK_TYPES],
164 [m4_foreach([AC_Type], [$1],
165   [_AC_CHECK_TYPE_NEW(AC_Type,
166                       [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Type), 1,
167                                           [Define to 1 if the system has the
168                                            type `]AC_Type['.])
169 $2],
170                       [$3],
171                       [$4])])])
174 # _AC_CHECK_TYPE_OLD(TYPE, DEFAULT)
175 # ---------------------------------
176 # FIXME: This is an extremely badly chosen name, since this
177 # macro actually performs an AC_REPLACE_TYPE.  Some day we
178 # have to clean this up.
179 m4_define([_AC_CHECK_TYPE_OLD],
180 [_AC_CHECK_TYPE_NEW([$1],,
181    [AC_DEFINE_UNQUOTED([$1], [$2],
182                        [Define to `$2' if <sys/types.h> does not define.])])dnl
183 ])# _AC_CHECK_TYPE_OLD
186 # _AC_CHECK_TYPE_REPLACEMENT_TYPE_P(STRING)
187 # -----------------------------------------
188 # Return `1' if STRING seems to be a builtin C/C++ type, i.e., if it
189 # starts with `_Bool', `bool', `char', `double', `float', `int',
190 # `long', `short', `signed', or `unsigned' followed by characters
191 # that are defining types.
192 # Because many people have used `off_t' and `size_t' too, they are added
193 # for better common-useward backward compatibility.
194 m4_define([_AC_CHECK_TYPE_REPLACEMENT_TYPE_P],
195 [m4_bmatch([$1],
196           [^\(_Bool\|bool\|char\|double\|float\|int\|long\|short\|\(un\)?signed\|[_a-zA-Z][_a-zA-Z0-9]*_t\)[][_a-zA-Z0-9() *]*$],
197           1, 0)dnl
198 ])# _AC_CHECK_TYPE_REPLACEMENT_TYPE_P
201 # _AC_CHECK_TYPE_MAYBE_TYPE_P(STRING)
202 # -----------------------------------
203 # Return `1' if STRING looks like a C/C++ type.
204 m4_define([_AC_CHECK_TYPE_MAYBE_TYPE_P],
205 [m4_bmatch([$1], [^[_a-zA-Z0-9 ]+\([_a-zA-Z0-9() *]\|\[\|\]\)*$],
206           1, 0)dnl
207 ])# _AC_CHECK_TYPE_MAYBE_TYPE_P
210 # AC_CHECK_TYPE(TYPE, DEFAULT)
211 #  or
212 # AC_CHECK_TYPE(TYPE,
213 #               [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
214 #               [INCLUDES = DEFAULT-INCLUDES])
215 # -------------------------------------------------------
217 # Dispatch respectively to _AC_CHECK_TYPE_OLD or _AC_CHECK_TYPE_NEW.
218 # 1. More than two arguments         => NEW
219 # 2. $2 seems to be replacement type => OLD
220 #    See _AC_CHECK_TYPE_REPLACEMENT_TYPE_P for `replacement type'.
221 # 3. $2 seems to be a type           => NEW plus a warning
222 # 4. default                         => NEW
223 AC_DEFUN([AC_CHECK_TYPE],
224 [m4_if($#, 3,
225          [_AC_CHECK_TYPE_NEW($@)],
226        $#, 4,
227          [_AC_CHECK_TYPE_NEW($@)],
228        _AC_CHECK_TYPE_REPLACEMENT_TYPE_P([$2]), 1,
229          [_AC_CHECK_TYPE_OLD($@)],
230        _AC_CHECK_TYPE_MAYBE_TYPE_P([$2]), 1,
231          [AC_DIAGNOSE([syntax],
232                     [$0: assuming `$2' is not a type])_AC_CHECK_TYPE_NEW($@)],
233        [_AC_CHECK_TYPE_NEW($@)])[]dnl
234 ])# AC_CHECK_TYPE
238 # ---------------------------- #
239 # Types that must be checked.  #
240 # ---------------------------- #
242 AN_IDENTIFIER([ptrdiff_t], [AC_CHECK_TYPES])
245 # ----------------- #
246 # Specific checks.  #
247 # ----------------- #
249 # AC_TYPE_GETGROUPS
250 # -----------------
251 AC_DEFUN([AC_TYPE_GETGROUPS],
252 [AC_REQUIRE([AC_TYPE_UID_T])dnl
253 AC_CACHE_CHECK(type of array argument to getgroups, ac_cv_type_getgroups,
254 [AC_RUN_IFELSE([AC_LANG_SOURCE(
255 [[/* Thanks to Mike Rendell for this test.  */
256 #include <sys/types.h>
257 #define NGID 256
258 #undef MAX
259 #define MAX(x, y) ((x) > (y) ? (x) : (y))
262 main ()
264   gid_t gidset[NGID];
265   int i, n;
266   union { gid_t gval; long lval; }  val;
268   val.lval = -1;
269   for (i = 0; i < NGID; i++)
270     gidset[i] = val.gval;
271   n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1,
272                  gidset);
273   /* Exit non-zero if getgroups seems to require an array of ints.  This
274      happens when gid_t is short but getgroups modifies an array of ints.  */
275   exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0);
276 }]])],
277                [ac_cv_type_getgroups=gid_t],
278                [ac_cv_type_getgroups=int],
279                [ac_cv_type_getgroups=cross])
280 if test $ac_cv_type_getgroups = cross; then
281   dnl When we can't run the test program (we are cross compiling), presume
282   dnl that <unistd.h> has either an accurate prototype for getgroups or none.
283   dnl Old systems without prototypes probably use int.
284   AC_EGREP_HEADER([getgroups.*int.*gid_t], unistd.h,
285                   ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int)
286 fi])
287 AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups,
288                    [Define to the type of elements in the array set by
289                     `getgroups'. Usually this is either `int' or `gid_t'.])
290 ])# AC_TYPE_GETGROUPS
293 # AU::AM_TYPE_PTRDIFF_T
294 # ---------------------
295 AU_DEFUN([AM_TYPE_PTRDIFF_T],
296 [AC_CHECK_TYPES(ptrdiff_t)])
299 # AC_TYPE_MBSTATE_T
300 # -----------------
301 AC_DEFUN([AC_TYPE_MBSTATE_T],
302   [AC_CACHE_CHECK([for mbstate_t], ac_cv_type_mbstate_t,
303      [AC_COMPILE_IFELSE(
304         [AC_LANG_PROGRAM(
305            [AC_INCLUDES_DEFAULT
306 #           include <wchar.h>],
307            [mbstate_t x; return sizeof x;])],
308         [ac_cv_type_mbstate_t=yes],
309         [ac_cv_type_mbstate_t=no])])
310    if test $ac_cv_type_mbstate_t = yes; then
311      AC_DEFINE([HAVE_MBSTATE_T], 1,
312                [Define to 1 if <wchar.h> declares mbstate_t.])
313    else
314      AC_DEFINE([mbstate_t], int,
315                [Define to a type if <wchar.h> does not define.])
316    fi])
319 # AC_TYPE_UID_T
320 # -------------
321 # FIXME: Rewrite using AC_CHECK_TYPE.
322 AN_IDENTIFIER([gid_t], [AC_TYPE_UID_T])
323 AN_IDENTIFIER([uid_t], [AC_TYPE_UID_T])
324 AC_DEFUN([AC_TYPE_UID_T],
325 [AC_CACHE_CHECK(for uid_t in sys/types.h, ac_cv_type_uid_t,
326 [AC_EGREP_HEADER(uid_t, sys/types.h,
327   ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])
328 if test $ac_cv_type_uid_t = no; then
329   AC_DEFINE(uid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
330   AC_DEFINE(gid_t, int, [Define to `int' if <sys/types.h> doesn't define.])
335 AN_IDENTIFIER([size_t], [AC_TYPE_SIZE_T])
336 AC_DEFUN([AC_TYPE_SIZE_T], [AC_CHECK_TYPE(size_t, unsigned)])
338 AN_IDENTIFIER([pid_t], [AC_TYPE_PID_T])
339 AC_DEFUN([AC_TYPE_PID_T],  [AC_CHECK_TYPE(pid_t,  int)])
341 AN_IDENTIFIER([off_t], [AC_TYPE_OFF_T])
342 AC_DEFUN([AC_TYPE_OFF_T],  [AC_CHECK_TYPE(off_t,  long)])
344 AN_IDENTIFIER([mode_t], [AC_TYPE_MODE_T])
345 AC_DEFUN([AC_TYPE_MODE_T], [AC_CHECK_TYPE(mode_t, int)])
348 # AC_TYPE_SIGNAL
349 # --------------
350 # Note that identifiers starting with SIG are reserved by ANSI C.
351 AN_FUNCTION([signal],  [AC_TYPE_SIGNAL])
352 AC_DEFUN([AC_TYPE_SIGNAL],
353 [AC_CACHE_CHECK([return type of signal handlers], ac_cv_type_signal,
354 [AC_COMPILE_IFELSE(
355 [AC_LANG_PROGRAM([#include <sys/types.h>
356 #include <signal.h>
357 #ifdef signal
358 # undef signal
359 #endif
360 #ifdef __cplusplus
361 extern "C" void (*signal (int, void (*)(int)))(int);
362 #else
363 void (*signal ()) ();
364 #endif
366                  [int i;])],
367                    [ac_cv_type_signal=void],
368                    [ac_cv_type_signal=int])])
369 AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal,
370                    [Define as the return type of signal handlers
371                     (`int' or `void').])
375 ## ------------------------ ##
376 ## Checking size of types.  ##
377 ## ------------------------ ##
379 # ---------------- #
380 # Generic checks.  #
381 # ---------------- #
384 # AC_CHECK_SIZEOF(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
385 # ---------------------------------------------------------------
386 AC_DEFUN([AC_CHECK_SIZEOF],
387 [AS_LITERAL_IF([$1], [],
388                [AC_FATAL([$0: requires literal arguments])])dnl
389 AC_CHECK_TYPE([$1], [], [], [$3])
390 AC_CACHE_CHECK([size of $1], AS_TR_SH([ac_cv_sizeof_$1]),
391 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
392   # The cast to unsigned long works around a bug in the HP C Compiler
393   # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
394   # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
395   # This bug is HP SR number 8606223364.
396   _AC_COMPUTE_INT([(long) (sizeof ($1))],
397                   [AS_TR_SH([ac_cv_sizeof_$1])],
398                   [AC_INCLUDES_DEFAULT([$3])],
399                   [AC_MSG_FAILURE([cannot compute sizeof ($1), 77])])
400 else
401   AS_TR_SH([ac_cv_sizeof_$1])=0
402 fi])dnl
403 AC_DEFINE_UNQUOTED(AS_TR_CPP(sizeof_$1), $AS_TR_SH([ac_cv_sizeof_$1]),
404                    [The size of a `$1', as computed by sizeof.])
405 ])# AC_CHECK_SIZEOF
409 # ---------------- #
410 # Generic checks.  #
411 # ---------------- #
413 # AU::AC_INT_16_BITS
414 # ------------------
415 # What a great name :)
416 AU_DEFUN([AC_INT_16_BITS],
417 [AC_CHECK_SIZEOF([int])
418 AC_DIAGNOSE([obsolete], [$0:
419         your code should no longer depend upon `INT_16_BITS', but upon
420         `SIZEOF_INT'.  Remove this warning and the `AC_DEFINE' when you
421         adjust the code.])dnl
422 test $ac_cv_sizeof_int = 2 &&
423   AC_DEFINE(INT_16_BITS, 1,
424             [Define to 1 if `sizeof (int)' = 2.  Obsolete, use `SIZEOF_INT'.])
428 # AU::AC_LONG_64_BITS
429 # -------------------
430 AU_DEFUN([AC_LONG_64_BITS],
431 [AC_CHECK_SIZEOF([long int])
432 AC_DIAGNOSE([obsolete], [$0:
433         your code should no longer depend upon `LONG_64_BITS', but upon
434         `SIZEOF_LONG_INT'.  Remove this warning and the `AC_DEFINE' when
435         you adjust the code.])dnl
436 test $ac_cv_sizeof_long_int = 8 &&
437   AC_DEFINE(LONG_64_BITS, 1,
438             [Define to 1 if `sizeof (long int)' = 8.  Obsolete, use
439              `SIZEOF_LONG_INT'.])
444 ## -------------------------- ##
445 ## Generic structure checks.  ##
446 ## -------------------------- ##
449 # ---------------- #
450 # Generic checks.  #
451 # ---------------- #
453 # AC_CHECK_MEMBER(AGGREGATE.MEMBER,
454 #                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
455 #                 [INCLUDES])
456 # ---------------------------------------------------------
457 # AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell
458 # variables are not a valid argument.
459 AC_DEFUN([AC_CHECK_MEMBER],
460 [AS_LITERAL_IF([$1], [],
461                [AC_FATAL([$0: requires literal arguments])])dnl
462 m4_bmatch([$1], [\.], ,
463          [m4_fatal([$0: Did not see any dot in `$1'])])dnl
464 AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl
465 dnl Extract the aggregate name, and the member name
466 AC_CACHE_CHECK([for $1], ac_Member,
467 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
468 [dnl AGGREGATE ac_aggr;
469 static m4_bpatsubst([$1], [\..*]) ac_aggr;
470 dnl ac_aggr.MEMBER;
471 if (ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))
472 return 0;])],
473                 [AS_VAR_SET(ac_Member, yes)],
474 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
475 [dnl AGGREGATE ac_aggr;
476 static m4_bpatsubst([$1], [\..*]) ac_aggr;
477 dnl sizeof ac_aggr.MEMBER;
478 if (sizeof ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))
479 return 0;])],
480                 [AS_VAR_SET(ac_Member, yes)],
481                 [AS_VAR_SET(ac_Member, no)])])])
482 AS_IF([test AS_VAR_GET(ac_Member) = yes], [$2], [$3])dnl
483 AS_VAR_POPDEF([ac_Member])dnl
484 ])# AC_CHECK_MEMBER
487 # AC_CHECK_MEMBERS([AGGREGATE.MEMBER, ...],
488 #                  [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]
489 #                  [INCLUDES])
490 # ---------------------------------------------------------
491 # The first argument is an m4 list.
492 AC_DEFUN([AC_CHECK_MEMBERS],
493 [m4_foreach([AC_Member], [$1],
494   [AC_CHECK_MEMBER(AC_Member,
495          [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Member), 1,
496                             [Define to 1 if `]m4_bpatsubst(AC_Member,
497                                                      [^[^.]*\.])[' is
498                              member of `]m4_bpatsubst(AC_Member, [\..*])['.])
499 $2],
500                  [$3],
501                  [$4])])])
505 # ------------------------------------------------------- #
506 # Members that ought to be tested with AC_CHECK_MEMBERS.  #
507 # ------------------------------------------------------- #
509 AN_IDENTIFIER([st_blksize], [AC_CHECK_MEMBERS([struct stat.st_blksize])])
510 AN_IDENTIFIER([st_rdev],    [AC_CHECK_MEMBERS([struct stat.st_rdev])])
513 # Alphabetic order, please.
515 # AC_STRUCT_ST_BLKSIZE
516 # --------------------
517 AU_DEFUN([AC_STRUCT_ST_BLKSIZE],
518 [AC_DIAGNOSE([obsolete], [$0:
519         your code should no longer depend upon `HAVE_ST_BLKSIZE', but
520         `HAVE_STRUCT_STAT_ST_BLKSIZE'.  Remove this warning and
521         the `AC_DEFINE' when you adjust the code.])
522 AC_CHECK_MEMBERS([struct stat.st_blksize],
523                  [AC_DEFINE(HAVE_ST_BLKSIZE, 1,
524                             [Define to 1 if your `struct stat' has
525                              `st_blksize'.  Deprecated, use
526                              `HAVE_STRUCT_STAT_ST_BLKSIZE' instead.])])
527 ])# AC_STRUCT_ST_BLKSIZE
530 # AC_STRUCT_ST_BLOCKS
531 # -------------------
532 # If `struct stat' contains an `st_blocks' member, define
533 # HAVE_STRUCT_STAT_ST_BLOCKS.  Otherwise, add `fileblocks.o' to the
534 # output variable LIBOBJS.  We still define HAVE_ST_BLOCKS for backward
535 # compatibility.  In the future, we will activate specializations for
536 # this macro, so don't obsolete it right now.
538 # AC_OBSOLETE([$0], [; replace it with
539 #   AC_CHECK_MEMBERS([struct stat.st_blocks],
540 #                     [AC_LIBOBJ([fileblocks])])
541 # Please note that it will define `HAVE_STRUCT_STAT_ST_BLOCKS',
542 # and not `HAVE_ST_BLOCKS'.])dnl
544 AN_IDENTIFIER([st_blocks],  [AC_STRUCT_ST_BLOCKS])
545 AC_DEFUN([AC_STRUCT_ST_BLOCKS],
546 [AC_CHECK_MEMBERS([struct stat.st_blocks],
547                   [AC_DEFINE(HAVE_ST_BLOCKS, 1,
548                              [Define to 1 if your `struct stat' has
549                               `st_blocks'.  Deprecated, use
550                               `HAVE_STRUCT_STAT_ST_BLOCKS' instead.])],
551                   [AC_LIBOBJ([fileblocks])])
552 ])# AC_STRUCT_ST_BLOCKS
555 # AC_STRUCT_ST_RDEV
556 # -----------------
557 AU_DEFUN([AC_STRUCT_ST_RDEV],
558 [AC_DIAGNOSE([obsolete], [$0:
559         your code should no longer depend upon `HAVE_ST_RDEV', but
560         `HAVE_STRUCT_STAT_ST_RDEV'.  Remove this warning and
561         the `AC_DEFINE' when you adjust the code.])
562 AC_CHECK_MEMBERS([struct stat.st_rdev],
563                  [AC_DEFINE(HAVE_ST_RDEV, 1,
564                             [Define to 1 if your `struct stat' has `st_rdev'.
565                              Deprecated, use `HAVE_STRUCT_STAT_ST_RDEV'
566                              instead.])])
567 ])# AC_STRUCT_ST_RDEV
570 # AC_STRUCT_TM
571 # ------------
572 # FIXME: This macro is badly named, it should be AC_CHECK_TYPE_STRUCT_TM.
573 # Or something else, but what? AC_CHECK_TYPE_STRUCT_TM_IN_SYS_TIME?
574 AN_IDENTIFIER([tm], [AC_STRUCT_TM])
575 AC_DEFUN([AC_STRUCT_TM],
576 [AC_CACHE_CHECK([whether struct tm is in sys/time.h or time.h],
577   ac_cv_struct_tm,
578 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
579 #include <time.h>
581                                     [struct tm *tp; tp->tm_sec;])],
582                    [ac_cv_struct_tm=time.h],
583                    [ac_cv_struct_tm=sys/time.h])])
584 if test $ac_cv_struct_tm = sys/time.h; then
585   AC_DEFINE(TM_IN_SYS_TIME, 1,
586             [Define to 1 if your <sys/time.h> declares `struct tm'.])
588 ])# AC_STRUCT_TM
591 # AC_STRUCT_TIMEZONE
592 # ------------------
593 # Figure out how to get the current timezone.  If `struct tm' has a
594 # `tm_zone' member, define `HAVE_TM_ZONE'.  Otherwise, if the
595 # external array `tzname' is found, define `HAVE_TZNAME'.
596 AN_IDENTIFIER([tm_zone], [AC_STRUCT_TIMEZONE])
597 AC_DEFUN([AC_STRUCT_TIMEZONE],
598 [AC_REQUIRE([AC_STRUCT_TM])dnl
599 AC_CHECK_MEMBERS([struct tm.tm_zone],,,[#include <sys/types.h>
600 #include <$ac_cv_struct_tm>
602 if test "$ac_cv_member_struct_tm_tm_zone" = yes; then
603   AC_DEFINE(HAVE_TM_ZONE, 1,
604             [Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
605              `HAVE_STRUCT_TM_TM_ZONE' instead.])
606 else
607   AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
608 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
609 [[#include <time.h>
610 #ifndef tzname /* For SGI.  */
611 extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
612 #endif
614 [atoi(*tzname);])],
615                 [ac_cv_var_tzname=yes],
616                 [ac_cv_var_tzname=no])])
617   if test $ac_cv_var_tzname = yes; then
618     AC_DEFINE(HAVE_TZNAME, 1,
619               [Define to 1 if you don't have `tm_zone' but do have the external
620                array `tzname'.])
621   fi
623 ])# AC_STRUCT_TIMEZONE