From 173757d3b2e9da8f8d22ee790a4616baec121981 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Fri, 6 Oct 2023 16:41:05 +0800 Subject: [PATCH 1/2] feat: add close_range for glibc --- libc-test/build.rs | 1 + libc-test/semver/linux-gnu.txt | 1 + src/unix/linux_like/linux/gnu/mod.rs | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 1d689e6d15b16..48fb4df08e8e9 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3378,6 +3378,7 @@ fn test_linux(target: &str) { "sys/fanotify.h", // is not present on uclibc [!uclibc]: "sys/auxv.h", + [gnu]: "linux/close_range.h", } // note: aio.h must be included before sys/mount.h diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 59950d81903f4..263a2b2bb7a98 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -665,3 +665,4 @@ getmntent_r putpwent putgrent execveat +close_range \ No newline at end of file diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index fe8f89177caae..ff3e71cf8f7c7 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1399,6 +1399,13 @@ extern "C" { envp: *const *mut c_char, flags: ::c_int, ) -> ::c_int; + + // Added in `glibc` 2.34 + pub fn close_range( + first: ::c_uint, + last: ::c_uint, + flags: ::c_int, + ) -> ::c_int; } cfg_if! { From 7b9e367f67a899b319da7020d0d836f515f492f2 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Fri, 6 Oct 2023 16:46:22 +0800 Subject: [PATCH 2/2] fmt --- src/unix/linux_like/linux/gnu/mod.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index ff3e71cf8f7c7..c2daa6903ba30 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1401,11 +1401,7 @@ extern "C" { ) -> ::c_int; // Added in `glibc` 2.34 - pub fn close_range( - first: ::c_uint, - last: ::c_uint, - flags: ::c_int, - ) -> ::c_int; + pub fn close_range(first: ::c_uint, last: ::c_uint, flags: ::c_int) -> ::c_int; } cfg_if! {