diff --git a/std/src/sys/pal/hermit/thread.rs b/std/src/sys/pal/hermit/thread.rs index bc70b3ac1705c..4c0c0919f4799 100644 --- a/std/src/sys/pal/hermit/thread.rs +++ b/std/src/sys/pal/hermit/thread.rs @@ -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); } }