3 dnl Find out how to get the file descriptor associated with an open DIR*.
6 AC_DEFUN([UTILS_FUNC_DIRFD],
12 #else /* not HAVE_DIRENT_H */
13 # define dirent direct
15 # include <sys/ndir.h>
16 # endif /* HAVE_SYS_NDIR_H */
19 # endif /* HAVE_SYS_DIR_H */
22 # endif /* HAVE_NDIR_H */
23 #endif /* HAVE_DIRENT_H */
26 AC_CHECK_DECLS([dirfd], , , $dirfd_headers)
28 # Use the replacement only if we have neither the function
30 if test $ac_cv_func_dirfd,$ac_cv_have_decl_dirfd = no,no; then
31 AC_REPLACE_FUNCS([dirfd])
33 [how to get the file descriptor associated with an open DIR*],
34 ac_cv_sys_dir_fd_member_name,
36 dirfd_save_CFLAGS=$CFLAGS
37 for ac_expr in d_fd dd_fd; do
39 CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
43 [DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;],
46 CFLAGS=$dirfd_save_CFLAGS
47 test "$dir_fd_found" = yes && break
49 test "$dir_fd_found" = yes || ac_expr=-1
51 ac_cv_sys_dir_fd_member_name=$ac_expr
54 if test $ac_cv_have_decl_dirfd = -1; then
55 AC_DEFINE_UNQUOTED(DIR_FD_MEMBER_NAME,
56 $ac_cv_sys_dir_fd_member_name,
57 [the name of the file descriptor member of DIR])
59 AH_VERBATIM(DIR_TO_FD,
60 [#ifdef DIR_FD_MEMBER_NAME
61 # define DIR_TO_FD(Dir_p) ((Dir_p)->DIR_FD_MEMBER_NAME)
63 # define DIR_TO_FD(Dir_p) -1