diff --git a/sv.c b/sv.c index 7c82b0408912..d4fc0c2e2ba3 100644 --- a/sv.c +++ b/sv.c @@ -14087,12 +14087,14 @@ Duplicate a directory handle, returning a pointer to the cloned object. =cut */ +#define HAS_FDOPENDIR 1 + DIR * Perl_dirp_dup(pTHX_ DIR *const dp, CLONE_PARAMS *const param) { DIR *ret; -#if defined(HAS_FCHDIR) && defined(HAS_TELLDIR) && defined(HAS_SEEKDIR) +#if !defined(HAS_FDOPENDIR) && defined(HAS_FCHDIR) && defined(HAS_TELLDIR) && defined(HAS_SEEKDIR) DIR *pwd; const Direntry_t *dirent; char smallbuf[256]; /* XXX MAXPATHLEN, surely? */ @@ -14102,6 +14104,7 @@ Perl_dirp_dup(pTHX_ DIR *const dp, CLONE_PARAMS *const param) #endif PERL_UNUSED_CONTEXT; + PERL_UNUSED_VAR(param); PERL_ARGS_ASSERT_DIRP_DUP; if (!dp) @@ -14112,7 +14115,11 @@ Perl_dirp_dup(pTHX_ DIR *const dp, CLONE_PARAMS *const param) if (ret) return ret; -#if defined(HAS_FCHDIR) && defined(HAS_TELLDIR) && defined(HAS_SEEKDIR) +#ifdef HAS_FDOPENDIR + + ret = fdopendir(dup(my_dirfd(dp))); + +#elif defined(HAS_FCHDIR) && defined(HAS_TELLDIR) && defined(HAS_SEEKDIR) PERL_UNUSED_ARG(param);