Skip to content

std: implement sleep_until for Fuchsia - #152617

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
joboet:fuchsia_sleep_until
Aug 21, 2026
Merged

std: implement sleep_until for Fuchsia#152617
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
joboet:fuchsia_sleep_until

Conversation

@joboet

@joboet joboet commented Feb 14, 2026

Copy link
Copy Markdown
Member

Tracking issue: #113752

Unfortunately Fuchsia's clock_nanosleep is only a stub. The kernel's zx_nanosleep syscall however does exactly what's needed.

I've done a few drive-by changes in the two outer commits, our uses of zx_time_t use the zx_instant_mono_t alias nowadays and the syscall table in the sleep_until documentation didn't mark the function names as code.

@rustbot ping fuchsia

@joboet
joboet marked this pull request as ready for review February 14, 2026 14:10
@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. O-fuchsia Operating system: Fuchsia labels Feb 14, 2026
@rustbot

rustbot commented Feb 14, 2026

Copy link
Copy Markdown
Collaborator

Hey friends of Fuchsia! This issue could use some guidance on how this should be
resolved/implemented on Fuchsia. Could one of you weigh in?

cc @erickt @Nashenas88

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 14, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 14, 2026
@rustbot

rustbot commented Feb 14, 2026

Copy link
Copy Markdown
Collaborator

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, ibraheemdev

@rust-bors

This comment has been minimized.

@Nashenas88

Copy link
Copy Markdown
Contributor

Sorry for the delay here. I was on vacation, then out sick for a bit.

The implementation looks correct to me. Thank you for updating the zx_time_ts to zx_instant_mono_ts! I'll take this back to the team since I believe we should have updated the rust bindings when that change was made.

One nit on the commit comment: while most usages of zx_time_t are now zx_instant_mono_t, there are still usages where zx_time_t is valid and distinct from zx_instant_mono_t. I believe this is always the case where the exact timeline used (e.g. boot or monotonic) is configurable. For example, with zx_timer_set.

@joboet
joboet force-pushed the fuchsia_sleep_until branch from 2e608fb to 8e4293c Compare May 21, 2026 13:46
@rustbot

This comment has been minimized.

@joboet
joboet force-pushed the fuchsia_sleep_until branch from 8e4293c to a31064a Compare May 21, 2026 13:48
@joboet

joboet commented Aug 18, 2026

Copy link
Copy Markdown
Member Author

@rustbot reroll

@rustbot rustbot assigned nia-e and unassigned ibraheemdev Aug 18, 2026
@nia-e

nia-e commented Aug 18, 2026

Copy link
Copy Markdown
Member

I don't suppose there's any fuschia runner to allow us to add a test? shame. the job for it seems to have been disabled for a while as well 🫠

i suppose it's at least worth a rebase and check build if you have a local fuchsia machine this can run on, since it is a tier 2 target

@nia-e

nia-e commented Aug 19, 2026

Copy link
Copy Markdown
Member

dug into this a bit - seems like fuchsia ci is just ... a lost cause for now & google does their own internal testing if they care? either way, not something that should be libs' task to fix, and it seems like you did your due diligence here. ill wait for a rebase just in case and then r=me

@erickt

erickt commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Oh shucks I forgot we had the fuchsia ci turned off. I’ll try to get it back on. I’m the meantime I’ll run this code by our time folks to make sure this implementation is correct.

/// | Hurd | [`clock_nanosleep`] (Monotonic Clock) |
/// | Vxworks | [`clock_nanosleep`] (Monotonic Clock) |
/// | Apple | `mach_wait_until` |
/// | Fuchsia | [`zx_nanosleep`] |

@erickt erickt Aug 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zx_nanosleep is also using our monotonic clock, so this should be:

/// | Fuchsia   | [`zx_nanosleep`]   (Monotonic Clock)

View changes since the review

@joboet joboet Aug 20, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "(Monotonic Clock)" comment is only relevant for clock_nanosleep since it can also be used with CLOCK_REALTIME. The situation on the Apple platforms – where there is no comment – is the same as on Fuchsia, the API only supports one clock.

@erickt

erickt commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This looks correct, other than the one comment. Thanks so much for implementing this for us!

@joboet
joboet force-pushed the fuchsia_sleep_until branch from a31064a to 1c0a0d9 Compare August 20, 2026 11:25
@rustbot

rustbot commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@joboet

joboet commented Aug 20, 2026

Copy link
Copy Markdown
Member Author

Thank you having a look @erickt 😊! And thanks, Nia, for picking this up.

Rebased and rechecked, it still works, so
@bors r=@nia-e

