diff options
| author | bors <bors@rust-lang.org> | 2024-08-26 20:04:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-26 20:04:35 +0000 |
| commit | 515395af0efdbdd657ff08a1f6d28e553856654f (patch) | |
| tree | 44d4cf3516921f6f9d5946f65af3834bf6233b10 /library/std/src/sys/pal | |
| parent | 22572d0994593197593e2a1b7b18d720a9a349a7 (diff) | |
| parent | 114e60ff79910ca71c00e075a061f010b573dfaa (diff) | |
| download | rust-515395af0efdbdd657ff08a1f6d28e553856654f.tar.gz rust-515395af0efdbdd657ff08a1f6d28e553856654f.zip | |
Auto merge of #129615 - matthiaskrgr:rollup-lw733x7, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #129190 (Add f16 and f128 to tests/ui/consts/const-float-bits-conv.rs) - #129377 (Add implementations for `unbounded_shl`/`unbounded_shr`) - #129539 (link to Future::poll from the Poll docs) - #129588 (pal/hermit: correctly round up microseconds in `Thread::sleep`) - #129592 (Remove cfg(test) from library/core) - #129597 (mv `build_reduced_graph_for_external_crate_res` into Resolver) - #129600 (Tie `impl_trait_overcaptures` lint to Rust 2024) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src/sys/pal')
| -rw-r--r-- | library/std/src/sys/pal/hermit/thread.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/library/std/src/sys/pal/hermit/thread.rs b/library/std/src/sys/pal/hermit/thread.rs index 6321f92e3d9..4c0c0919f47 100644 --- a/library/std/src/sys/pal/hermit/thread.rs +++ b/library/std/src/sys/pal/hermit/thread.rs @@ -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); } } |
