Skip to content

Commit 26bd16f

Browse files
joboettgross35
authored andcommitted
add os_sync_wait_on_address and related definitions
(apply <#3769> to `main`) [ resolve conflicts - Trevor ] (cherry picked from commit 5bd8143)
1 parent 5431bdb commit 26bd16f

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

libc-test/build.rs

+2
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,10 @@ fn test_apple(target: &str) {
219219
"netinet/tcp.h",
220220
"netinet/udp.h",
221221
"netinet6/in6_var.h",
222+
"os/clock.h",
222223
"os/lock.h",
223224
"os/signpost.h",
225+
"os/os_sync_wait_on_address.h",
224226
"poll.h",
225227
"pthread.h",
226228
"pthread_spis.h",

libc-test/semver/apple.txt

+13
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ OFDEL
10261026
OFILL
10271027
OLD_TIME
10281028
ONOEOT
1029+
OS_CLOCK_MACH_ABSOLUTE_TIME
10291030
OS_LOG_TYPE_DEBUG
10301031
OS_LOG_TYPE_DEFAULT
10311032
OS_LOG_TYPE_ERROR
@@ -1034,6 +1035,10 @@ OS_LOG_TYPE_INFO
10341035
OS_SIGNPOST_EVENT
10351036
OS_SIGNPOST_INTERVAL_BEGIN
10361037
OS_SIGNPOST_INTERVAL_END
1038+
OS_SYNC_WAKE_BY_ADDRESS_NONE
1039+
OS_SYNC_WAKE_BY_ADDRESS_SHARED
1040+
OS_SYNC_WAIT_ON_ADDRESS_NONE
1041+
OS_SYNC_WAIT_ON_ADDRESS_SHARED
10371042
OS_UNFAIR_LOCK_INIT
10381043
OXTABS
10391044
O_ASYNC
@@ -1951,6 +1956,7 @@ open_memstream
19511956
open_wmemstream
19521957
openat
19531958
openpty
1959+
os_clockid_t
19541960
os_log_create
19551961
os_log_t
19561962
os_log_type_enabled
@@ -1960,6 +1966,13 @@ os_signpost_id_generate
19601966
os_signpost_id_make_with_pointer
19611967
os_signpost_id_t
19621968
os_signpost_type_t
1969+
os_sync_wake_by_address_any
1970+
os_sync_wake_by_address_all
1971+
os_sync_wake_by_address_flags_t
1972+
os_sync_wait_on_address
1973+
os_sync_wait_on_address_flags_t
1974+
os_sync_wait_on_address_with_deadline
1975+
os_sync_wait_on_address_with_timeout
19631976
os_unfair_lock
19641977
os_unfair_lock_assert_not_owner
19651978
os_unfair_lock_assert_owner

src/unix/bsd/apple/mod.rs

+48
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ pub type pthread_introspection_hook_t =
123123
extern "C" fn(event: ::c_uint, thread: ::pthread_t, addr: *mut ::c_void, size: ::size_t);
124124
pub type pthread_jit_write_callback_t = ::Option<extern "C" fn(ctx: *mut ::c_void) -> ::c_int>;
125125

126+
pub type os_clockid_t = u32;
127+
128+
pub type os_sync_wait_on_address_flags_t = u32;
129+
pub type os_sync_wake_by_address_flags_t = u32;
130+
126131
pub type os_unfair_lock = os_unfair_lock_s;
127132
pub type os_unfair_lock_t = *mut os_unfair_lock;
128133

@@ -5438,6 +5443,15 @@ pub const VOL_CAP_INT_RENAME_SWAP: attrgroup_t = 0x00040000;
54385443
pub const VOL_CAP_INT_RENAME_EXCL: attrgroup_t = 0x00080000;
54395444
pub const VOL_CAP_INT_RENAME_OPENFAIL: attrgroup_t = 0x00100000;
54405445

5446+
// os/clock.h
5447+
pub const OS_CLOCK_MACH_ABSOLUTE_TIME: os_clockid_t = 32;
5448+
5449+
// os/os_sync_wait_on_address.h
5450+
pub const OS_SYNC_WAIT_ON_ADDRESS_NONE: os_sync_wait_on_address_flags_t = 0x00000000;
5451+
pub const OS_SYNC_WAIT_ON_ADDRESS_SHARED: os_sync_wait_on_address_flags_t = 0x00000001;
5452+
pub const OS_SYNC_WAKE_BY_ADDRESS_NONE: os_sync_wake_by_address_flags_t = 0x00000000;
5453+
pub const OS_SYNC_WAKE_BY_ADDRESS_SHARED: os_sync_wake_by_address_flags_t = 0x00000001;
5454+
54415455
// <proc.h>
54425456
/// Process being created by fork.
54435457
pub const SIDL: u32 = 1;
@@ -5791,6 +5805,40 @@ extern "C" {
57915805
pub fn pthread_jit_write_freeze_callbacks_np();
57925806
pub fn pthread_cpu_number_np(cpu_number_out: *mut ::size_t) -> ::c_int;
57935807

5808+
// Available starting with macOS 14.4.
5809+
pub fn os_sync_wait_on_address(
5810+
addr: *mut ::c_void,
5811+
value: u64,
5812+
size: ::size_t,
5813+
flags: os_sync_wait_on_address_flags_t,
5814+
) -> ::c_int;
5815+
pub fn os_sync_wait_on_address_with_deadline(
5816+
addr: *mut ::c_void,
5817+
value: u64,
5818+
size: ::size_t,
5819+
flags: os_sync_wait_on_address_flags_t,
5820+
clockid: os_clockid_t,
5821+
deadline: u64,
5822+
) -> ::c_int;
5823+
pub fn os_sync_wait_on_address_with_timeout(
5824+
addr: *mut ::c_void,
5825+
value: u64,
5826+
size: ::size_t,
5827+
flags: os_sync_wait_on_address_flags_t,
5828+
clockid: os_clockid_t,
5829+
timeout_ns: u64,
5830+
) -> ::c_int;
5831+
pub fn os_sync_wake_by_address_any(
5832+
addr: *mut ::c_void,
5833+
size: ::size_t,
5834+
flags: os_sync_wake_by_address_flags_t,
5835+
) -> ::c_int;
5836+
pub fn os_sync_wake_by_address_all(
5837+
addr: *mut ::c_void,
5838+
size: ::size_t,
5839+
flags: os_sync_wake_by_address_flags_t,
5840+
) -> ::c_int;
5841+
57945842
pub fn os_unfair_lock_lock(lock: os_unfair_lock_t);
57955843
pub fn os_unfair_lock_trylock(lock: os_unfair_lock_t) -> bool;
57965844
pub fn os_unfair_lock_unlock(lock: os_unfair_lock_t);

0 commit comments

Comments
 (0)