Skip to content

Commit

Permalink
pal/hermit: saturate usleep microseconds at u64::MAX
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 fdb5fc1 commit c688def
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion std/src/sys/pal/hermit/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ 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(micros as u64);
hermit_abi::usleep(micros);
}
}

Expand Down

0 comments on commit c688def

Please sign in to comment.