diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 89b5cca443395..b528a1c64350c 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1116,16 +1116,29 @@ PROC_CSM_TECS PROC_PIDTASKALLINFO PROC_PIDTASKINFO PROC_PIDTHREADINFO +PTHREAD_CANCEL_ASYNCHRONOUS +PTHREAD_CANCEL_DEFERRED +PTHREAD_CANCEL_DISABLE +PTHREAD_CANCEL_ENABLE +PTHREAD_CANCELED PTHREAD_CREATE_DETACHED PTHREAD_CREATE_JOINABLE +PTHREAD_EXPLICIT_SCHED +PTHREAD_INHERIT_SCHED PTHREAD_INTROSPECTION_THREAD_CREATE PTHREAD_INTROSPECTION_THREAD_DESTROY PTHREAD_INTROSPECTION_THREAD_START PTHREAD_INTROSPECTION_THREAD_TERMINATE PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_ERRORCHECK +PTHREAD_ONCE_INIT +PTHREAD_PRIO_INHERIT +PTHREAD_PRIO_NONE +PTHREAD_PRIO_PROTECT PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_SHARED +PTHREAD_SCOPE_PROCESS +PTHREAD_SCOPE_SYSTEM PTHREAD_STACK_MIN PT_ATTACH PT_ATTACHEXC @@ -1832,6 +1845,7 @@ _WSTOPPED __PTHREAD_CONDATTR_SIZE__ __PTHREAD_COND_SIZE__ __PTHREAD_MUTEX_SIZE__ +__PTHREAD_ONCE_SIZE__ __PTHREAD_RWLOCKATTR_SIZE__ __PTHREAD_RWLOCK_SIZE__ __darwin_mcontext64 @@ -2142,8 +2156,18 @@ pseudo_AF_KEY pseudo_AF_PIP pseudo_AF_RTIP pseudo_AF_XTP +pthread_atfork +pthread_attr_getdetachstate +pthread_attr_getinheritsched pthread_attr_getschedparam +pthread_attr_getschedpolicy +pthread_attr_getscope +pthread_attr_getstackaddr +pthread_attr_setinheritsched pthread_attr_setschedparam +pthread_attr_setschedpolicy +pthread_attr_setscope +pthread_attr_setstackaddr pthread_cancel pthread_condattr_getpshared pthread_condattr_setpshared @@ -2167,6 +2191,8 @@ pthread_kill pthread_main_np pthread_mutexattr_getpshared pthread_mutexattr_setpshared +pthread_once +pthread_once_t pthread_rwlockattr_getpshared pthread_rwlockattr_setpshared pthread_setname_np diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index 0f1722f975744..4e45459c18101 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -54,6 +54,11 @@ s_no_extra_traits! { __sig: c_long, __opaque: [::c_char; 36] } + + pub struct pthread_once_t { + __sig: c_long, + __opaque: [::c_char; ::__PTHREAD_ONCE_SIZE__], + } } cfg_if! { @@ -82,6 +87,29 @@ cfg_if! { self.__opaque.hash(state); } } + impl PartialEq for pthread_once_t { + fn eq(&self, other: &pthread_once_t) -> bool { + self.__sig == other.__sig + && self.__opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_once_t {} + impl ::fmt::Debug for pthread_once_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_once_t") + .field("__sig", &self.__sig) + .finish() + } + } + impl ::hash::Hash for pthread_once_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } } } @@ -92,6 +120,7 @@ pub const NET_RT_MAXID: ::c_int = 10; pub const __PTHREAD_MUTEX_SIZE__: usize = 40; pub const __PTHREAD_COND_SIZE__: usize = 24; pub const __PTHREAD_CONDATTR_SIZE__: usize = 4; +pub const __PTHREAD_ONCE_SIZE__: usize = 4; pub const __PTHREAD_RWLOCK_SIZE__: usize = 124; pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12; @@ -103,6 +132,12 @@ pub const BIOCSRTIMEOUT: ::c_ulong = 0x8008426d; pub const BIOCGRTIMEOUT: ::c_ulong = 0x4008426e; pub const BIOCSETFNR: ::c_ulong = 0x8008427e; +const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA; +pub const PTHREAD_ONCE_INIT: ::pthread_once_t = ::pthread_once_t { + __sig: _PTHREAD_ONCE_SIG_INIT, + __opaque: [0; 4], +}; + extern "C" { pub fn exchangedata( path1: *const ::c_char, diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index 48d94bcd6bfdc..2206210da5575 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -54,6 +54,11 @@ s_no_extra_traits! { __sig: c_long, __opaque: [::c_char; 56] } + + pub struct pthread_once_t { + __sig: c_long, + __opaque: [::c_char; __PTHREAD_ONCE_SIZE__], + } } cfg_if! { @@ -82,6 +87,29 @@ cfg_if! { self.__opaque.hash(state); } } + impl PartialEq for pthread_once_t { + fn eq(&self, other: &pthread_once_t) -> bool { + self.__sig == other.__sig + && self.__opaque + .iter() + .zip(other.__opaque.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for pthread_once_t {} + impl ::fmt::Debug for pthread_once_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("pthread_once_t") + .field("__sig", &self.__sig) + .finish() + } + } + impl ::hash::Hash for pthread_once_t { + fn hash(&self, state: &mut H) { + self.__sig.hash(state); + self.__opaque.hash(state); + } + } } } @@ -92,6 +120,7 @@ pub const NET_RT_MAXID: ::c_int = 11; pub const __PTHREAD_MUTEX_SIZE__: usize = 56; pub const __PTHREAD_COND_SIZE__: usize = 40; pub const __PTHREAD_CONDATTR_SIZE__: usize = 8; +pub const __PTHREAD_ONCE_SIZE__: usize = 8; pub const __PTHREAD_RWLOCK_SIZE__: usize = 192; pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16; @@ -103,6 +132,12 @@ pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; pub const BIOCSETFNR: ::c_ulong = 0x8010427e; +const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA; +pub const PTHREAD_ONCE_INIT: ::pthread_once_t = ::pthread_once_t { + __sig: _PTHREAD_ONCE_SIG_INIT, + __opaque: [0; 8], +}; + extern "C" { pub fn exchangedata( path1: *const ::c_char, diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 92d724071a3d4..3e150feee6afa 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -3787,6 +3787,19 @@ pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 2; pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; pub const PTHREAD_CREATE_JOINABLE: ::c_int = 1; pub const PTHREAD_CREATE_DETACHED: ::c_int = 2; +pub const PTHREAD_INHERIT_SCHED: ::c_int = 1; +pub const PTHREAD_EXPLICIT_SCHED: ::c_int = 2; +pub const PTHREAD_CANCEL_ENABLE: ::c_int = 0x01; +pub const PTHREAD_CANCEL_DISABLE: ::c_int = 0x00; +pub const PTHREAD_CANCEL_DEFERRED: ::c_int = 0x02; +pub const PTHREAD_CANCEL_ASYNCHRONOUS: ::c_int = 0x00; +pub const PTHREAD_CANCELED: *mut ::c_void = 1 as *mut ::c_void; +pub const PTHREAD_SCOPE_SYSTEM: ::c_int = 1; +pub const PTHREAD_SCOPE_PROCESS: ::c_int = 2; +pub const PTHREAD_PRIO_NONE: ::c_int = 0; +pub const PTHREAD_PRIO_INHERIT: ::c_int = 1; +pub const PTHREAD_PRIO_PROTECT: ::c_int = 2; + #[cfg(target_arch = "aarch64")] pub const PTHREAD_STACK_MIN: ::size_t = 16384; #[cfg(not(target_arch = "aarch64"))] @@ -5757,6 +5770,40 @@ extern "C" { pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; pub fn mach_host_self() -> mach_port_t; pub fn mach_thread_self() -> mach_port_t; + pub fn pthread_once( + once_control: *mut ::pthread_once_t, + init_routine: ::Option, + ) -> ::c_int; + pub fn pthread_attr_getinheritsched( + attr: *const ::pthread_attr_t, + inheritsched: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_attr_getschedpolicy( + attr: *const ::pthread_attr_t, + policy: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_attr_getscope( + attr: *const ::pthread_attr_t, + contentionscope: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_attr_getstackaddr( + attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + ) -> ::c_int; + pub fn pthread_attr_getdetachstate( + attr: *const ::pthread_attr_t, + detachstate: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_attr_setinheritsched( + attr: *mut ::pthread_attr_t, + inheritsched: ::c_int, + ) -> ::c_int; + pub fn pthread_attr_setschedpolicy(attr: *mut ::pthread_attr_t, policy: ::c_int) -> ::c_int; + pub fn pthread_attr_setscope(attr: *mut ::pthread_attr_t, contentionscope: ::c_int) -> ::c_int; + pub fn pthread_attr_setstackaddr( + attr: *mut ::pthread_attr_t, + stackaddr: *mut ::c_void, + ) -> ::c_int; pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; pub fn pthread_getname_np(thread: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn pthread_mach_thread_np(thread: ::pthread_t) -> ::mach_port_t;