Skip to content

Add os_unfair_lock signatures/primitives #2918

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

Closed
wants to merge 3 commits into from

Conversation

notgull
Copy link
Contributor

@notgull notgull commented Sep 21, 2022

This pull request resolves #2917 by adding bindings to the os_unfair_lock API found in Apple operating systems. I've added the following code:

  • os_unfair_lock, which is an opaque, 32-bit structure.
  • os_unfair_lock_t, which is a mutable pointer to an os_unfair_lock.
  • The constant OS_UNFAIR_LOCK_INIT, which just initializes a lock to zero.
  • The functions os_unfair_lock_lock, os_unfair_lock_trylock, os_unfair_lock_unlock, os_unfair_lock_assert_owner and os_unfair_lock_assert_not_owner, which are based on the signatures they have here.

This is my first time opening a PR here! I'm excited, but let me know if I've missed anything.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Amanieu (or someone else) soon.

Please see the contribution instructions for more information.

@JohnTitor
Copy link
Member

CI failed, does it pass on your end? If so that means our CI image is old and we could skip the test for them.

@@ -1295,6 +1297,10 @@ s_no_extra_traits! {
pub l2p_contigbytes: ::off_t,
pub l2p_devoffset: ::off_t,
}

pub struct os_unfair_lock {
Copy link
Contributor

Choose a reason for hiding this comment

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

actually os_unfair_lock is an alias of struct os_unfair_lock_s in reality.

@devnexen
Copy link
Contributor

CI failed, does it pass on your end? If so that means our CI image is old and we could skip the test for them.

the os_unfair api is available since sierra (10.12) if that helps.

@notgull
Copy link
Contributor Author

notgull commented Oct 3, 2022

Sorry for the late response, I haven't been able to gain access to a macOS machine that isn't horribly out of date yet. It may be a while before I can.

@thomcc
Copy link
Member

thomcc commented Oct 5, 2022

No worries, I've finished up the bindings for you (tired of defining this in local extern "C"s), I hope you don't mind!

@bors bors closed this in 14f31db Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

os_unfair_lock_t on macOS
6 participants