AC_DEFINE(HAVE_DIRFD, 1, [Define if dirfd is available in <dirent.h>.])
fi
dnl
+ AC_CACHE_CHECK([for openat],
+ glibcxx_cv_openat, [dnl
+ GCC_TRY_COMPILE_OR_LINK(
+ [#include <fcntl.h>],
+ [int fd = ::openat(AT_FDCWD, "", 0);],
+ [glibcxx_cv_openat=yes],
+ [glibcxx_cv_openat=no])
+ ])
+ if test $glibcxx_cv_openat = yes; then
+ AC_DEFINE(HAVE_OPENAT, 1, [Define if openat is available in <fcntl.h>.])
+ fi
+dnl
AC_CACHE_CHECK([for unlinkat],
glibcxx_cv_unlinkat, [dnl
GCC_TRY_COMPILE_OR_LINK(
$as_echo "#define HAVE_DIRFD 1" >>confdefs.h
fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openat" >&5
+$as_echo_n "checking for openat... " >&6; }
+if ${glibcxx_cv_openat+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test x$gcc_no_link = xyes; then
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <fcntl.h>
+int
+main ()
+{
+int fd = ::openat(AT_FDCWD, "", 0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ glibcxx_cv_openat=yes
+else
+ glibcxx_cv_openat=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ if test x$gcc_no_link = xyes; then
+ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <fcntl.h>
+int
+main ()
+{
+int fd = ::openat(AT_FDCWD, "", 0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ glibcxx_cv_openat=yes
+else
+ glibcxx_cv_openat=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_openat" >&5
+$as_echo "$glibcxx_cv_openat" >&6; }
+ if test $glibcxx_cv_openat = yes; then
+
+$as_echo "#define HAVE_OPENAT 1" >>confdefs.h
+
+ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for unlinkat" >&5
$as_echo_n "checking for unlinkat... " >&6; }
if ${glibcxx_cv_unlinkat+:} false; then :
dir_and_pathname() const noexcept
{
const fs::path& p = entry.path();
-#if _GLIBCXX_HAVE_DIRFD
+#if _GLIBCXX_HAVE_DIRFD && _GLIBCXX_HAVE_OPENAT
return {::dirfd(this->dirp), std::prev(p.end())->c_str()};
#endif
return {this->fdcwd(), p.c_str()};