Skip to content

Commit

Permalink
add os_sync_wait_on_address and related definitions
Browse files Browse the repository at this point in the history
(apply <rust-lang#3769> to `main`)
[ resolve conflicts - Trevor ]
(cherry picked from commit 5bd8143)
  • Loading branch information
joboet authored and tgross35 committed Aug 29, 2024
1 parent 5431bdb commit 26bd16f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ fn test_apple(target: &str) {
"netinet/tcp.h",
"netinet/udp.h",
"netinet6/in6_var.h",
"os/clock.h",
"os/lock.h",
"os/signpost.h",
"os/os_sync_wait_on_address.h",
"poll.h",
"pthread.h",
"pthread_spis.h",
Expand Down
13 changes: 13 additions & 0 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ OFDEL
OFILL
OLD_TIME
ONOEOT
OS_CLOCK_MACH_ABSOLUTE_TIME
OS_LOG_TYPE_DEBUG
OS_LOG_TYPE_DEFAULT
OS_LOG_TYPE_ERROR
Expand All @@ -1034,6 +1035,10 @@ OS_LOG_TYPE_INFO
OS_SIGNPOST_EVENT
OS_SIGNPOST_INTERVAL_BEGIN
OS_SIGNPOST_INTERVAL_END
OS_SYNC_WAKE_BY_ADDRESS_NONE
OS_SYNC_WAKE_BY_ADDRESS_SHARED
OS_SYNC_WAIT_ON_ADDRESS_NONE
OS_SYNC_WAIT_ON_ADDRESS_SHARED
OS_UNFAIR_LOCK_INIT
OXTABS
O_ASYNC
Expand Down Expand Up @@ -1951,6 +1956,7 @@ open_memstream
open_wmemstream
openat
openpty
os_clockid_t
os_log_create
os_log_t
os_log_type_enabled
Expand All @@ -1960,6 +1966,13 @@ os_signpost_id_generate
os_signpost_id_make_with_pointer
os_signpost_id_t
os_signpost_type_t
os_sync_wake_by_address_any
os_sync_wake_by_address_all
os_sync_wake_by_address_flags_t
os_sync_wait_on_address
os_sync_wait_on_address_flags_t
os_sync_wait_on_address_with_deadline
os_sync_wait_on_address_with_timeout
os_unfair_lock
os_unfair_lock_assert_not_owner
os_unfair_lock_assert_owner
Expand Down
48 changes: 48 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ 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_clockid_t = u32;

pub type os_sync_wait_on_address_flags_t = u32;
pub type os_sync_wake_by_address_flags_t = u32;

pub type os_unfair_lock = os_unfair_lock_s;
pub type os_unfair_lock_t = *mut os_unfair_lock;

Expand Down Expand Up @@ -5438,6 +5443,15 @@ pub const VOL_CAP_INT_RENAME_SWAP: attrgroup_t = 0x00040000;
pub const VOL_CAP_INT_RENAME_EXCL: attrgroup_t = 0x00080000;
pub const VOL_CAP_INT_RENAME_OPENFAIL: attrgroup_t = 0x00100000;

// os/clock.h
pub const OS_CLOCK_MACH_ABSOLUTE_TIME: os_clockid_t = 32;

// os/os_sync_wait_on_address.h
pub const OS_SYNC_WAIT_ON_ADDRESS_NONE: os_sync_wait_on_address_flags_t = 0x00000000;
pub const OS_SYNC_WAIT_ON_ADDRESS_SHARED: os_sync_wait_on_address_flags_t = 0x00000001;
pub const OS_SYNC_WAKE_BY_ADDRESS_NONE: os_sync_wake_by_address_flags_t = 0x00000000;
pub const OS_SYNC_WAKE_BY_ADDRESS_SHARED: os_sync_wake_by_address_flags_t = 0x00000001;

// <proc.h>
/// Process being created by fork.
pub const SIDL: u32 = 1;
Expand Down Expand Up @@ -5791,6 +5805,40 @@ extern "C" {
pub fn pthread_jit_write_freeze_callbacks_np();
pub fn pthread_cpu_number_np(cpu_number_out: *mut ::size_t) -> ::c_int;

// Available starting with macOS 14.4.
pub fn os_sync_wait_on_address(
addr: *mut ::c_void,
value: u64,
size: ::size_t,
flags: os_sync_wait_on_address_flags_t,
) -> ::c_int;
pub fn os_sync_wait_on_address_with_deadline(
addr: *mut ::c_void,
value: u64,
size: ::size_t,
flags: os_sync_wait_on_address_flags_t,
clockid: os_clockid_t,
deadline: u64,
) -> ::c_int;
pub fn os_sync_wait_on_address_with_timeout(
addr: *mut ::c_void,
value: u64,
size: ::size_t,
flags: os_sync_wait_on_address_flags_t,
clockid: os_clockid_t,
timeout_ns: u64,
) -> ::c_int;
pub fn os_sync_wake_by_address_any(
addr: *mut ::c_void,
size: ::size_t,
flags: os_sync_wake_by_address_flags_t,
) -> ::c_int;
pub fn os_sync_wake_by_address_all(
addr: *mut ::c_void,
size: ::size_t,
flags: os_sync_wake_by_address_flags_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) -> bool;
pub fn os_unfair_lock_unlock(lock: os_unfair_lock_t);
Expand Down

0 comments on commit 26bd16f

Please sign in to comment.