pal/hermit: saturate usleep microseconds at u64::MAX

Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
This commit is contained in:
Martin Kröning 2024-08-26 00:04:00 +02:00
parent 687c8a1eab
commit edeefc532f
Failed to extract signature

View File

@ -78,9 +78,10 @@ pub fn set_name(_name: &CStr) {
#[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);
}
}