-
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
Add new cfg linux_time_bits64 corresponding to __USE_TIME_BITS64 #4148
Conversation
Thanks! I'll need to double check the definitions but at first glance this looks good. Could you add an internal env Line 67 in 42e5708 if [ "$os" = "linux" ]; then
RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64=1 $cmd
fi So we make sure the build is correct in CI |
Also FYI there is a large edition refactor coming #4132 so this will probably wind up with conflicts in the near future. |
src/unix/linux_like/linux/mod.rs
Outdated
pub struct input_event { | ||
pub time: ::timeval, | ||
#[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] | ||
pub input_event_sec: ::time_t, | ||
#[cfg(all(target_pointer_width = "32", linux_time_bits64))] | ||
pub input_event_sec: ::c_ulong, | ||
|
||
#[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))] | ||
pub input_event_usec: ::suseconds_t, | ||
#[cfg(all(target_pointer_width = "32", linux_time_bits64))] | ||
pub input_event_usec: ::c_ulong, | ||
|
||
#[cfg(target_arch = "sparc64")] | ||
_pad1: ::c_int, |
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 that we should leave the pub time: ::timeval
for #[cfg(any(target_pointer_width = "64", not(linux_time_bits64)))]
to minimize breakage. Maybe it's better to leave time
or __sec
+__usec
as the fields, then make input_event_u?sec
methods on the struct.
Also I believe sparc64
needs __usec
/input_event_usec
to be a c_uint
rather than c_ulong
.
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 choose the current struct based on the discussion starting here #3175 (review) . The input_event_X
members are the platform independent way of referring to these members, even if I cannot find any documentation for this.
We can exclude the input_event
change from this PR for now if we need to discuss this further,
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.
And suseconds_t
is i32
on sparc64
for glibc
. As far as I can tell none of the other libc
's support sparc64
.
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.
Thanks for the information, that reasoning makes sense. Agreed that we should make this change but I would like to be able to backport this PR (so users can start experimenting before commiting to 1.0) so I don't think we should make this change now. Would it be possible to:
- Leave
time
with the cfg mentioned in Add new cfg linux_time_bits64 corresponding to __USE_TIME_BITS64 #4148 (comment) - Just put the conflicting
input_event_*
in a block comment with aFIXME(1.0): ...
so we make this change before that release
I think we should mark time
deprecated at some point but I am hesitant to do that without a migration path, so this can be revisited later.
e38313d
to
34378b5
Compare
I think I've addressed most of your comments. I did not change the |
☔ The latest upstream changes (presumably #4132) made this pull request unmergeable. Please resolve the merge conflicts. |
34378b5
to
2cb283e
Compare
The PR has been rebased on main, including the mentioned refactor in #4132 . |
Thanks for the changes, I'll double check this within the next couple of days (the recent MSRV bump and edition change have been pretty time consuming in this repo). |
One last request to defer the |
linux_time_bits64 will be used to match __USE_TIME_BITS64 in the uapi headers. The environment variable RUST_LIBC_UNSTABLE_LINUX_TIME_BITS64 can be used by callers to enable the linux_time_bits64 config.
The actual values may be different on 32bit archs with and without __USE_TIME_BITS64
2cb283e
to
7572399
Compare
I've updated input_event as I think you meant. |
struct timeval has to be updated at least for glibc with _TIME_BITS=64.
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.
Looks great, thanks for the changes! You can run ./ci/style.sh
to fix whatever the failure is.
7572399
to
c201302
Compare
Description
Add a new cfg
linux_time_bits64
-- corresponding to the kernels__USE_TIME_BITS64
-- with some associated changes as a base for 64bittime_t
support forglibc
andmusl
Sources
https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/socket.h#L157
https://github.com/torvalds/linux/blob/master/arch/mips/include/uapi/asm/socket.h#L164
https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/socket.h
https://github.com/torvalds/linux/blob/master/include/uapi/asm-generic/resource.h#L58
https://github.com/torvalds/linux/blob/master/arch/mips/include/uapi/asm/resource.h#L31
https://github.com/torvalds/linux/blob/master/include/uapi/linux/input.h#L28
https://github.com/torvalds/linux/blob/master/include/uapi/linux/time.h#L17
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