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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ fn test_apple(target: &str) {
"netinet/ip.h",
"netinet/tcp.h",
"netinet/udp.h",
"os/lock.h",
"poll.h",
"pthread.h",
"pthread_spis.h",
Expand Down
8 changes: 8 additions & 0 deletions libc-test/semver/macos.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
clock_settime
memmem
task_set_info
os_unfair_lock
os_unfair_lock_t
os_unfair_lock_lock
os_unfair_lock_trylock
os_unfair_lock_unlock
os_unfair_lock_assert_owner
os_unfair_lock_assert_not_owner
OS_UNFAIR_LOCK_INIT
16 changes: 16 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ pub type pthread_introspection_hook_t =
extern "C" fn(event: ::c_uint, thread: ::pthread_t, addr: *mut ::c_void, size: ::size_t);
pub type pthread_jit_write_callback_t = Option<extern "C" fn(ctx: *mut ::c_void) -> ::c_int>;

pub type os_unfair_lock_t = *mut os_unfair_lock;

pub type vm_statistics_t = *mut vm_statistics;
pub type vm_statistics_data_t = vm_statistics;
pub type vm_statistics64_t = *mut vm_statistics64;
Expand Down Expand Up @@ -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.

_os_unfair_lock_opaque: u32,
}
}

impl siginfo_t {
Expand Down Expand Up @@ -3863,6 +3869,10 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
__opaque: [0; __PTHREAD_RWLOCK_SIZE__],
};

pub const OS_UNFAIR_LOCK_INIT: os_unfair_lock = os_unfair_lock {
_os_unfair_lock_opaque: 0,
};

pub const MINSIGSTKSZ: ::size_t = 32768;
pub const SIGSTKSZ: ::size_t = 131072;

Expand Down Expand Up @@ -5209,6 +5219,12 @@ extern "C" {
pub fn pthread_jit_write_freeze_callbacks_np();
pub fn pthread_cpu_number_np(cpu_number_out: *mut ::size_t) -> ::c_int;

pub fn os_unfair_lock_lock(lock: os_unfair_lock_t);
pub fn os_unfair_lock_trylock(lock: os_unfair_lock_t) -> ::c_int;
pub fn os_unfair_lock_unlock(lock: os_unfair_lock_t);
pub fn os_unfair_lock_assert_owner(lock: *const os_unfair_lock);
pub fn os_unfair_lock_assert_not_owner(lock: *const os_unfair_lock);

pub fn thread_policy_set(
thread: thread_t,
flavor: thread_policy_flavor_t,
Expand Down