summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-10-21 16:04:17 +0000
committerbors <bors@rust-lang.org>2021-10-21 16:04:17 +0000
commit473e8deb372dee29730c321f82ebba69d579cdbe (patch)
treef146b75c71eef2de899935b858e89ca6d9bf89f4
parent21ad06f32c6b1c403a84cfe830e2d62f6fd7442b (diff)
parent157ca896b629f0d5b7bb196404b113916b95dcc8 (diff)
downloadrust-libc-473e8deb372dee29730c321f82ebba69d579cdbe.tar.gz
Auto merge of #2471 - NeoRaider:close_range, r=JohnTitor
linux: Add CLOSE_RANGE_* flags Flags for the SYS_close_range syscall from <linux/close_range.h>.
-rw-r--r--libc-test/build.rs4
-rw-r--r--libc-test/semver/linux.txt2
-rw-r--r--src/unix/linux_like/linux/mod.rs4
3 files changed, 10 insertions, 0 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index 38190b3501..32f48119e8 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -2924,6 +2924,10 @@ fn test_linux(target: &str) {
| "SW_CNT"
if mips || ppc64 || riscv64 || sparc64 => true,
+ // FIXME: Requires more recent kernel headers (5.9 / 5.11):
+ | "CLOSE_RANGE_UNSHARE"
+ | "CLOSE_RANGE_CLOEXEC" => true,
+
// kernel constants not available in uclibc 1.0.34
| "ADDR_COMPAT_LAYOUT"
| "ADDR_LIMIT_3GB"
diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt
index ccfc2fb202..15248960ec 100644
--- a/libc-test/semver/linux.txt
+++ b/libc-test/semver/linux.txt
@@ -265,6 +265,8 @@ CLONE_THREAD
CLONE_UNTRACED
CLONE_VFORK
CLONE_VM
+CLOSE_RANGE_CLOEXEC
+CLOSE_RANGE_UNSHARE
CMSG_DATA
CMSG_FIRSTHDR
CMSG_LEN
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index 7f837f2ab8..460ea6248b 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -1818,6 +1818,10 @@ pub const MFD_CLOEXEC: ::c_uint = 0x0001;
pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
pub const MFD_HUGETLB: ::c_uint = 0x0004;
+// linux/close_range.h
+pub const CLOSE_RANGE_UNSHARE: ::c_uint = 1 << 1;
+pub const CLOSE_RANGE_CLOEXEC: ::c_uint = 1 << 2;
+
// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has
// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32
// so we can use that type here to avoid having to cast.