[vte] lib: Move missing defs to missing.hh and update



commit 6f860706a907549a74e09e4e047643a44128dbcc
Author: Christian Persch <chpe src gnome org>
Date:   Mon Feb 1 22:04:12 2021 +0100

    lib: Move missing defs to missing.hh and update

 src/missing.hh  | 26 ++++++++++++++++++++++++++
 src/vteutils.cc |  9 ++-------
 2 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/src/missing.hh b/src/missing.hh
index 2dd8047d..d5d0484c 100644
--- a/src/missing.hh
+++ b/src/missing.hh
@@ -81,6 +81,32 @@ char* strchrnul(char const* s,
 #  endif
 #endif /* !__NR_close_range */
 
+/* The following is copied from systemd/src/basic/missing_fcntl.h (LGPL2.1+) */
+
+/* The precise definition of __O_TMPFILE is arch specific; use the
+ * values defined by the kernel (note: some are hexa, some are octal,
+ * duplicated as-is from the kernel definitions):
+ * - alpha, parisc, sparc: each has a specific value;
+ * - others: they use the "generic" value.
+ */
+
+#ifndef __O_TMPFILE
+#if defined(__alpha__)
+#define __O_TMPFILE     0100000000
+#elif defined(__parisc__) || defined(__hppa__)
+#define __O_TMPFILE     0400000000
+#elif defined(__sparc__) || defined(__sparc64__)
+#define __O_TMPFILE     0x2000000
+#else
+#define __O_TMPFILE     020000000
+#endif
+#endif
+
+/* a horrid kludge trying to make sure that this will fail on old kernels */
+#ifndef O_TMPFILE
+#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
+#endif
+
 /* END copied from systemd */
 
 #if !defined(SYS_close_range) && defined(__NR_close_range)
diff --git a/src/vteutils.cc b/src/vteutils.cc
index d4afdcba..95c79b8d 100644
--- a/src/vteutils.cc
+++ b/src/vteutils.cc
@@ -31,15 +31,10 @@
 #include <sys/ioctl.h>
 #include <linux/fs.h>
 
-#ifndef O_TMPFILE
-#ifndef __O_TMPFILE
-#define __O_TMPFILE     020000000
-#endif
-#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
-#endif
-
 #endif /* __linux__ */
 
+#include "missing.hh"
+
 int
 _vte_mkstemp (void)
 {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]