diff --git a/libc-test/semver/freebsd-x86_64.txt b/libc-test/semver/freebsd-x86_64.txt index be73d1f7290fe..14ddc25a1b254 100644 --- a/libc-test/semver/freebsd-x86_64.txt +++ b/libc-test/semver/freebsd-x86_64.txt @@ -13,8 +13,6 @@ _MC_HASSEGS fpreg fpreg32 max_align_t -mcontext_t reg reg32 -ucontext_t xmmreg diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index d4b53860b5a53..eb598483a3bf4 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2020,6 +2020,7 @@ mallctl mallctlbymib mallctlnametomib mallocx +mcontext_t memmem memrchr memset_s @@ -2350,13 +2351,14 @@ timer_t timex truncate ttyname_r -uuidgen +ucontext_t unmount useconds_t uselocale utimensat utmpx utrace +uuidgen vm_size_t vmtotal wait4 diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 8ff500c65981c..965abd33f0a48 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -5,6 +5,49 @@ pub type wchar_t = u32; pub type time_t = i64; pub type suseconds_t = i32; pub type register_t = i32; +pub type __greg_t = ::c_uint; +pub type __gregset_t = [::__greg_t; 17]; + +s_no_extra_traits! { + pub struct mcontext_t { + pub __gregs: ::__gregset_t, + pub mc_vfp_size: ::__size_t, + pub mc_vfp_ptr: *mut ::c_void, + pub mc_spare: [::c_uint; 33], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.__gregs == other.__gregs && + self.mc_vfp_size == other.mc_vfp_size && + self.mc_vfp_ptr == other.mc_vfp_ptr && + self.mc_spare.iter().zip(other.mc_spare.iter()).all(|(a, b)| a == b) + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("__gregs", &self.__gregs) + .field("mc_vfp_size", &self.mc_vfp_size) + .field("mc_vfp_ptr", &self.mc_vfp_ptr) + .field("mc_spare", &self.mc_spare) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.__gregs.hash(state); + self.mc_vfp_size.hash(state); + self.mc_vfp_ptr.hash(state); + self.mc_spare.hash(state); + } + } + } +} // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { @@ -16,5 +59,6 @@ cfg_if! { pub const _ALIGNBYTES: usize = 4 - 1; } } + pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index a15987df10775..dda108e8c0ef2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1654,6 +1654,15 @@ s_no_extra_traits! { _kf_cap_spare: u64, pub kf_path: [::c_char; ::PATH_MAX as usize], } + + pub struct ucontext_t { + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: ::mcontext_t, + pub uc_link: *mut ::ucontext_t, + pub uc_stack: ::stack_t, + pub uc_flags: ::c_int, + __spare__: [::c_int; 4], + } } cfg_if! { @@ -2656,6 +2665,18 @@ cfg_if! { self.kf_path.hash(state); } } + + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_sigmask", &self.uc_sigmask) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_flags", &self.uc_flags) + .finish() + } + } } } diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index f84062ba34b93..d856e80226746 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -6,6 +6,72 @@ pub type time_t = i64; pub type suseconds_t = i32; pub type register_t = i32; +cfg_if! { + if #[cfg(libc_align)] { + s_no_extra_traits! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_vers: ::c_int, + pub mc_flags: ::c_int, + pub mc_onstack: ::c_int, + pub mc_len: ::c_int, + pub mc_avec: [u64; 64], + pub mc_av: [u32; 2], + pub mc_frame: [::register_t; 42], + pub mc_fpreg: [u64; 33], + pub mc_vsxfpreg: [u64; 32], + } + } + } +} + +cfg_if! { + if #[cfg(all(libc_align, feature = "extra_traits"))] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.mc_vers == other.mc_vers && + self.mc_flags == other.mc_flags && + self.mc_onstack == other.mc_onstack && + self.mc_len == other.mc_len && + self.mc_avec == other.mc_avec && + self.mc_av == other.mc_av && + self.mc_frame == other.mc_frame && + self.mc_fpreg == other.mc_fpreg && + self.mc_vsxfpreg == other.mc_vsxfpreg + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("mc_vers", &self.mc_vers) + .field("mc_flags", &self.mc_flags) + .field("mc_onstack", &self.mc_onstack) + .field("mc_len", &self.mc_len) + .field("mc_avec", &self.mc_avec) + .field("mc_av", &self.mc_av) + .field("mc_frame", &self.mc_frame) + .field("mc_fpreg", &self.mc_fpreg) + .field("mc_vsxfpreg", &self.mc_vsxfpreg) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.mc_vers.hash(state); + self.mc_flags.hash(state); + self.mc_onstack.hash(state); + self.mc_len.hash(state); + self.mc_avec.hash(state); + self.mc_av.hash(state); + self.mc_frame.hash(state); + self.mc_fpreg.hash(state); + self.mc_vsxfpreg.hash(state); + } + } + } +} + // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { if #[cfg(libc_const_size_of)] { diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index 69cf4c5fc88c7..ec1c17e32db3f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -6,6 +6,72 @@ pub type time_t = i64; pub type suseconds_t = i64; pub type register_t = i64; +cfg_if! { + if #[cfg(libc_align)] { + s_no_extra_traits! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_vers: ::c_int, + pub mc_flags: ::c_int, + pub mc_onstack: ::c_int, + pub mc_len: ::c_int, + pub mc_avec: [u64; 64], + pub mc_av: [u32; 2], + pub mc_frame: [::register_t; 42], + pub mc_fpreg: [u64; 33], + pub mc_vsxfpreg: [u64; 32], + } + } + } +} + +cfg_if! { + if #[cfg(all(libc_align, feature = "extra_traits"))] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.mc_vers == other.mc_vers && + self.mc_flags == other.mc_flags && + self.mc_onstack == other.mc_onstack && + self.mc_len == other.mc_len && + self.mc_avec == other.mc_avec && + self.mc_av == other.mc_av && + self.mc_frame == other.mc_frame && + self.mc_fpreg == other.mc_fpreg && + self.mc_vsxfpreg == other.mc_vsxfpreg + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("mc_vers", &self.mc_vers) + .field("mc_flags", &self.mc_flags) + .field("mc_onstack", &self.mc_onstack) + .field("mc_len", &self.mc_len) + .field("mc_avec", &self.mc_avec) + .field("mc_av", &self.mc_av) + .field("mc_frame", &self.mc_frame) + .field("mc_fpreg", &self.mc_fpreg) + .field("mc_vsxfpreg", &self.mc_vsxfpreg) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.mc_vers.hash(state); + self.mc_flags.hash(state); + self.mc_onstack.hash(state); + self.mc_len.hash(state); + self.mc_avec.hash(state); + self.mc_av.hash(state); + self.mc_frame.hash(state); + self.mc_fpreg.hash(state); + self.mc_vsxfpreg.hash(state); + } + } + } +} + // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { if #[cfg(libc_const_size_of)] { diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 31a660e7d0a22..43545044e6793 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -41,17 +41,6 @@ s_no_extra_traits! { } } -s! { - pub struct ucontext_t { - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: ::mcontext_t, - pub uc_link: *mut ::ucontext_t, - pub uc_stack: ::stack_t, - pub uc_flags: ::c_int, - __spare__: [::c_int; 4], - } -} - // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { if #[cfg(libc_const_size_of)] { diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs index 3a016a0519852..208e7f2c90c0a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs @@ -184,14 +184,3 @@ cfg_if! { } } } - -s! { - pub struct ucontext_t { - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: ::mcontext_t, - pub uc_link: *mut ::ucontext_t, - pub uc_stack: ::stack_t, - pub uc_flags: ::c_int, - __spare__: [::c_int; 4], - } -}