Skip to content

Commit

Permalink
Auto merge of #3373 - SteveLauC:close_range, r=JohnTitor
Browse files Browse the repository at this point in the history
feat: add close_range for glibc

This PR adds [`close_range(2)`](https://man7.org/linux/man-pages/man2/close_range.2.html) for Linux/glibc:

```c
#include <linux/close_range.h>

       int close_range(unsigned int first, unsigned int last,
                       unsigned int flags);
```

musl and uClibc don't have wrappers for this syscall
  • Loading branch information
bors committed Oct 6, 2023
2 parents 14ef2e5 + 7b9e367 commit 017bf5f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3378,6 +3378,7 @@ fn test_linux(target: &str) {
"sys/fanotify.h",
// <sys/auxv.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
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/linux-gnu.txt
Original file line number Diff line number Diff line change
Expand Up @@ -665,3 +665,4 @@ getmntent_r
putpwent
putgrent
execveat
close_range
3 changes: 3 additions & 0 deletions src/unix/linux_like/linux/gnu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,9 @@ 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! {
Expand Down

0 comments on commit 017bf5f

Please sign in to comment.