From 75d4fce0bfe98b46a1dcf2bfe482e7a24ab2c08e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 22 Oct 2024 23:40:22 +0100 Subject: [PATCH] glibc wrapper only available on recent glibc releases --- src/unistd.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/unistd.rs b/src/unistd.rs index 0e33dda1d1..3edf59e556 100644 --- a/src/unistd.rs +++ b/src/unistd.rs @@ -4024,7 +4024,14 @@ pub fn close_range(fdbegin: F, fdlast: F, flags: CloseRang let raw = unsafe { Errno::clear(); - libc::close_range(fdbegin.as_fd().as_raw_fd() as u32, fdlast.as_fd().as_raw_fd() as u32, flags.bits() as i32) + + cfg_if! { + if #[cfg(all(target_os = "linux", target_env = "gnu"))] { + libc::syscall(libc::SYS_close_range, fdbegin.as_fd().as_raw_fd() as u32, fdlast.as_fd().as_raw_fd() as u32, flags.bits() as i32) as i32 + } else { + libc::close_range(fdbegin.as_fd().as_raw_fd() as u32, fdlast.as_fd().as_raw_fd() as u32, flags.bits() as i32) + } + } }; if raw == -1 { if Errno::last_raw() == 0 {