From 42c2630b8f7ce47d668f7bc8cf83135e5524bd8e Mon Sep 17 00:00:00 2001 From: highjeans Date: Sun, 16 Mar 2025 16:36:57 +0000 Subject: [PATCH 1/5] Add correct darwin definition of pthread_t --- src/unix/bsd/apple/b32/mod.rs | 1 + src/unix/bsd/apple/b64/mod.rs | 1 + src/unix/bsd/mod.rs | 31 ++++++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index 3753ffb085907..e1032b842f213 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -125,6 +125,7 @@ cfg_if! { #[deprecated(since = "0.2.55")] pub const NET_RT_MAXID: c_int = 10; +pub const __PTHREAD_SIZE__: usize = 4088; pub const __PTHREAD_MUTEX_SIZE__: usize = 40; pub const __PTHREAD_COND_SIZE__: usize = 24; pub const __PTHREAD_CONDATTR_SIZE__: usize = 4; diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index 2bd682313428e..1c4989a1f7079 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -118,6 +118,7 @@ cfg_if! { #[deprecated(since = "0.2.55")] pub const NET_RT_MAXID: c_int = 11; +pub const __PTHREAD_SIZE__: usize = 8176; pub const __PTHREAD_MUTEX_SIZE__: usize = 56; pub const __PTHREAD_COND_SIZE__: usize = 40; pub const __PTHREAD_CONDATTR_SIZE__: usize = 8; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 867898cec72cb..a9f084510f43f 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -5,7 +5,36 @@ pub type useconds_t = u32; pub type blkcnt_t = i64; pub type socklen_t = u32; pub type sa_family_t = u8; -pub type pthread_t = crate::uintptr_t; +// pub type pthread_t = crate::uintptr_t; + +cfg_if! { + if #[cfg(any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + ))] { + s! { + pub struct __darwin_pthread_handler_rec { + __routine: Option, + __arg: *mut c_void, + __next: *mut __darwin_pthread_handler_rec, + } + pub struct _opaque_pthread_t { + __sig: c_long, + __cleanup_stack: *mut __darwin_pthread_handler_rec, + __opaque: [c_char; __PTHREAD_SIZE__], + } + } + pub type __darwin_pthread_t = *mut _opaque_pthread_t; + pub type pthread_t = __darwin_pthread_t; + } + else { + pub type pthread_t = crate::uintptr_t; + } +} + pub type nfds_t = c_uint; pub type regoff_t = off_t; From 270dacdda53f8bff019bb3d49164f3158fb3f39b Mon Sep 17 00:00:00 2001 From: highjeans Date: Mon, 17 Mar 2025 15:19:37 +0000 Subject: [PATCH 2/5] Explicitly set "opaque_pthread_t" to be a struct rather than a type --- libc-test/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 76dea8e77c1a7..4049b5a5f95e9 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -449,6 +449,7 @@ fn test_apple(target: &str) { // OSX calls this something else "sighandler_t" => "sig_t".to_string(), + "_opaque_pthread_t" => format!("struct {}", ty), t if is_union => format!("union {}", t), t if t.ends_with("_t") => t.to_string(), t if is_struct => format!("struct {}", t), From 594ad79e81571e3dbebee1abdb2334357de945d0 Mon Sep 17 00:00:00 2001 From: highjeans Date: Mon, 17 Mar 2025 15:19:52 +0000 Subject: [PATCH 3/5] Update symbols list --- libc-test/semver/apple.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 800d4a7996d0d..54619057b8edb 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1773,13 +1773,17 @@ _UTX_LINESIZE _UTX_USERSIZE _WSTATUS _WSTOPPED +_opaque_pthread_t __PTHREAD_CONDATTR_SIZE__ __PTHREAD_COND_SIZE__ __PTHREAD_MUTEX_SIZE__ __PTHREAD_ONCE_SIZE__ __PTHREAD_RWLOCKATTR_SIZE__ __PTHREAD_RWLOCK_SIZE__ +__PTHREAD_SIZE__ __darwin_mcontext64 +__darwin_pthread_handler_rec +__darwin_pthread_t __error abs acct From e82ba246bb72eb7153b71324e0716033327edb2b Mon Sep 17 00:00:00 2001 From: highjeans Date: Mon, 17 Mar 2025 15:30:00 +0000 Subject: [PATCH 4/5] Fix stylings --- libc-test/build.rs | 3 +-- libc-test/semver/apple.txt | 2 +- src/unix/bsd/mod.rs | 19 +++++++++---------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4049b5a5f95e9..28e87669635be 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4065,8 +4065,7 @@ fn test_linux(target: &str) { "epoll_params" => true, // FIXME(linux): Requires >= 6.12 kernel headers. - "dmabuf_cmsg" | - "dmabuf_token" => true, + "dmabuf_cmsg" | "dmabuf_token" => true, _ => false, } diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 54619057b8edb..977cc021f29b8 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1773,7 +1773,6 @@ _UTX_LINESIZE _UTX_USERSIZE _WSTATUS _WSTOPPED -_opaque_pthread_t __PTHREAD_CONDATTR_SIZE__ __PTHREAD_COND_SIZE__ __PTHREAD_MUTEX_SIZE__ @@ -1785,6 +1784,7 @@ __darwin_mcontext64 __darwin_pthread_handler_rec __darwin_pthread_t __error +_opaque_pthread_t abs acct aio_cancel diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index a9f084510f43f..11e9b20a54ffd 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -9,12 +9,14 @@ pub type sa_family_t = u8; cfg_if! { if #[cfg(any( - target_os = "macos", - target_os = "ios", - target_os = "tvos", - target_os = "watchos", - target_os = "visionos", - ))] { + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos", + target_os = "visionos", + ))] { + pub type __darwin_pthread_t = *mut _opaque_pthread_t; + pub type pthread_t = __darwin_pthread_t; s! { pub struct __darwin_pthread_handler_rec { __routine: Option, @@ -27,10 +29,7 @@ cfg_if! { __opaque: [c_char; __PTHREAD_SIZE__], } } - pub type __darwin_pthread_t = *mut _opaque_pthread_t; - pub type pthread_t = __darwin_pthread_t; - } - else { + } else { pub type pthread_t = crate::uintptr_t; } } From bf4833b9e6bd14b57c9759d6a8d0750c275140f9 Mon Sep 17 00:00:00 2001 From: highjeans Date: Tue, 18 Mar 2025 07:49:58 +0000 Subject: [PATCH 5/5] Remove commented line --- src/unix/bsd/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 11e9b20a54ffd..f55884a233f3c 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -5,7 +5,6 @@ pub type useconds_t = u32; pub type blkcnt_t = i64; pub type socklen_t = u32; pub type sa_family_t = u8; -// pub type pthread_t = crate::uintptr_t; cfg_if! { if #[cfg(any(