Rollup merge of #129588 - hermit-os:sleep-micros, r=workingjubilee · patricklam/verify-rust-std@77a1318 (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit 77a1318
Rollup merge of rust-lang#129588 - hermit-os:sleep-micros, r=workingjubilee
pal/hermit: correctly round up microseconds in `Thread::sleep` This fixes the Hermit-related part of rust-lang#129212 and thus the whole issue, since ESP-IDF is already fixed, as far as I understand.Fixes rust-lang#129212r? `@workingjubilee` CC: `@stlankes`
File tree
1 file changed
lines changed
1 file changed
lines changed
Lines changed: 4 additions & 1 deletion
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -77,8 +77,11 @@ impl Thread { | ||
77 | 77 | |
78 | 78 | #[inline] |
79 | 79 | pub fn sleep(dur: Duration) { |
80 | +let micros = dur.as_micros() + if dur.subsec_nanos() % 1_000 > 0 { 1 } else { 0 }; | |
81 | +let micros = u64::try_from(micros).unwrap_or(u64::MAX); | |
82 | + | |
80 | 83 | unsafe { |
81 | - hermit_abi::usleep(dur.as_micros() as u64); | |
84 | + hermit_abi::usleep(micros); | |
82 | 85 | } |
83 | 86 | } |
84 | 87 |