Skip to content

Conversation

@joboet
Copy link
Member

@joboet joboet commented Jan 12, 2026

On Apple platforms, nanosleep is internally implemented using mach_wait_until, a function that waits until a deadline specified in terms of mach_absolute_time. Since mach_wait_until is public1, we can use it to implement sleep_until by converting Instants (which are measured against CLOCK_UPTIME_RAW, which is equivalent to mach_absolute_time) into mach_absolute_time values.

Related tracking issue: #113752

Footnotes

  1. It's badly documented, but it's defined in the same header as mach_absolute_time, which std used to use for Instant before time: use clock_gettime on macos #116238.

@rustbot rustbot added O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 12, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 12, 2026

r? @ChrisDenton

rustbot has assigned @ChrisDenton.
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

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 12, 2026

The Miri subtree was changed

cc @rust-lang/miri

@JayanAXHF JayanAXHF added O-macos Operating system: macOS S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed O-unix Operating system: Unix-like S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 12, 2026
@madsmtm madsmtm added O-apple Operating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS) and removed O-macos Operating system: macOS labels Jan 13, 2026
@joboet joboet force-pushed the apple-sleep-until branch from 65aa2b0 to d9189bf Compare January 13, 2026 09:45
@rustbot rustbot added the O-unix Operating system: Unix-like label Jan 13, 2026
@joboet joboet added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 13, 2026
@rust-log-analyzer

This comment has been minimized.

@joboet joboet force-pushed the apple-sleep-until branch from d9189bf to ced9de5 Compare January 13, 2026 10:23
@joboet joboet force-pushed the apple-sleep-until branch from ced9de5 to 2ad5f81 Compare January 18, 2026 17:51
@rust-log-analyzer

This comment has been minimized.

@joboet joboet force-pushed the apple-sleep-until branch from 15e7481 to 8e09d54 Compare January 19, 2026 11:49
@joboet joboet force-pushed the apple-sleep-until branch from 8e09d54 to af269ab Compare January 19, 2026 14:31
@ChrisDenton
Copy link
Member

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 19, 2026

📌 Commit af269ab has been approved by ChrisDenton

It is now in the queue for this repository.

@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 Jan 19, 2026
rust-bors bot pushed a commit that referenced this pull request Jan 19, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #148623 (Ignore `#[doc(hidden)]` items when computing trimmed paths for printing)
 - #150550 (Miscellaneous cleanups to borrowck related code)
 - #150879 (Remove the diagnostic lints)
 - #150895 (rustc_errors: Add (heuristic) Syntax Highlighting for `rustc --explain`)
 - #150987 (remote-test-server: Fix header in batch mode)
 - #151004 (std: implement `sleep_until` on Apple platforms)
 - #151045 (Simplify some literal-value negations with `u128::wrapping_neg`)
 - #151119 (Support pointers in type reflection)
 - #151171 (Do not recover from `Trait()` if generic list is unterminated)
 - #151231 (HIR typeck cleanup: clarify and re-style `check_expr_unop`)
 - #151249 (Parse ident with allowing recovery when trying to diagnose)
 - #151295 (THIR patterns: Use `ty::Value` in more places throughout `const_to_pat`)
 - #151326 (Remove `DiagMessage::Translated` in favour of `DiagMessage::Str`)
 - #151361 (add test for issue 61463)
 - #151371 (Add `S-blocked` to `labels_blocking_approval`)

r? @ghost
@rust-bors rust-bors bot merged commit f1922ff into rust-lang:main Jan 20, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Jan 20, 2026
rust-timer added a commit that referenced this pull request Jan 20, 2026
Rollup merge of #151004 - apple-sleep-until, r=ChrisDenton

std: implement `sleep_until` on Apple platforms

On Apple platforms, `nanosleep` is internally [implemented](https://github.com/apple-oss-distributions/Libc/blob/55b54c0a0c37b3b24393b42b90a4c561d6c606b1/gen/nanosleep.c#L281) using `mach_wait_until`, a function that waits until a deadline specified in terms of `mach_absolute_time`. Since `mach_wait_until` is [public](https://github.com/apple-oss-distributions/xnu/blob/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea/osfmk/mach/mach_time.h#L50-L51)[^1], we can use it to implement `sleep_until` by converting `Instant`s (which are measured against `CLOCK_UPTIME_RAW`, which is equivalent to `mach_absolute_time`) into `mach_absolute_time` values.

Related tracking issue: #113752

[^1]: It's badly documented, but it's defined in the same header as `mach_absolute_time`, which  `std` used to use for `Instant` before #116238.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 20, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#148623 (Ignore `#[doc(hidden)]` items when computing trimmed paths for printing)
 - rust-lang/rust#150550 (Miscellaneous cleanups to borrowck related code)
 - rust-lang/rust#150879 (Remove the diagnostic lints)
 - rust-lang/rust#150895 (rustc_errors: Add (heuristic) Syntax Highlighting for `rustc --explain`)
 - rust-lang/rust#150987 (remote-test-server: Fix header in batch mode)
 - rust-lang/rust#151004 (std: implement `sleep_until` on Apple platforms)
 - rust-lang/rust#151045 (Simplify some literal-value negations with `u128::wrapping_neg`)
 - rust-lang/rust#151119 (Support pointers in type reflection)
 - rust-lang/rust#151171 (Do not recover from `Trait()` if generic list is unterminated)
 - rust-lang/rust#151231 (HIR typeck cleanup: clarify and re-style `check_expr_unop`)
 - rust-lang/rust#151249 (Parse ident with allowing recovery when trying to diagnose)
 - rust-lang/rust#151295 (THIR patterns: Use `ty::Value` in more places throughout `const_to_pat`)
 - rust-lang/rust#151326 (Remove `DiagMessage::Translated` in favour of `DiagMessage::Str`)
 - rust-lang/rust#151361 (add test for issue 61463)
 - rust-lang/rust#151371 (Add `S-blocked` to `labels_blocking_approval`)

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-apple Operating system: Apple / Darwin (macOS, iOS, tvOS, visionOS, watchOS) 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.

7 participants