]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Add macro for dirfd() on HP-UX because no full POSIX.1-2008 coverage exists 1679/head
authorMichael Osipov <michael.osipov@siemens.com>
Thu, 10 Mar 2022 11:56:02 +0000 (12:56 +0100)
committerMichael Osipov <michael.osipov@siemens.com>
Fri, 11 Mar 2022 19:17:33 +0000 (20:17 +0100)
HP-UX does neither provide a function nor a macro. This solution based on an
issue with vim: https://github.com/vim/vim/issues/6838

libarchive/archive_read_disk_posix.c

index d0e1f35c8291ff4316eb2e440bf0e32e4afb64e1..2b39e672b49c83bf74457f6e6aff6d2fcc466a43 100644 (file)
@@ -109,6 +109,11 @@ __FBSDID("$FreeBSD$");
 #define O_CLOEXEC      0
 #endif
 
+#if defined(__hpux) && !defined(HAVE_DIRFD)
+#define dirfd(x) ((x)->__dd_fd)
+#define HAVE_DIRFD
+#endif
+
 /*-
  * This is a new directory-walking system that addresses a number
  * of problems I've had with fts(3).  In particular, it has no
@@ -2428,7 +2433,7 @@ tree_dir_next_posix(struct tree *t)
 #else /* HAVE_FDOPENDIR */
                if (tree_enter_working_dir(t) == 0) {
                        t->d = opendir(".");
-#if HAVE_DIRFD || defined(dirfd)
+#ifdef HAVE_DIRFD
                        __archive_ensure_cloexec_flag(dirfd(t->d));
 #endif
                }