Skip to content

Commit

Permalink
Unrolled build for rust-lang#129588
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#129588 - hermit-os:sleep-micros, r=workingjubilee

pal/hermit: correctly round up microseconds in `Thread::sleep`

This fixes the Hermit-related part of rust-lang#129212 and thus the whole issue, since ESP-IDF is already fixed, as far as I understand.

Fixes rust-lang#129212

r? `@workingjubilee`

CC: `@stlankes`
  • Loading branch information
rust-timer authored Aug 26, 2024
2 parents 22572d0 + edeefc5 commit f3812bd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion library/std/src/sys/pal/hermit/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ impl Thread {

#[inline]
pub fn sleep(dur: Duration) {
let micros = dur.as_micros() + if dur.subsec_nanos() % 1_000 > 0 { 1 } else { 0 };
let micros = u64::try_from(micros).unwrap_or(u64::MAX);

unsafe {
hermit_abi::usleep(dur.as_micros() as u64);
hermit_abi::usleep(micros);
}
}

Expand Down

0 comments on commit f3812bd

Please sign in to comment.