aboutgitcodebugslistschat
path: root/linux_dep.h
diff options
context:
space:
mode:
Diffstat (limited to 'linux_dep.h')
-rw-r--r--linux_dep.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/linux_dep.h b/linux_dep.h
index eae9c3c..3a41e42 100644
--- a/linux_dep.h
+++ b/linux_dep.h
@@ -125,4 +125,24 @@ struct tcp_info_linux {
#define FALLOC_FL_COLLAPSE_RANGE 0x08
#endif
+#include <linux/close_range.h>
+
+#ifdef CLOSE_RANGE_UNSHARE /* Linux kernel >= 5.9 */
+/* glibc < 2.34 and musl as of 1.2.5 need these */
+#ifndef SYS_close_range
+#define SYS_close_range 436
+#endif
+__attribute__ ((weak))
+/* cppcheck-suppress funcArgNamesDifferent */
+int close_range(unsigned int first, unsigned int last, int flags) {
+ return syscall(SYS_close_range, first, last, flags);
+}
+#else
+/* No reasonable fallback option */
+/* cppcheck-suppress funcArgNamesDifferent */
+int close_range(unsigned int first, unsigned int last, int flags) {
+ return 0;
+}
+#endif
+
#endif /* LINUX_DEP_H */