@rust-bors

rust-bors Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 1c0a0d9 has been approved by nia-e

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 10. This pull request will be tested once the tree is reopened.

Reason for tree closure: Main branch is broken

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 20, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 20, 2026
std: implement `sleep_until` for Fuchsia

Tracking issue: rust-lang#113752

Unfortunately Fuchsia's `clock_nanosleep` is [only a stub](https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/src/time/clock_nanosleep.c;l=4;drc=26e68e7948a6cc4a1c4a0c8eb19b7e4a2dc27153). The kernel's `zx_nanosleep` syscall however does exactly what's needed.

I've done a few drive-by changes in the two outer commits, our uses of `zx_time_t` use the `zx_instant_mono_t` alias nowadays and the syscall table in the `sleep_until` documentation didn't mark the function names as code.

@rustbot ping fuchsia
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 20, 2026
std: implement `sleep_until` for Fuchsia

Tracking issue: rust-lang#113752

Unfortunately Fuchsia's `clock_nanosleep` is [only a stub](https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/src/time/clock_nanosleep.c;l=4;drc=26e68e7948a6cc4a1c4a0c8eb19b7e4a2dc27153). The kernel's `zx_nanosleep` syscall however does exactly what's needed.

I've done a few drive-by changes in the two outer commits, our uses of `zx_time_t` use the `zx_instant_mono_t` alias nowadays and the syscall table in the `sleep_until` documentation didn't mark the function names as code.

@rustbot ping fuchsia
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 20, 2026
std: implement `sleep_until` for Fuchsia

Tracking issue: rust-lang#113752

Unfortunately Fuchsia's `clock_nanosleep` is [only a stub](https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/src/time/clock_nanosleep.c;l=4;drc=26e68e7948a6cc4a1c4a0c8eb19b7e4a2dc27153). The kernel's `zx_nanosleep` syscall however does exactly what's needed.

I've done a few drive-by changes in the two outer commits, our uses of `zx_time_t` use the `zx_instant_mono_t` alias nowadays and the syscall table in the `sleep_until` documentation didn't mark the function names as code.

@rustbot ping fuchsia
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 20, 2026
std: implement `sleep_until` for Fuchsia

Tracking issue: rust-lang#113752

Unfortunately Fuchsia's `clock_nanosleep` is [only a stub](https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/src/time/clock_nanosleep.c;l=4;drc=26e68e7948a6cc4a1c4a0c8eb19b7e4a2dc27153). The kernel's `zx_nanosleep` syscall however does exactly what's needed.

I've done a few drive-by changes in the two outer commits, our uses of `zx_time_t` use the `zx_instant_mono_t` alias nowadays and the syscall table in the `sleep_until` documentation didn't mark the function names as code.

@rustbot ping fuchsia
rust-bors Bot pushed a commit that referenced this pull request Aug 20, 2026
…uwer

Rollup of 20 pull requests

Successful merges:

 - #152617 (std: implement `sleep_until` for Fuchsia)
 - #158934 (diagnostics: fix `let x: vec![]` suggestion pointing into stdlib)
 - #161277 (bootstrap: Move all non-module items out of the crate root)
 - #161295 (std: don't panic on long-elapsed deadlines for `sleep_until`)
 - #161368 (Double-word align `_Unwind_Exception`)
 - #161370 (Uplift rustfmt macro formatting fix)
 - #161378 (`FlowSensitiveAnalysis` cleanups)
 - #158032 (Offload expose device selection)
 - #158855 (Add `desktop` method to `CommandExt`)
 - #161199 (Add regression test for non lifetime binders)
 - #161302 (Add regression test for inconsistent import resolution from issue 147208)
 - #161329 (Add regression tests for a few fixed issues with E-needs-test)
 - #161330 (Add regression test for nested RPIT not an iterator ICE)
 - #161351 (Cleanup: Move impl of `#[rustc_dump_object_lifetime_defaults]`)
 - #161355 (Add file path to some archive build errors)
 - #161373 (Allow running EC2 jobs locally)
 - #161393 (Configure LLM policy URL for triagebot)
 - #161409 (Add back `tests/rustdoc-gui/notable-trait.goml` test)
 - #161410 (Fix rustdoc remapping `documentation` scope documentation)
 - #161415 (Update expect messages in path docs to better follow guidelines)
rust-bors Bot pushed a commit that referenced this pull request Aug 21, 2026
Rollup of 25 pull requests

