Skip to content

Commit 043e8a3

Browse files
authored
Merge pull request #3769 from joboet/libc-0.2
macOS: add `os_sync_wait_on_address` and related definitions
2 parents 9e5ecb6 + 17cb3a2 commit 043e8a3

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
@@ -239,8 +239,11 @@ fn test_apple(target: &str) {
239239
"netinet/ip.h",
240240
"netinet/tcp.h",
241241
"netinet/udp.h",
242+
"os/clock.h",
242243
"os/lock.h",
243244
"os/signpost.h",
245+
// FIXME: Requires the macOS 14.4 SDK.
246+
//"os/os_sync_wait_on_address.h",
244247
"poll.h",
245248
"pthread.h",
246249
"pthread_spis.h",
@@ -329,6 +332,9 @@ fn test_apple(target: &str) {
329332
return true;
330333
}
331334
match ty {
335+
// FIXME: Requires the macOS 14.4 SDK.
336+
"os_sync_wake_by_address_flags_t" | "os_sync_wait_on_address_flags_t" => true,
337+
332338
_ => false,
333339
}
334340
});
@@ -347,6 +353,13 @@ fn test_apple(target: &str) {
347353

348354
// FIXME: XCode 13.1 doesn't have it.
349355
"TIOCREMOTE" => true,
356+
357+
// FIXME: Requires the macOS 14.4 SDK.
358+
"OS_SYNC_WAKE_BY_ADDRESS_NONE"
359+
| "OS_SYNC_WAKE_BY_ADDRESS_SHARED"
360+
| "OS_SYNC_WAIT_ON_ADDRESS_NONE"
361+
| "OS_SYNC_WAIT_ON_ADDRESS_SHARED" => true,
362+
350363
_ => false,
351364
}
352365
});
@@ -372,6 +385,15 @@ fn test_apple(target: &str) {
372385
// FIXME: Once the SDK get updated to Ventura's level
373386
"freadlink" | "mknodat" | "mkfifoat" => true,
374387

388+
// FIXME: Requires the macOS 14.4 SDK.
389+
"os_sync_wake_by_address_any"
390+
| "os_sync_wake_by_address_all"
391+
| "os_sync_wake_by_address_flags_t"
392+
| "os_sync_wait_on_address"
393+
| "os_sync_wait_on_address_flags_t"
394+
| "os_sync_wait_on_address_with_deadline"
395+
| "os_sync_wait_on_address_with_timeout" => true,
396+
375397
_ => false,
376398
}
377399
});

libc-test/semver/apple.txt

+13
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ OFDEL
10231023
OFILL
10241024
OLD_TIME
10251025
ONOEOT
1026+
OS_CLOCK_MACH_ABSOLUTE_TIME
10261027
OS_LOG_TYPE_DEBUG
10271028
OS_LOG_TYPE_DEFAULT
10281029
OS_LOG_TYPE_ERROR
@@ -1031,6 +1032,10 @@ OS_LOG_TYPE_INFO
10311032
OS_SIGNPOST_EVENT
10321033
OS_SIGNPOST_INTERVAL_BEGIN
10331034
OS_SIGNPOST_INTERVAL_END
1035+
OS_SYNC_WAKE_BY_ADDRESS_NONE
1036+
OS_SYNC_WAKE_BY_ADDRESS_SHARED
1037+
OS_SYNC_WAIT_ON_ADDRESS_NONE
1038+
OS_SYNC_WAIT_ON_ADDRESS_SHARED
10341039
OS_UNFAIR_LOCK_INIT
10351040
OXTABS
10361041
O_ASYNC
@@ -2049,6 +2054,7 @@ open_memstream
20492054
open_wmemstream
20502055
openat
20512056
openpty
2057+
os_clockid_t
20522058
os_log_create
20532059
os_log_t
20542060
os_log_type_enabled
@@ -2058,6 +2064,13 @@ os_signpost_id_generate
20582064
os_signpost_id_make_with_pointer
20592065
os_signpost_id_t
20602066
os_signpost_type_t
2067+
os_sync_wake_by_address_any
2068+
os_sync_wake_by_address_all
2069+
os_sync_wake_by_address_flags_t
2070+
os_sync_wait_on_address
2071+
os_sync_wait_on_address_flags_t
2072+
os_sync_wait_on_address_with_deadline
2073+
os_sync_wait_on_address_with_timeout
20612074
os_unfair_lock
20622075
os_unfair_lock_assert_not_owner
20632076
os_unfair_lock_assert_owner

