Skip to content

Commit

Permalink
pal/hermit: correctly round up microseconds in Thread::sleep
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
  • Loading branch information
mkroening committed Aug 25, 2024
1 parent 1a94d83 commit 687c8a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 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,10 @@ impl Thread {

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

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

Expand Down

0 comments on commit 687c8a1

Please sign in to comment.