Successful merges:

 - #152617 (std: implement `sleep_until` for Fuchsia)
 - #158934 (diagnostics: fix `let x: vec![]` suggestion pointing into stdlib)
 - #160995 (Tiny readability cleanups for initialization dataflow analyses)
 - #161277 (bootstrap: Move all non-module items out of the crate root)
 - #161295 (std: don't panic on long-elapsed deadlines for `sleep_until`)
 - #161368 (Double-word align `_Unwind_Exception`)
 - #161370 (Uplift rustfmt macro formatting fix)
 - #161378 (`FlowSensitiveAnalysis` cleanups)
 - #161420 (Bump wasm-component-ld to 0.5.30)
 - #161429 (Tighten allocator `Send`/`Sync` requirements for `Arc` in preparation for refactor)
 - #158032 (Offload expose device selection)
 - #158855 (Add `desktop` method to `CommandExt`)
 - #160299 (Stabilize `bool::toggle`)
 - #160842 (Apply `&[T]` visualizer to `*const [T]`, `*mut [T]` and `Box<[T]>`)
 - #160981 (Partially support building and locating wasm proc-macros)
 - #161199 (Add regression test for non lifetime binders)
 - #161212 (rust-installer/install-template.sh: catch cp(1) error when installing…)
 - #161302 (Add regression test for inconsistent import resolution from issue 147208)
 - #161329 (Add regression tests for a few fixed issues with E-needs-test)
 - #161330 (Add regression test for nested RPIT not an iterator ICE)
 - #161331 (Bitset simplifications)
 - #161340 (rustdoc: enable scrolling only on table/code)
 - #161351 (Cleanup: Move impl of `#[rustc_dump_object_lifetime_defaults]`)
 - #161355 (Add file path to some archive build errors)
 - #161373 (Allow running EC2 jobs locally)
rust-bors Bot pushed a commit that referenced this pull request Aug 21, 2026
Rollup of 25 pull requests

Successful merges:

 - #152617 (std: implement `sleep_until` for Fuchsia)
 - #158934 (diagnostics: fix `let x: vec![]` suggestion pointing into stdlib)
 - #160995 (Tiny readability cleanups for initialization dataflow analyses)
 - #161277 (bootstrap: Move all non-module items out of the crate root)
 - #161295 (std: don't panic on long-elapsed deadlines for `sleep_until`)
 - #161368 (Double-word align `_Unwind_Exception`)
 - #161370 (Uplift rustfmt macro formatting fix)
 - #161378 (`FlowSensitiveAnalysis` cleanups)
 - #161420 (Bump wasm-component-ld to 0.5.30)
 - #161429 (Tighten allocator `Send`/`Sync` requirements for `Arc` in preparation for refactor)
 - #158032 (Offload expose device selection)
 - #158855 (Add `desktop` method to `CommandExt`)
 - #160299 (Stabilize `bool::toggle`)
 - #160842 (Apply `&[T]` visualizer to `*const [T]`, `*mut [T]` and `Box<[T]>`)
 - #160981 (Partially support building and locating wasm proc-macros)
 - #161199 (Add regression test for non lifetime binders)
 - #161212 (rust-installer/install-template.sh: catch cp(1) error when installing…)
 - #161302 (Add regression test for inconsistent import resolution from issue 147208)
 - #161329 (Add regression tests for a few fixed issues with E-needs-test)
 - #161330 (Add regression test for nested RPIT not an iterator ICE)
 - #161331 (Bitset simplifications)
 - #161340 (rustdoc: enable scrolling only on table/code)
 - #161351 (Cleanup: Move impl of `#[rustc_dump_object_lifetime_defaults]`)
 - #161355 (Add file path to some archive build errors)
 - #161373 (Allow running EC2 jobs locally)
@rust-bors
rust-bors Bot merged commit 81d5d74 into rust-lang:main Aug 21, 2026
13 checks passed
rust-bors Bot pushed a commit that referenced this pull request Aug 21, 2026
Rollup merge of #152617 - joboet:fuchsia_sleep_until, r=nia-e

std: implement `sleep_until` for Fuchsia

Tracking issue: #113752

Unfortunately Fuchsia's `clock_nanosleep` is [only a stub](https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/src/time/clock_nanosleep.c;l=4;drc=26e68e7948a6cc4a1c4a0c8eb19b7e4a2dc27153). The kernel's `zx_nanosleep` syscall however does exactly what's needed.

I've done a few drive-by changes in the two outer commits, our uses of `zx_time_t` use the `zx_instant_mono_t` alias nowadays and the syscall table in the `sleep_until` documentation didn't mark the function names as code.

@rustbot ping fuchsia
@rustbot rustbot added this to the 1.100.0 milestone Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-fuchsia Operating system: Fuchsia O-unix Operating system: Unix-like S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants