* acgeneral.m4 (AC_C_STRUCT_MEMBER): New macro.
* acspecific.m4 (AC_STRUCT_TIMEZONE): Rewrite in terms of
AC_C_STRUCT_MEMBER.
(AC_STRUCT_ST_BLOCKS): Likewise.
(AC_STRUCT_ST_BLKSIZE): Likewise.
(AC_STRUCT_ST_RDEV): Likewise.
* autoconf.texi (Structures): Update. Add menu for subnodes.
(Particular Structures): New node.
(Generic Structures): New node.
(AC_C_STRUCT_MEMBER): Document.
+1999-04-11 Ben Elliston <bje@cygnus.com>
+
+ * acgeneral.m4 (AC_C_STRUCT_MEMBER): New macro.
+ * acspecific.m4 (AC_STRUCT_TIMEZONE): Rewrite in terms of
+ AC_C_STRUCT_MEMBER.
+ (AC_STRUCT_ST_BLOCKS): Likewise.
+ (AC_STRUCT_ST_BLKSIZE): Likewise.
+ (AC_STRUCT_ST_RDEV): Likewise.
+ * autoconf.texi (Structures): Update. Add menu for subnodes.
+ (Particular Structures): New node.
+ (Generic Structures): New node.
+ (AC_C_STRUCT_MEMBER): Document.
+
1999-04-10 Ben Elliston <bje@cygnus.com>
* mkinstalldirs: Add `-m' flag to specify the mode of a newly
)])
+dnl ### Generic structure checks
+
+dnl Check if a particular structure member exists.
+dnl AC_C_STRUCT_MEMBER(VARIABLE, INCLUDES, TYPE, MEMBER)
+AC_DEFUN(AC_C_STRUCT_MEMBER,
+[AC_CACHE_CHECK([for member $4 in aggregate type $3],ac_cv_c_struct_member_$1,
+ [AC_TRY_COMPILE([$2], [$3 foo; foo.$4;],
+ ac_cv_c_struct_member_$1=yes,ac_cv_c_struct_member_$1=no)])
+$1="$ac_cv_c_struct_member_$1"])
+
+
dnl ### Checking for programs
AC_DEFUN(AC_STRUCT_TIMEZONE,
[AC_REQUIRE([AC_STRUCT_TM])dnl
-AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
- ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
-if test "$ac_cv_struct_tm_zone" = yes; then
+AC_C_STRUCT_MEMBER(tm_zone, [#include <sys/types.h>
+#include <$ac_cv_struct_tm>], [struct tm], tm_zone)
+if test "$ac_cv_c_struct_member_tm_zone" = yes; then
AC_DEFINE(HAVE_TM_ZONE)
else
AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
])
AC_DEFUN(AC_STRUCT_ST_BLOCKS,
-[AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/stat.h>], [struct stat s; s.st_blocks;],
-ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])
-if test $ac_cv_struct_st_blocks = yes; then
+[AC_C_STRUCT_MEMBER(st_blocks, [#include <sys/types.h>
+#include <sys/stat.h>], [struct stat], st_blocks)
+if test $ac_cv_c_struct_member_st_blocks = yes; then
AC_DEFINE(HAVE_ST_BLOCKS)
else
LIBOBJS="$LIBOBJS fileblocks.${ac_objext}"
])
AC_DEFUN(AC_STRUCT_ST_BLKSIZE,
-[AC_CACHE_CHECK([for st_blksize in struct stat], ac_cv_struct_st_blksize,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/stat.h>], [struct stat s; s.st_blksize;],
-ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)])
-if test $ac_cv_struct_st_blksize = yes; then
+[AC_C_STRUCT_MEMBER(st_blksize, [#include <sys/types.h>
+#include <sys/stat.h>], [struct stat], st_blksize)
+if test $ac_cv_c_struct_member_st_blksize = yes; then
AC_DEFINE(HAVE_ST_BLKSIZE)
fi
])
AC_DEFUN(AC_STRUCT_ST_RDEV,
-[AC_CACHE_CHECK([for st_rdev in struct stat], ac_cv_struct_st_rdev,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/stat.h>], [struct stat s; s.st_rdev;],
-ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)])
-if test $ac_cv_struct_st_rdev = yes; then
+[AC_C_STRUCT_MEMBER(st_rdev, [#include <sys/types.h>
+#include <sys/stat.h>], [struct stat], st_rdev)
+if test $ac_cv_c_struct_member_st_rdev = yes; then
AC_DEFINE(HAVE_ST_RDEV)
fi
])
@node Structures, Typedefs, Header Files, Existing Tests
@section Structures
+The following macros check for the presence of certain members in C
+structures. If there is no macro specifically defined to check for a
+member you need, then you can use the general structure member macro
+(@pxref{Generic Structures}) or, for more complex tests, you may use
+@code{AC_TRY_COMPILE} (@pxref{Examining Syntax}).
+
+@menu
+* Particular Structures:: Macros to check for certain stucture members.
+* Generic Structures:: How to find other structure members.
+@end menu
+
+@node Particular Structures, Generic Structures, Structures, Structures
+@subsection Particular Structure Checks
+
The following macros check for certain structures or structure members.
-To check structures not listed here, use @code{AC_EGREP_CPP}
-(@pxref{Examining Declarations}) or @code{AC_TRY_COMPILE}
-(@pxref{Examining Syntax}).
@defmac AC_HEADER_STAT
@maindex HEADER_STAT
external array @code{tzname} is found, define @code{HAVE_TZNAME}.
@end defmac
+@node Generic Structures, , Particular Structures, Structures
+@subsection Generic Structure Checks
+
+These macros are used to find structure members not covered by the
+particular test macros.
+
+@defmac AC_C_STRUCT_MEMBER (@var{variable}, @var{includes}, @var{type}, @var{member})
+@maindex C_STRUCT_MEMBER
+Check whether @var{member} is a member of the C aggregate @var{type}.
+The value of @var{type} may be the name of any legitimate C data type
+including the keywords @code{struct} and @code{union}. @var{includes} is
+any @code{#include} statements needed to obtain the definition of the
+aggregate type. If @var{member} is present, set @var{variable} to @samp{yes},
+otherwise @samp{no}. An example:
+@example
+AC_C_STRUCT_MEMBER(gecos,
+ [#include <pwd.h>], [struct passwd], gecos)
+@end example
+@end defmac
+
@node Typedefs, C Compiler Characteristics, Structures, Existing Tests
@section Typedefs
@node Structures, Typedefs, Header Files, Existing Tests
@section Structures
+The following macros check for the presence of certain members in C
+structures. If there is no macro specifically defined to check for a
+member you need, then you can use the general structure member macro
+(@pxref{Generic Structures}) or, for more complex tests, you may use
+@code{AC_TRY_COMPILE} (@pxref{Examining Syntax}).
+
+@menu
+* Particular Structures:: Macros to check for certain stucture members.
+* Generic Structures:: How to find other structure members.
+@end menu
+
+@node Particular Structures, Generic Structures, Structures, Structures
+@subsection Particular Structure Checks
+
The following macros check for certain structures or structure members.
-To check structures not listed here, use @code{AC_EGREP_CPP}
-(@pxref{Examining Declarations}) or @code{AC_TRY_COMPILE}
-(@pxref{Examining Syntax}).
@defmac AC_HEADER_STAT
@maindex HEADER_STAT
external array @code{tzname} is found, define @code{HAVE_TZNAME}.
@end defmac
+@node Generic Structures, , Particular Structures, Structures
+@subsection Generic Structure Checks
+
+These macros are used to find structure members not covered by the
+particular test macros.
+
+@defmac AC_C_STRUCT_MEMBER (@var{variable}, @var{includes}, @var{type}, @var{member})
+@maindex C_STRUCT_MEMBER
+Check whether @var{member} is a member of the C aggregate @var{type}.
+The value of @var{type} may be the name of any legitimate C data type
+including the keywords @code{struct} and @code{union}. @var{includes} is
+any @code{#include} statements needed to obtain the definition of the
+aggregate type. If @var{member} is present, set @var{variable} to @samp{yes},
+otherwise @samp{no}. An example:
+@example
+AC_C_STRUCT_MEMBER(gecos,
+ [#include <pwd.h>], [struct passwd], gecos)
+@end example
+@end defmac
+
@node Typedefs, C Compiler Characteristics, Structures, Existing Tests
@section Typedefs
)])
+dnl ### Generic structure checks
+
+dnl Check if a particular structure member exists.
+dnl AC_C_STRUCT_MEMBER(VARIABLE, INCLUDES, TYPE, MEMBER)
+AC_DEFUN(AC_C_STRUCT_MEMBER,
+[AC_CACHE_CHECK([for member $4 in aggregate type $3],ac_cv_c_struct_member_$1,
+ [AC_TRY_COMPILE([$2], [$3 foo; foo.$4;],
+ ac_cv_c_struct_member_$1=yes,ac_cv_c_struct_member_$1=no)])
+$1="$ac_cv_c_struct_member_$1"])
+
+
dnl ### Checking for programs
AC_DEFUN(AC_STRUCT_TIMEZONE,
[AC_REQUIRE([AC_STRUCT_TM])dnl
-AC_CACHE_CHECK([for tm_zone in struct tm], ac_cv_struct_tm_zone,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;],
- ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])
-if test "$ac_cv_struct_tm_zone" = yes; then
+AC_C_STRUCT_MEMBER(tm_zone, [#include <sys/types.h>
+#include <$ac_cv_struct_tm>], [struct tm], tm_zone)
+if test "$ac_cv_c_struct_member_tm_zone" = yes; then
AC_DEFINE(HAVE_TM_ZONE)
else
AC_CACHE_CHECK(for tzname, ac_cv_var_tzname,
])
AC_DEFUN(AC_STRUCT_ST_BLOCKS,
-[AC_CACHE_CHECK([for st_blocks in struct stat], ac_cv_struct_st_blocks,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/stat.h>], [struct stat s; s.st_blocks;],
-ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])
-if test $ac_cv_struct_st_blocks = yes; then
+[AC_C_STRUCT_MEMBER(st_blocks, [#include <sys/types.h>
+#include <sys/stat.h>], [struct stat], st_blocks)
+if test $ac_cv_c_struct_member_st_blocks = yes; then
AC_DEFINE(HAVE_ST_BLOCKS)
else
LIBOBJS="$LIBOBJS fileblocks.${ac_objext}"
])
AC_DEFUN(AC_STRUCT_ST_BLKSIZE,
-[AC_CACHE_CHECK([for st_blksize in struct stat], ac_cv_struct_st_blksize,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/stat.h>], [struct stat s; s.st_blksize;],
-ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)])
-if test $ac_cv_struct_st_blksize = yes; then
+[AC_C_STRUCT_MEMBER(st_blksize, [#include <sys/types.h>
+#include <sys/stat.h>], [struct stat], st_blksize)
+if test $ac_cv_c_struct_member_st_blksize = yes; then
AC_DEFINE(HAVE_ST_BLKSIZE)
fi
])
AC_DEFUN(AC_STRUCT_ST_RDEV,
-[AC_CACHE_CHECK([for st_rdev in struct stat], ac_cv_struct_st_rdev,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <sys/stat.h>], [struct stat s; s.st_rdev;],
-ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)])
-if test $ac_cv_struct_st_rdev = yes; then
+[AC_C_STRUCT_MEMBER(st_rdev, [#include <sys/types.h>
+#include <sys/stat.h>], [struct stat], st_rdev)
+if test $ac_cv_c_struct_member_st_rdev = yes; then
AC_DEFINE(HAVE_ST_RDEV)
fi
])