Add new cfg linux_time_bits64 corresponding to __USE_TIME_BITS64#4148
Add new cfg linux_time_bits64 corresponding to __USE_TIME_BITS64#4148tgross35 merged 5 commits intorust-lang:mainfrom
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
fiSo 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.
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.
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.
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.
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
timewith 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.
tgross35
left a comment
There was a problem hiding this comment.
Looks great, thanks for the changes! You can run ./ci/style.sh to fix whatever the failure is.
7572399 to
c201302
Compare
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. (backport <rust-lang#4148>) (cherry picked from commit 5453fe6)
The actual values may be different on 32bit archs with and without __USE_TIME_BITS64 (backport <rust-lang#4148>) (cherry picked from commit 616d546)
(backport <rust-lang#4148>) (cherry picked from commit 125b4f7)
(backport <rust-lang#4148>) (cherry picked from commit 7413e22)
struct timeval has to be updated at least for glibc with _TIME_BITS=64. (backport <rust-lang#4148>) (cherry picked from commit c201302)
Description
Add a new cfg
linux_time_bits64-- corresponding to the kernels__USE_TIME_BITS64-- with some associated changes as a base for 64bittime_tsupport forglibcandmuslSources
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/semverhave been updated*LASTor*MAXareincluded (see #3131)
cd libc-test && cargo test --target mytarget);especially relevant for platforms that may not be checked in CI