summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/ConfigureChecks.cmake1
-rw-r--r--configure.ac1
-rw-r--r--dbus/dbus-sysdeps-unix.c18
3 files changed, 20 insertions, 0 deletions
diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake
index 735a4fe0..ce8f4f9d 100644
--- a/cmake/ConfigureChecks.cmake
+++ b/cmake/ConfigureChecks.cmake
@@ -32,6 +32,7 @@ check_include_file(sys/inotify.h HAVE_SYS_INOTIFY_H)
check_include_file(sys/random.h HAVE_SYS_RANDOM_H)
check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
+check_include_file(sys/syscall.h HAVE_SYS_SYSCALL_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(sys/uio.h HAVE_SYS_UIO_H)
check_include_file(sys/prctl.h HAVE_SYS_PRCTL_H)
diff --git a/configure.ac b/configure.ac
index eed8a787..26de0a55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -427,6 +427,7 @@ stdint.h
sys/prctl.h
sys/random.h
sys/resource.h
+sys/syscall.h
sys/syslimits.h
sys/time.h
unistd.h
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index ced32063..9a35d076 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -84,6 +84,9 @@
#ifdef HAVE_SYS_RANDOM_H
#include <sys/random.h>
#endif
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#endif
#ifdef HAVE_ADT
#include <bsm/adt.h>
@@ -141,6 +144,21 @@
#endif /* Solaris */
+#if defined(__linux__) && defined(__NR_close_range) && !defined(HAVE_CLOSE_RANGE)
+/* The kernel headers are new enough to have the close_range syscall,
+ * but glibc isn't new enough to have the syscall wrapper, so call the
+ * syscall directly. */
+static inline int
+close_range (unsigned int first,
+ unsigned int last,
+ unsigned int flags)
+{
+ return syscall (__NR_close_range, first, last, flags);
+}
+/* Now we can call that inline wrapper as though it was provided by glibc. */
+#define HAVE_CLOSE_RANGE
+#endif
+
/**
* Ensure that the standard file descriptors stdin, stdout and stderr
* are open, by opening /dev/null if necessary.