-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Specialize sleep_until implementation for unix (except mac) #141829
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
base: master
Are you sure you want to change the base?
Conversation
r? @cuviper |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This can be done without touching all pal's, ill be doing that tomorrow, now its bed time 😴 edit: I was mistaken, tidy does not allow #[cfg(...)] in |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
@rustbot ready Apologies for the unnecessary rebase. Changes:
|
This comment has been minimized.
This comment has been minimized.
fn add_100_millis(mut ts: libc::timespec) -> libc::timespec { | ||
const SECOND: i64 = 1_000_000_000; | ||
ts.tv_nsec += SECOND / 10; | ||
ts.tv_sec = ts.tv_nsec / SECOND; |
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.
Isn't this still wrong?
ts.tv_sec = ts.tv_nsec / SECOND; | |
// If this pushes tv_nsec to SECOND or higher, we need to overflow to tv_sec. | |
ts.tv_sec += ts.tv_nsec / SECOND; |
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.
It should be this now:
fn add_100_millis(mut ts: libc::timespec) -> libc::timespec {
const SECOND: i64 = 1_000_000_000;
ts.tv_nsec += SECOND / 10;
ts.tv_sec = ts.tv_nsec / SECOND;
ts.tv_nsec %= SECOND;
ts
}
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.
But that's wrong, as I already said above. Why do you reset tv_sec
to 0 or 1??
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.
the overflow of tv_nsec
is taken care of by:
ts.tv_nsec %= SECOND;
right?
I tested it in the playground and there it seems to work https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=8c8dcb8b0f9c7238b747b61e073ddc14
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.
But that's wrong, as I already said above. Why do you reset
tv_sec
to 0 or 1??
oh damn I get it
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 I'm struggling with this, no idea why. Thanks for your patience Ralf.
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.
Better take a bit more time and think things through twice next time. :)
My suggestion above has a comment, I think that's still a useful comment to explain the (clearly non-obvious!) logic. Please add that comment.
Miri code looks good once the last comment nit is resolved. :) |
Regarding trying on more Unix platforms... this should cover various unix flavors |
Specialize sleep_until implementation for unix (except mac) related tracking issue: #113752 Supersedes #118480 for the reasons see: #113752 (comment) Replaces the generic catch all implementation with target_os specific ones for: linux/netbsd/freebsd/android/solaris/illumos etc. Other platforms like wasi, macos/ios/tvos/watchos and windows will follow in later separate PR's (once this is merged). try-job: dist-x86_64-*
The job Click to see the possible cause of the failure (guessed by this bot)
|
@rustbot author |
related tracking issue: #113752
Supersedes #118480 for the reasons see: #113752 (comment)
Replaces the generic catch all implementation with target_os specific ones for: linux/netbsd/freebsd/android/solaris/illumos etc. Other platforms like wasi, macos/ios/tvos/watchos and windows will follow in later separate PR's (once this is merged).