From 26bd16ff4d4b60111c0a4988fe66c324c0077bec Mon Sep 17 00:00:00 2001 From: joboet Date: Tue, 9 Jul 2024 11:39:52 +0200 Subject: [PATCH] add `os_sync_wait_on_address` and related definitions (apply to `main`) [ resolve conflicts - Trevor ] (cherry picked from commit 5bd8143a9e2d9eff3ed2026826b317fc718896d9) --- libc-test/build.rs | 2 ++ libc-test/semver/apple.txt | 13 +++++++++++ src/unix/bsd/apple/mod.rs | 48 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 9560e07c8cf7e..a6d9c4b017625 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -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", diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index bb80ce86b48cf..ad14820e9ffac 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -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 @@ -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 @@ -1951,6 +1956,7 @@ open_memstream open_wmemstream openat openpty +os_clockid_t os_log_create os_log_t os_log_type_enabled @@ -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 diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 84e725a91cb9d..f0dfe59841867 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -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 ::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; @@ -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; + // /// Process being created by fork. pub const SIDL: u32 = 1; @@ -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);