src/unix/bsd/apple/mod.rs

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

124+
pub type os_clockid_t = u32;
125+
126+
pub type os_sync_wait_on_address_flags_t = u32;
127+
pub type os_sync_wake_by_address_flags_t = u32;
128+
124129
pub type os_unfair_lock = os_unfair_lock_s;
125130
pub type os_unfair_lock_t = *mut os_unfair_lock;
126131

@@ -5441,6 +5446,15 @@ pub const VOL_CAP_INT_RENAME_SWAP: attrgroup_t = 0x00040000;
54415446
pub const VOL_CAP_INT_RENAME_EXCL: attrgroup_t = 0x00080000;
54425447
pub const VOL_CAP_INT_RENAME_OPENFAIL: attrgroup_t = 0x00100000;
54435448

5449+
// os/clock.h
5450+
pub const OS_CLOCK_MACH_ABSOLUTE_TIME: os_clockid_t = 32;
5451+
5452+
// os/os_sync_wait_on_address.h
5453+
pub const OS_SYNC_WAIT_ON_ADDRESS_NONE: os_sync_wait_on_address_flags_t = 0x00000000;
5454+
pub const OS_SYNC_WAIT_ON_ADDRESS_SHARED: os_sync_wait_on_address_flags_t = 0x00000001;
5455+
pub const OS_SYNC_WAKE_BY_ADDRESS_NONE: os_sync_wake_by_address_flags_t = 0x00000000;
5456+
pub const OS_SYNC_WAKE_BY_ADDRESS_SHARED: os_sync_wake_by_address_flags_t = 0x00000001;
5457+
54445458
// <proc.h>
54455459
/// Process being created by fork.
54465460
pub const SIDL: u32 = 1;
@@ -5834,6 +5848,40 @@ extern "C" {
58345848
pub fn pthread_jit_write_freeze_callbacks_np();
58355849
pub fn pthread_cpu_number_np(cpu_number_out: *mut ::size_t) -> ::c_int;
58365850

5851+
// Available starting with macOS 14.4.
5852+
pub fn os_sync_wait_on_address(
5853+
addr: *mut ::c_void,
5854+
value: u64,
5855+
size: ::size_t,
5856+
flags: os_sync_wait_on_address_flags_t,
5857+
) -> ::c_int;
5858+
pub fn os_sync_wait_on_address_with_deadline(
5859+
addr: *mut ::c_void,
5860+
value: u64,
5861+
size: ::size_t,
5862+
flags: os_sync_wait_on_address_flags_t,
5863+
clockid: os_clockid_t,
5864+
deadline: u64,
5865+
) -> ::c_int;
5866+
pub fn os_sync_wait_on_address_with_timeout(
5867+
addr: *mut ::c_void,
5868+
value: u64,
5869+
size: ::size_t,
5870+
flags: os_sync_wait_on_address_flags_t,
5871+
clockid: os_clockid_t,
5872+
timeout_ns: u64,
5873+
) -> ::c_int;
5874+
pub fn os_sync_wake_by_address_any(
5875+
addr: *mut ::c_void,
5876+
size: ::size_t,
5877+
flags: os_sync_wake_by_address_flags_t,
5878+
) -> ::c_int;
5879+
pub fn os_sync_wake_by_address_all(
5880+
addr: *mut ::c_void,
5881+
size: ::size_t,
5882+
flags: os_sync_wake_by_address_flags_t,
5883+
) -> ::c_int;
5884+
58375885
pub fn os_unfair_lock_lock(lock: os_unfair_lock_t);
58385886
pub fn os_unfair_lock_trylock(lock: os_unfair_lock_t) -> bool;
58395887
pub fn os_unfair_lock_unlock(lock: os_unfair_lock_t);

0 commit comments

Comments
 (0)