AC_DEFUN([UTILS_FUNC_DIRFD],
[
+ AC_HEADER_DIRENT
AC_REPLACE_FUNCS([dirfd])
- AC_CHECK_DECLS([dirfd])
+ dirfd_headers='
+#if HAVE_DIRENT_H
+# include <dirent.h>
+#else /* not HAVE_DIRENT_H */
+# define dirent direct
+# if HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif /* HAVE_SYS_NDIR_H */
+# if HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif /* HAVE_SYS_DIR_H */
+# if HAVE_NDIR_H
+# include <ndir.h>
+# endif /* HAVE_NDIR_H */
+#endif /* HAVE_DIRENT_H */
+'
+ AC_CHECK_DECLS([dirfd], , , $dirfd_headers)
if test $ac_cv_func_dirfd = no; then
AC_CACHE_CHECK(
[how to get the file descriptor associated with an open DIR*],
DEFS="$DEFS -DDIR_TO_FD=$ac_expr"
AC_TRY_COMPILE(
- [#include <sys/types.h>
-#include <dirent.h>
+ [$dirfd_headers
],
[DIR *dir_p = opendir("."); (void) ($ac_expr);],
dir_fd_done=yes