Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add close_range for glibc #3373

Merged
merged 2 commits into from Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions libc-test/build.rs
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
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
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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flags argument, is of type unsigned int, according to the signature given in the man page, but

$ cd libc-test && cargo t

would complain it should have type int to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glibc version difference? I'd prefer to declare a newer one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glibc version difference?

Not sure about this, let me investigate it a little bit, my glibc is 2.37

$ ldd --version
ldd (GNU libc) 2.37
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just give it a check on glibc

  • 2.34
  • 2.35
  • 2.36

The flag argument is of type int, so I guess this is a mistake of the manual

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems so, thank you for investigating!

}

cfg_if! {
Expand Down