Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shim Apple's futex primitives #4142

Merged
merged 1 commit into from
Feb 2, 2025
Merged

Conversation

joboet
Copy link
Member

@joboet joboet commented Jan 19, 2025

This is necessary to unblock rust-lang/rust#122408. The documentation for these is available here.

Because the futex wait operations (os_sync_wait_on_address et al.) return the number of remaining waiters after returning, this required some changes to the common futex infrastructure, which I've changed to take a callback instead of precalculating the return values.

@RalfJung
Copy link
Member

Thanks for the PR! I just left for a 1-week business trip and will have to catch up with stuff when I am back so it could take a bit before I can take a closer look.

@rustbot

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Jan 29, 2025
Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Overall approach looks great, but I have a bunch of questions and comments. :)

src/concurrency/sync.rs Outdated Show resolved Hide resolved
src/shims/unix/linux_like/sync.rs Outdated Show resolved Hide resolved
src/shims/windows/sync.rs Outdated Show resolved Hide resolved
src/shims/windows/sync.rs Outdated Show resolved Hide resolved
src/shims/unix/macos/foreign_items.rs Show resolved Hide resolved
tests/pass-dep/concurrency/apple-futex.rs Outdated Show resolved Hide resolved
tests/pass-dep/concurrency/apple-futex.rs Show resolved Hide resolved
tests/pass-dep/concurrency/apple-futex.rs Outdated Show resolved Hide resolved
tests/pass-dep/concurrency/apple-futex.rs Show resolved Hide resolved
tests/pass-dep/concurrency/apple-futex.rs Show resolved Hide resolved
tests/pass-dep/concurrency/apple-futex.rs Outdated Show resolved Hide resolved
tests/pass-dep/concurrency/apple-futex.rs Show resolved Hide resolved

let is_shared = flags == shared;
let timeout = clock_timeout.map(|(_, anchor, timeout)| {
(TimeoutClock::Monotonic, anchor, Duration::from_nanos(timeout))
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment making that connection.

@joboet
Copy link
Member Author

joboet commented Feb 2, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Feb 2, 2025
@RalfJung
Copy link
Member

RalfJung commented Feb 2, 2025

This looks great, thanks! Please squash the commits, then we can land this. Please use the --keep-base flag when squashing so that the force-push diff is easier to review. Then write @rustbot ready after you pushed the squashed PR.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Feb 2, 2025
This is necessary to unblock rust-lang/rust#122408. The documentation for these is available [here](https://developer.apple.com/documentation/os/os_sync_wait_on_address?language=objc).

Because the futex wait operations (`os_sync_wait_on_address` et al.) return the number of remaining waiters after returning, this required some changes to the common futex infrastructure, which I've changed to take a callback instead of precalculating the return values.
@joboet
Copy link
Member Author

joboet commented Feb 2, 2025

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Feb 2, 2025
@RalfJung RalfJung enabled auto-merge February 2, 2025 19:30
@RalfJung RalfJung added this pull request to the merge queue Feb 2, 2025
Merged via the queue into rust-lang:master with commit 1c797a2 Feb 2, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Waiting for a review to complete
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants