summaryrefslogtreecommitdiff
path: root/m4/dirfd.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/dirfd.m4')
-rw-r--r--m4/dirfd.m426
1 files changed, 14 insertions, 12 deletions
diff --git a/m4/dirfd.m4 b/m4/dirfd.m4
index 85223351b28..e58582e6145 100644
--- a/m4/dirfd.m4
+++ b/m4/dirfd.m4
@@ -1,4 +1,4 @@
-# serial 26 -*- Autoconf -*-
+# serial 30 -*- Autoconf -*-
dnl Find out how to get the file descriptor associated with an open DIR*.
@@ -12,7 +12,7 @@ dnl From Jim Meyering
AC_DEFUN([gl_FUNC_DIRFD],
[
AC_REQUIRE([gl_DIRENT_H_DEFAULTS])
- AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_REQUIRE([AC_CANONICAL_HOST])
dnl Persuade glibc <dirent.h> to declare dirfd().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
@@ -36,15 +36,17 @@ AC_DEFUN([gl_FUNC_DIRFD],
[gl_cv_func_dirfd_macro=yes],
[gl_cv_func_dirfd_macro=no])])
- # Use the replacement if we have no function or macro with that name,
- # or if OS/2 kLIBC whose dirfd() does not work.
- # Replace only if the system declares dirfd already.
- case $ac_cv_func_dirfd,$gl_cv_func_dirfd_macro,$host_os,$ac_cv_have_decl_dirfd in
- no,no,*,yes | *,*,os2*,yes)
+ if test $ac_cv_func_dirfd = no && test $gl_cv_func_dirfd_macro = no; then
+ HAVE_DIRFD=0
+ else
+ HAVE_DIRFD=1
+ dnl Replace dirfd() on native Windows and OS/2 kLIBC,
+ dnl to support fdopendir().
+ AC_REQUIRE([gl_DIRENT_DIR])
+ if test $DIR_HAS_FD_MEMBER = 0; then
REPLACE_DIRFD=1
- AC_DEFINE([REPLACE_DIRFD], [1],
- [Define to 1 if gnulib's dirfd() replacement is used.]);;
- esac
+ fi
+ fi
])
dnl Prerequisites of lib/dirfd.c.
@@ -53,7 +55,7 @@ AC_DEFUN([gl_PREREQ_DIRFD],
AC_CACHE_CHECK([how to get the file descriptor associated with an open DIR*],
[gl_cv_sys_dir_fd_member_name],
[
- dirfd_save_CFLAGS=$CFLAGS
+ gl_saved_CFLAGS=$CFLAGS
for ac_expr in d_fd dd_fd; do
CFLAGS="$CFLAGS -DDIR_FD_MEMBER_NAME=$ac_expr"
@@ -63,7 +65,7 @@ AC_DEFUN([gl_PREREQ_DIRFD],
[[DIR *dir_p = opendir("."); (void) dir_p->DIR_FD_MEMBER_NAME;]])],
[dir_fd_found=yes]
)
- CFLAGS=$dirfd_save_CFLAGS
+ CFLAGS=$gl_saved_CFLAGS
test "$dir_fd_found" = yes && break
done
test "$dir_fd_found" = yes || ac_expr=no_such_member