-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Support confstr on Linux #3612
Support confstr on Linux #3612
Conversation
r? @JohnTitor rustbot has assigned @JohnTitor. Use r? to explicitly pick a reviewer |
Pull request looks good to me. More comprehensive than #3771. Maybe a |
@@ -1634,6 +1634,34 @@ pub const _SC_XOPEN_STREAMS: ::c_int = 246; | |||
pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 247; | |||
pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 248; | |||
|
|||
pub const _CS_PATH: ::c_int = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least some of these should be added to other platforms, e.g. OpenBSD https://man.openbsd.org/confstr.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree re additional for other platforms.
A challenge: The constant is stable and POSIX-defined, but the constant's value is not guaranteed stable across POSIX platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope someone else will contribute the constant values for non-linux targets.
☔ The latest upstream changes made this pull request unmergeable. Please resolve the merge conflicts. |
6469c63
to
51f9da4
Compare
Rebased. I also re-checked the header files and changed some constant definitions that I missed before. @rustbot ready |
☔ The latest upstream changes (presumably #4018) made this pull request unmergeable. Please resolve the merge conflicts. |
src/unix/linux_like/linux/mod.rs
Outdated
pub const _CS_GNU_LIBC_VERSION: ::c_int = 2; | ||
pub const _CS_GNU_LIBPTHREAD_VERSION: ::c_int = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these _GNU_
values should go in gnu or musl only, they don't seem to exist in ulibc or newlib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Those values are specific to glibc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Musl seems to have them https://github.com/kraj/musl/blob/ffb23aef7b5339b8c3234f4c6a93c488dc873919/include/unistd.h#L439-L440 which is probably why we aren't getting test failures. But I don't think we have any need to expose it on anything but gnu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the conflict, one last thing to double check above and then LGTM |
51f9da4
to
649154d
Compare
Rebased and resolved the conflicts |
649154d
to
51512d1
Compare
(backport <rust-lang#3612>) (cherry picked from commit 51512d1)
Description
This pull request adds support for the
confstr
function on Linux and also defines the constants used as a parameter for the function.I moved the function declaration from
src/unix/bsd/apple/mod.rs
tosrc/unix/mod.rs
(rather than adding tosrc/unix/linux_like/linux/mod.rs
) since it is part of POSIX so it should be available on any unix-like systems.The constants for non-linux targets are not the scope of this pull request.
Sources
Checklist
libc-test/semver
have been updated*LAST
or*MAX
areincluded (see #3131)
cd libc-test && cargo test --target mytarget
);especially relevant for platforms that may not be checked in CI