Skip to content

Commit 0f9b760

Browse files
authored
Merge pull request #3886 from tgross35/main-macos-sync-woa
[main] macOS: add `os_sync_wait_on_address` and related definitions
2 parents b4b5fbe + f0b2a0e commit 0f9b760

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

libc-test/build.rs

+22
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,11 @@ 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+
// FIXME: Requires the macOS 14.4 SDK.
226+
//"os/os_sync_wait_on_address.h",
224227
"poll.h",
225228
"pthread.h",
226229
"pthread_spis.h",
@@ -311,6 +314,9 @@ fn test_apple(target: &str) {
311314
return true;
312315
}
313316
match ty {
317+
// FIXME: Requires the macOS 14.4 SDK.
318+
"os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true,
319+
314320
_ => false,
315321
}
316322
});
@@ -325,6 +331,13 @@ fn test_apple(target: &str) {
325331

326332
// FIXME: XCode 13.1 doesn't have it.
327333
"TIOCREMOTE" => true,
334+
335+
// FIXME: Requires the macOS 14.4 SDK.
336+
"OS_SYNC_WAKE_BY_ADDRESS_NONE"
337+
| "OS_SYNC_WAKE_BY_ADDRESS_SHARED"
338+
| "OS_SYNC_WAIT_ON_ADDRESS_NONE"
339+
| "OS_SYNC_WAIT_ON_ADDRESS_SHARED" => true,
340+
328341
_ => false,
329342
}
330343
});
@@ -347,6 +360,15 @@ fn test_apple(target: &str) {
347360
// FIXME: Once the SDK get updated to Ventura's level
348361
"freadlink" | "mknodat" | "mkfifoat" => true,
349362

363+
// FIXME: Requires the macOS 14.4 SDK.
364+
"os_sync_wake_by_address_any"
365+
| "os_sync_wake_by_address_all"
366+
| "os_sync_wake_by_address_flags_t"
367+
| "os_sync_wait_on_address"
368+
| "os_sync_wait_on_address_flags_t"
369+
| "os_sync_wait_on_address_with_deadline"
370+
| "os_sync_wait_on_address_with_timeout" => true,
371+
350372
_ => false,
351373
}
352374
});

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

@@ -5422,6 +5427,15 @@ pub const VOL_CAP_INT_RENAME_SWAP: attrgroup_t = 0x00040000;
54225427
pub const VOL_CAP_INT_RENAME_EXCL: attrgroup_t = 0x00080000;
54235428
pub const VOL_CAP_INT_RENAME_OPENFAIL: attrgroup_t = 0x00100000;
54245429

5430+
// os/clock.h
5431+
pub const OS_CLOCK_MACH_ABSOLUTE_TIME: os_clockid_t = 32;
5432+
5433+
// os/os_sync_wait_on_address.h
5434+
pub const OS_SYNC_WAIT_ON_ADDRESS_NONE: os_sync_wait_on_address_flags_t = 0x00000000;
5435+
pub const OS_SYNC_WAIT_ON_ADDRESS_SHARED: os_sync_wait_on_address_flags_t = 0x00000001;
5436+
pub const OS_SYNC_WAKE_BY_ADDRESS_NONE: os_sync_wake_by_address_flags_t = 0x00000000;
5437+
pub const OS_SYNC_WAKE_BY_ADDRESS_SHARED: os_sync_wake_by_address_flags_t = 0x00000001;
5438+
54255439
// <proc.h>
54265440
/// Process being created by fork.
54275441
pub const SIDL: u32 = 1;
@@ -5775,6 +5789,40 @@ extern "C" {
57755789
pub fn pthread_jit_write_freeze_callbacks_np();
57765790
pub fn pthread_cpu_number_np(cpu_number_out: *mut ::size_t) -> ::c_int;
57775791

5792+
// Available starting with macOS 14.4.
5793+
pub fn os_sync_wait_on_address(
5794+
addr: *mut ::c_void,
5795+
value: u64,
5796+
size: ::size_t,
5797+
flags: os_sync_wait_on_address_flags_t,
5798+
) -> ::c_int;
5799+
pub fn os_sync_wait_on_address_with_deadline(
5800+
addr: *mut ::c_void,
5801+
value: u64,
5802+
size: ::size_t,
5803+
flags: os_sync_wait_on_address_flags_t,
5804+
clockid: os_clockid_t,
5805+
deadline: u64,
5806+
) -> ::c_int;
5807+
pub fn os_sync_wait_on_address_with_timeout(
5808+
addr: *mut ::c_void,
5809+
value: u64,
5810+
size: ::size_t,
5811+
flags: os_sync_wait_on_address_flags_t,
5812+
clockid: os_clockid_t,
5813+
timeout_ns: u64,
5814+
) -> ::c_int;
5815+
pub fn os_sync_wake_by_address_any(
5816+
addr: *mut ::c_void,
5817+
size: ::size_t,
5818+
flags: os_sync_wake_by_address_flags_t,
5819+
) -> ::c_int;
5820+
pub fn os_sync_wake_by_address_all(
5821+
addr: *mut ::c_void,
5822+
size: ::size_t,
5823+
flags: os_sync_wake_by_address_flags_t,
5824+
) -> ::c_int;
5825+
57785826
pub fn os_unfair_lock_lock(lock: os_unfair_lock_t);
57795827
pub fn os_unfair_lock_trylock(lock: os_unfair_lock_t) -> bool;
57805828
pub fn os_unfair_lock_unlock(lock: os_unfair_lock_t);

0 commit comments

Comments
 (0)