From 3ce0190a52d046a712f88b9e920100040bdef4d1 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Sun, 2 Nov 2025 03:17:12 -0600 Subject: [PATCH] cleanup: Use derived traits as much as possible Historically Rust hasn't supported derives on packed structs well, and until recently our automatic derives via `s!` still did not support these (fixed by 79d1bdbb07b0 ("Flip `Copy` and `PartialEq, Hash` derives")). This meant that any packed struct implementing `extra_traits` had handwritten implementations that are no longer needed. There are also a handful of cases that use a handwritten implementation in order to selectively exclude padding fields. Others don't seem to be handwritten for any specific reason. Clean up all of the above by switching from `s_no_extra_traits!` to `s!` and deleting the handwritten implementations wherever possible. The only remaining handwritten implementations are those that compare unions with `unsafe` (which will have to be addressed) or floats. Note that in some cases, this means we are no longer excluding padding fields from comparisons. These traits are only usable via references, not raw pointers; thus, the user has asserted that they are initialized, and there is no UB in `libc` by reading them. Practically the only way to know they are initialized is by starting with a zeroed struct, so in most cases they will have no effect on the results. Whether or not padding fields are included in handwritten traits is also completely inconsistent (most include them), so there isn't much predictability lost here. The new `Padding` type will also improve the situation here in the future. --- src/fuchsia/mod.rs | 265 +---- src/fuchsia/x86_64.rs | 32 - src/unix/aix/mod.rs | 38 +- src/unix/aix/powerpc64.rs | 67 +- src/unix/bsd/apple/b32/mod.rs | 43 +- src/unix/bsd/apple/b64/mod.rs | 41 - src/unix/bsd/apple/mod.rs | 920 +----------------- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 251 ----- src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 70 +- src/unix/bsd/freebsdlike/freebsd/arm.rs | 28 +- .../bsd/freebsdlike/freebsd/freebsd11/mod.rs | 119 --- .../bsd/freebsdlike/freebsd/freebsd12/mod.rs | 121 --- .../bsd/freebsdlike/freebsd/freebsd13/mod.rs | 121 --- .../bsd/freebsdlike/freebsd/freebsd14/mod.rs | 121 --- .../bsd/freebsdlike/freebsd/freebsd15/mod.rs | 121 --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 652 ++----------- src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 34 +- src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 34 +- src/unix/bsd/freebsdlike/freebsd/riscv64.rs | 74 +- src/unix/bsd/freebsdlike/freebsd/x86.rs | 84 +- .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 193 +--- src/unix/bsd/freebsdlike/mod.rs | 30 - src/unix/bsd/mod.rs | 70 -- src/unix/bsd/netbsdlike/netbsd/mod.rs | 289 +----- src/unix/bsd/netbsdlike/openbsd/mod.rs | 353 ++----- src/unix/bsd/netbsdlike/openbsd/x86_64.rs | 44 - src/unix/cygwin/mod.rs | 172 +--- src/unix/haiku/mod.rs | 128 --- src/unix/haiku/native.rs | 28 +- src/unix/haiku/x86_64.rs | 152 +-- src/unix/hurd/mod.rs | 44 - src/unix/linux_like/android/b32/arm.rs | 52 +- src/unix/linux_like/android/b32/x86/mod.rs | 50 +- src/unix/linux_like/android/b64/mod.rs | 74 -- src/unix/linux_like/android/b64/x86_64/mod.rs | 164 +--- src/unix/linux_like/android/mod.rs | 261 +---- src/unix/linux_like/emscripten/mod.rs | 104 +- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 32 +- src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 70 +- .../linux_like/linux/gnu/b64/x86_64/mod.rs | 69 +- src/unix/linux_like/linux/gnu/mod.rs | 126 +-- src/unix/linux_like/linux/mod.rs | 463 ++------- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 29 +- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 74 +- .../linux_like/linux/musl/b64/x86_64/mod.rs | 73 +- src/unix/linux_like/linux/musl/mod.rs | 124 +-- src/unix/linux_like/mod.rs | 131 +-- src/unix/newlib/mod.rs | 2 + src/unix/nto/mod.rs | 264 +---- src/unix/redox/mod.rs | 123 +-- src/unix/solarish/illumos.rs | 59 -- src/unix/solarish/mod.rs | 168 +--- src/unix/solarish/solaris.rs | 70 +- src/unix/solarish/x86_64.rs | 40 +- 54 files changed, 592 insertions(+), 6769 deletions(-) diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 557b6465d53a8..ded19f85eea3e 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -875,9 +875,7 @@ s! { pub struct pthread_condattr_t { size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], } -} -s_no_extra_traits! { pub struct sysinfo { pub uptime: c_ulong, pub loads: [c_ulong; 3], @@ -964,6 +962,8 @@ s_no_extra_traits! { pub nl_groups: u32, } + // FIXME(msrv): suggested method was added in 1.85 + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigevent { pub sigev_value: crate::sigval, pub sigev_signo: c_int, @@ -1016,7 +1016,9 @@ s_no_extra_traits! { pub struct pthread_cond_t { size: [u8; crate::__SIZEOF_PTHREAD_COND_T], } +} +s_no_extra_traits! { pub union sigval { pub sival_int: c_int, pub sival_ptr: *mut c_void, @@ -1037,265 +1039,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for sysinfo { - fn eq(&self, other: &sysinfo) -> bool { - self.uptime == other.uptime - && self.loads == other.loads - && self.totalram == other.totalram - && self.freeram == other.freeram - && self.sharedram == other.sharedram - && self.bufferram == other.bufferram - && self.totalswap == other.totalswap - && self.freeswap == other.freeswap - && self.procs == other.procs - && self.pad == other.pad - && self.totalhigh == other.totalhigh - && self.freehigh == other.freehigh - && self.mem_unit == other.mem_unit - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sysinfo {} - impl hash::Hash for sysinfo { - fn hash(&self, state: &mut H) { - self.uptime.hash(state); - self.loads.hash(state); - self.totalram.hash(state); - self.freeram.hash(state); - self.sharedram.hash(state); - self.bufferram.hash(state); - self.totalswap.hash(state); - self.freeswap.hash(state); - self.procs.hash(state); - self.pad.hash(state); - self.totalhigh.hash(state); - self.freehigh.hash(state); - self.mem_unit.hash(state); - self.__reserved.hash(state); - } - } - - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_un {} - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_family == other.ss_family - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_family.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for utsname {} - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for dirent64 { - fn eq(&self, other: &dirent64) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent64 {} - impl hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for mq_attr { - fn eq(&self, other: &mq_attr) -> bool { - self.mq_flags == other.mq_flags - && self.mq_maxmsg == other.mq_maxmsg - && self.mq_msgsize == other.mq_msgsize - && self.mq_curmsgs == other.mq_curmsgs - } - } - impl Eq for mq_attr {} - impl hash::Hash for mq_attr { - fn hash(&self, state: &mut H) { - self.mq_flags.hash(state); - self.mq_maxmsg.hash(state); - self.mq_msgsize.hash(state); - self.mq_curmsgs.hash(state); - } - } - - impl PartialEq for sockaddr_nl { - fn eq(&self, other: &sockaddr_nl) -> bool { - self.nl_family == other.nl_family - && self.nl_pid == other.nl_pid - && self.nl_groups == other.nl_groups - } - } - impl Eq for sockaddr_nl {} - impl hash::Hash for sockaddr_nl { - fn hash(&self, state: &mut H) { - self.nl_family.hash(state); - self.nl_pid.hash(state); - self.nl_groups.hash(state); - } - } - - // FIXME(msrv): suggested method was added in 1.85 - #[allow(unpredictable_function_pointer_comparisons)] - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_value == other.sigev_value - && self.sigev_signo == other.sigev_signo - && self.sigev_notify == other.sigev_notify - && self.sigev_notify_function == other.sigev_notify_function - && self.sigev_notify_attributes == other.sigev_notify_attributes - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_value.hash(state); - self.sigev_signo.hash(state); - self.sigev_notify.hash(state); - self.sigev_notify_function.hash(state); - self.sigev_notify_attributes.hash(state); - } - } - - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - impl Eq for pthread_cond_t {} - impl hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - impl Eq for pthread_mutex_t {} - impl hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - impl Eq for pthread_rwlock_t {} - impl hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - impl PartialEq for sigval { fn eq(&self, _other: &sigval) -> bool { unimplemented!("traits") diff --git a/src/fuchsia/x86_64.rs b/src/fuchsia/x86_64.rs index add60a4564020..2ce21e20fefc4 100644 --- a/src/fuchsia/x86_64.rs +++ b/src/fuchsia/x86_64.rs @@ -64,9 +64,7 @@ s! { __unused1: c_long, __unused2: c_long, } -} -s_no_extra_traits! { pub struct ucontext_t { pub uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -77,36 +75,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - && self - .__private - .iter() - .zip(other.__private.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - self.__private.hash(state); - } - } - } -} - // offsets in user_regs_structs, from sys/reg.h pub const R15: c_int = 0; pub const R14: c_int = 1; diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index 6b939a477847a..db804555c87a7 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -545,14 +545,6 @@ s! { pub sa_mask: sigset_t, pub sa_flags: c_int, } -} - -s_no_extra_traits! { - pub union __poll_ctl_ext_u { - pub addr: *mut c_void, - pub data32: u32, - pub data: u64, - } pub struct poll_ctl_ext { pub version: u8, @@ -564,6 +556,14 @@ s_no_extra_traits! { } } +s_no_extra_traits! { + pub union __poll_ctl_ext_u { + pub addr: *mut c_void, + pub data32: u32, + pub data: u64, + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for __poll_ctl_ext_u { @@ -585,28 +585,6 @@ cfg_if! { } } } - - impl PartialEq for poll_ctl_ext { - fn eq(&self, other: &poll_ctl_ext) -> bool { - self.version == other.version - && self.command == other.command - && self.events == other.events - && self.fd == other.fd - && self.reserved64 == other.reserved64 - && self.u == other.u - } - } - impl Eq for poll_ctl_ext {} - impl hash::Hash for poll_ctl_ext { - fn hash(&self, state: &mut H) { - self.version.hash(state); - self.command.hash(state); - self.events.hash(state); - self.fd.hash(state); - self.u.hash(state); - self.reserved64.hash(state); - } - } } } diff --git a/src/unix/aix/powerpc64.rs b/src/unix/aix/powerpc64.rs index f3a4419efb38f..a936ddb7e2f99 100644 --- a/src/unix/aix/powerpc64.rs +++ b/src/unix/aix/powerpc64.rs @@ -244,9 +244,7 @@ s! { pub msg_wwait: c_int, pub msg_reqevents: c_ushort, } -} -s_no_extra_traits! { pub struct siginfo_t { pub si_signo: c_int, pub si_errno: c_int, @@ -261,6 +259,15 @@ s_no_extra_traits! { pub __pad: [c_int; 3], } + pub struct pollfd_ext { + pub fd: c_int, + pub events: c_short, + pub revents: c_short, + pub data: __pollfd_ext_u, + } +} + +s_no_extra_traits! { pub union _kernel_simple_lock { pub _slock: c_long, pub _slockp: *mut lock_data_instrumented, @@ -335,13 +342,6 @@ s_no_extra_traits! { pub data: u64, } - pub struct pollfd_ext { - pub fd: c_int, - pub events: c_short, - pub revents: c_short, - pub data: __pollfd_ext_u, - } - pub struct fpreg_t { pub d: c_double, } @@ -371,36 +371,6 @@ impl siginfo_t { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for siginfo_t { - fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo - && self.si_errno == other.si_errno - && self.si_code == other.si_code - && self.si_pid == other.si_pid - && self.si_uid == other.si_uid - && self.si_status == other.si_status - && self.si_addr == other.si_addr - && self.si_band == other.si_band - && self.__si_flags == other.__si_flags - && self.si_value == other.si_value - } - } - impl Eq for siginfo_t {} - impl hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { - self.si_signo.hash(state); - self.si_errno.hash(state); - self.si_code.hash(state); - self.si_pid.hash(state); - self.si_uid.hash(state); - self.si_status.hash(state); - self.si_addr.hash(state); - self.si_band.hash(state); - self.si_value.hash(state); - self.__si_flags.hash(state); - } - } - impl PartialEq for __pollfd_ext_u { fn eq(&self, other: &__pollfd_ext_u) -> bool { unsafe { @@ -421,31 +391,12 @@ cfg_if! { } } - impl PartialEq for pollfd_ext { - fn eq(&self, other: &pollfd_ext) -> bool { - self.fd == other.fd - && self.events == other.events - && self.revents == other.revents - && self.data == other.data - } - } - impl Eq for pollfd_ext {} - impl hash::Hash for pollfd_ext { - fn hash(&self, state: &mut H) { - self.fd.hash(state); - self.events.hash(state); - self.revents.hash(state); - self.data.hash(state); - } - } impl PartialEq for fpreg_t { fn eq(&self, other: &fpreg_t) -> bool { self.d == other.d } } - impl Eq for fpreg_t {} - impl hash::Hash for fpreg_t { fn hash(&self, state: &mut H) { let d: u64 = self.d.to_bits(); diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index bd6762558f508..f4234a110d827 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -47,9 +47,7 @@ s! { pub struct malloc_zone_t { __private: [crate::uintptr_t; 18], // FIXME(macos): keeping private for now } -} -s_no_extra_traits! { pub struct pthread_attr_t { __sig: c_long, __opaque: [c_char; 36], @@ -59,52 +57,15 @@ s_no_extra_traits! { __sig: c_long, __opaque: [c_char; crate::__PTHREAD_ONCE_SIZE__], } +} +s_no_extra_traits! { #[repr(align(16))] pub struct max_align_t { priv_: [f64; 2], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for pthread_attr_t { - fn eq(&self, other: &pthread_attr_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for pthread_attr_t {} - impl hash::Hash for pthread_attr_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - 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 hash::Hash for pthread_once_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - } -} - #[doc(hidden)] #[deprecated(since = "0.2.55")] pub const NET_RT_MAXID: c_int = 10; diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index 34743464a44e7..2fe60d177fefa 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -46,9 +46,7 @@ s! { pub bh_datalen: u32, pub bh_hdrlen: c_ushort, } -} -s_no_extra_traits! { pub struct pthread_attr_t { __sig: c_long, __opaque: [c_char; 56], @@ -60,45 +58,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for pthread_attr_t { - fn eq(&self, other: &pthread_attr_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for pthread_attr_t {} - impl hash::Hash for pthread_attr_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - 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 hash::Hash for pthread_once_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - } -} - #[doc(hidden)] #[deprecated(since = "0.2.55")] pub const NET_RT_MAXID: c_int = 11; diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 844e462d87e4c..e496cba6ef7c8 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -1250,14 +1250,6 @@ s! { pub proc_fd: i32, pub proc_fdtype: u32, } -} - -s_no_extra_traits! { - #[repr(packed(4))] - pub struct ifconf { - pub ifc_len: c_int, - pub ifc_ifcu: __c_anonymous_ifc_ifcu, - } #[repr(packed(4))] pub struct kevent { @@ -1380,7 +1372,6 @@ s_no_extra_traits! { __unused1: *mut c_void, //actually a function pointer pub sigev_notify_attributes: *mut crate::pthread_attr_t, } - pub struct processor_cpu_load_info { pub cpu_ticks: [c_uint; CPU_STATE_MAX as usize], } @@ -1553,11 +1544,6 @@ s_no_extra_traits! { pub ifdm_max: c_int, } - pub union __c_anonymous_ifk_data { - pub ifk_ptr: *mut c_void, - pub ifk_value: c_int, - } - #[repr(packed(4))] pub struct ifkpi { pub ifk_module_id: c_uint, @@ -1565,6 +1551,28 @@ s_no_extra_traits! { pub ifk_data: __c_anonymous_ifk_data, } + pub struct ifreq { + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub struct in6_ifreq { + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru6, + } +} + +s_no_extra_traits! { + #[repr(packed(4))] + pub struct ifconf { + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + pub union __c_anonymous_ifk_data { + pub ifk_ptr: *mut c_void, + pub ifk_value: c_int, + } + pub union __c_anonymous_ifr_ifru { pub ifru_addr: crate::sockaddr, pub ifru_dstaddr: crate::sockaddr, @@ -1584,11 +1592,6 @@ s_no_extra_traits! { pub ifru_functional_type: u32, } - pub struct ifreq { - pub ifr_name: [c_char; crate::IFNAMSIZ], - pub ifr_ifru: __c_anonymous_ifr_ifru, - } - pub union __c_anonymous_ifc_ifcu { pub ifcu_buf: *mut c_char, pub ifcu_req: *mut ifreq, @@ -1607,11 +1610,6 @@ s_no_extra_traits! { pub ifru_icmp6stat: icmp6_ifstat, pub ifru_scope_id: [u32; SCOPE6_ID_MAX], } - - pub struct in6_ifreq { - pub ifr_name: [c_char; crate::IFNAMSIZ], - pub ifr_ifru: __c_anonymous_ifr_ifru6, - } } impl siginfo_t { @@ -1669,842 +1667,6 @@ cfg_if! { unsafe { self.val.hash(state) }; } } - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for kevent { - fn eq(&self, other: &kevent) -> bool { - self.ident == other.ident - && self.filter == other.filter - && self.flags == other.flags - && self.fflags == other.fflags - && self.data == other.data - && self.udata == other.udata - } - } - impl Eq for kevent {} - impl hash::Hash for kevent { - fn hash(&self, state: &mut H) { - let ident = self.ident; - let filter = self.filter; - let flags = self.flags; - let fflags = self.fflags; - let data = self.data; - let udata = self.udata; - ident.hash(state); - filter.hash(state); - flags.hash(state); - fflags.hash(state); - data.hash(state); - udata.hash(state); - } - } - - impl PartialEq for semid_ds { - fn eq(&self, other: &semid_ds) -> bool { - let sem_perm = self.sem_perm; - let sem_pad3 = self.sem_pad3; - let other_sem_perm = other.sem_perm; - let other_sem_pad3 = other.sem_pad3; - sem_perm == other_sem_perm - && self.sem_base == other.sem_base - && self.sem_nsems == other.sem_nsems - && self.sem_otime == other.sem_otime - && self.sem_pad1 == other.sem_pad1 - && self.sem_ctime == other.sem_ctime - && self.sem_pad2 == other.sem_pad2 - && sem_pad3 == other_sem_pad3 - } - } - impl Eq for semid_ds {} - impl hash::Hash for semid_ds { - fn hash(&self, state: &mut H) { - let sem_perm = self.sem_perm; - let sem_base = self.sem_base; - let sem_nsems = self.sem_nsems; - let sem_otime = self.sem_otime; - let sem_pad1 = self.sem_pad1; - let sem_ctime = self.sem_ctime; - let sem_pad2 = self.sem_pad2; - let sem_pad3 = self.sem_pad3; - sem_perm.hash(state); - sem_base.hash(state); - sem_nsems.hash(state); - sem_otime.hash(state); - sem_pad1.hash(state); - sem_ctime.hash(state); - sem_pad2.hash(state); - sem_pad3.hash(state); - } - } - - impl PartialEq for shmid_ds { - fn eq(&self, other: &shmid_ds) -> bool { - let shm_perm = self.shm_perm; - let other_shm_perm = other.shm_perm; - shm_perm == other_shm_perm - && self.shm_segsz == other.shm_segsz - && self.shm_lpid == other.shm_lpid - && self.shm_cpid == other.shm_cpid - && self.shm_nattch == other.shm_nattch - && self.shm_atime == other.shm_atime - && self.shm_dtime == other.shm_dtime - && self.shm_ctime == other.shm_ctime - && self.shm_internal == other.shm_internal - } - } - impl Eq for shmid_ds {} - impl hash::Hash for shmid_ds { - fn hash(&self, state: &mut H) { - let shm_perm = self.shm_perm; - let shm_segsz = self.shm_segsz; - let shm_lpid = self.shm_lpid; - let shm_cpid = self.shm_cpid; - let shm_nattch = self.shm_nattch; - let shm_atime = self.shm_atime; - let shm_dtime = self.shm_dtime; - let shm_ctime = self.shm_ctime; - let shm_internal = self.shm_internal; - shm_perm.hash(state); - shm_segsz.hash(state); - shm_lpid.hash(state); - shm_cpid.hash(state); - shm_nattch.hash(state); - shm_atime.hash(state); - shm_dtime.hash(state); - shm_ctime.hash(state); - shm_internal.hash(state); - } - } - - impl PartialEq for proc_threadinfo { - fn eq(&self, other: &proc_threadinfo) -> bool { - self.pth_user_time == other.pth_user_time - && self.pth_system_time == other.pth_system_time - && self.pth_cpu_usage == other.pth_cpu_usage - && self.pth_policy == other.pth_policy - && self.pth_run_state == other.pth_run_state - && self.pth_flags == other.pth_flags - && self.pth_sleep_time == other.pth_sleep_time - && self.pth_curpri == other.pth_curpri - && self.pth_priority == other.pth_priority - && self.pth_maxpriority == other.pth_maxpriority - && self - .pth_name - .iter() - .zip(other.pth_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for proc_threadinfo {} - impl hash::Hash for proc_threadinfo { - fn hash(&self, state: &mut H) { - self.pth_user_time.hash(state); - self.pth_system_time.hash(state); - self.pth_cpu_usage.hash(state); - self.pth_policy.hash(state); - self.pth_run_state.hash(state); - self.pth_flags.hash(state); - self.pth_sleep_time.hash(state); - self.pth_curpri.hash(state); - self.pth_priority.hash(state); - self.pth_maxpriority.hash(state); - self.pth_name.hash(state); - } - } - - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_fsid == other.f_fsid - && self.f_owner == other.f_owner - && self.f_flags == other.f_flags - && self.f_fssubtype == other.f_fssubtype - && self.f_fstypename == other.f_fstypename - && self.f_type == other.f_type - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self.f_reserved == other.f_reserved - } - } - - impl Eq for statfs {} - - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_fsid.hash(state); - self.f_owner.hash(state); - self.f_flags.hash(state); - self.f_fssubtype.hash(state); - self.f_fstypename.hash(state); - self.f_type.hash(state); - self.f_mntonname.hash(state); - self.f_mntfromname.hash(state); - self.f_reserved.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_seekoff == other.d_seekoff - && self.d_reclen == other.d_reclen - && self.d_namlen == other.d_namlen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_seekoff.hash(state); - self.d_reclen.hash(state); - self.d_namlen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for pthread_rwlock_t {} - impl hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - - impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for pthread_mutex_t {} - - impl hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.__sig == other.__sig - && self - .__opaque - .iter() - .zip(other.__opaque.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for pthread_cond_t {} - - impl hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.__sig.hash(state); - self.__opaque.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self - .__ss_pad1 - .iter() - .zip(other.__ss_pad1.iter()) - .all(|(a, b)| a == b) - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_storage {} - - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } - } - - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_user - .iter() - .zip(other.ut_user.iter()) - .all(|(a, b)| a == b) - && self.ut_id == other.ut_id - && self.ut_line == other.ut_line - && self.ut_pid == other.ut_pid - && self.ut_type == other.ut_type - && self.ut_tv == other.ut_tv - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.ut_pad == other.ut_pad - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_user.hash(state); - self.ut_id.hash(state); - self.ut_line.hash(state); - self.ut_pid.hash(state); - self.ut_type.hash(state); - self.ut_tv.hash(state); - self.ut_host.hash(state); - self.ut_pad.hash(state); - } - } - - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - && self.sigev_notify_attributes == other.sigev_notify_attributes - } - } - - impl Eq for sigevent {} - - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - self.sigev_notify_attributes.hash(state); - } - } - - impl PartialEq for processor_cpu_load_info { - fn eq(&self, other: &processor_cpu_load_info) -> bool { - self.cpu_ticks == other.cpu_ticks - } - } - impl Eq for processor_cpu_load_info {} - impl hash::Hash for processor_cpu_load_info { - fn hash(&self, state: &mut H) { - self.cpu_ticks.hash(state); - } - } - - impl PartialEq for processor_basic_info { - fn eq(&self, other: &processor_basic_info) -> bool { - self.cpu_type == other.cpu_type - && self.cpu_subtype == other.cpu_subtype - && self.running == other.running - && self.slot_num == other.slot_num - && self.is_master == other.is_master - } - } - impl Eq for processor_basic_info {} - impl hash::Hash for processor_basic_info { - fn hash(&self, state: &mut H) { - self.cpu_type.hash(state); - self.cpu_subtype.hash(state); - self.running.hash(state); - self.slot_num.hash(state); - self.is_master.hash(state); - } - } - - impl PartialEq for processor_set_basic_info { - fn eq(&self, other: &processor_set_basic_info) -> bool { - self.processor_count == other.processor_count - && self.default_policy == other.default_policy - } - } - impl Eq for processor_set_basic_info {} - impl hash::Hash for processor_set_basic_info { - fn hash(&self, state: &mut H) { - self.processor_count.hash(state); - self.default_policy.hash(state); - } - } - - impl PartialEq for processor_set_load_info { - fn eq(&self, other: &processor_set_load_info) -> bool { - self.task_count == other.task_count - && self.thread_count == other.thread_count - && self.load_average == other.load_average - && self.mach_factor == other.mach_factor - } - } - impl Eq for processor_set_load_info {} - impl hash::Hash for processor_set_load_info { - fn hash(&self, state: &mut H) { - self.task_count.hash(state); - self.thread_count.hash(state); - self.load_average.hash(state); - self.mach_factor.hash(state); - } - } - - impl PartialEq for time_value_t { - fn eq(&self, other: &time_value_t) -> bool { - self.seconds == other.seconds && self.microseconds == other.microseconds - } - } - impl Eq for time_value_t {} - impl hash::Hash for time_value_t { - fn hash(&self, state: &mut H) { - self.seconds.hash(state); - self.microseconds.hash(state); - } - } - impl PartialEq for thread_basic_info { - fn eq(&self, other: &thread_basic_info) -> bool { - self.user_time == other.user_time - && self.system_time == other.system_time - && self.cpu_usage == other.cpu_usage - && self.policy == other.policy - && self.run_state == other.run_state - && self.flags == other.flags - && self.suspend_count == other.suspend_count - && self.sleep_time == other.sleep_time - } - } - impl Eq for thread_basic_info {} - impl hash::Hash for thread_basic_info { - fn hash(&self, state: &mut H) { - self.user_time.hash(state); - self.system_time.hash(state); - self.cpu_usage.hash(state); - self.policy.hash(state); - self.run_state.hash(state); - self.flags.hash(state); - self.suspend_count.hash(state); - self.sleep_time.hash(state); - } - } - impl PartialEq for thread_extended_info { - fn eq(&self, other: &thread_extended_info) -> bool { - self.pth_user_time == other.pth_user_time - && self.pth_system_time == other.pth_system_time - && self.pth_cpu_usage == other.pth_cpu_usage - && self.pth_policy == other.pth_policy - && self.pth_run_state == other.pth_run_state - && self.pth_flags == other.pth_flags - && self.pth_sleep_time == other.pth_sleep_time - && self.pth_curpri == other.pth_curpri - && self.pth_priority == other.pth_priority - && self.pth_maxpriority == other.pth_maxpriority - && self - .pth_name - .iter() - .zip(other.pth_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for thread_extended_info {} - impl hash::Hash for thread_extended_info { - fn hash(&self, state: &mut H) { - self.pth_user_time.hash(state); - self.pth_system_time.hash(state); - self.pth_cpu_usage.hash(state); - self.pth_policy.hash(state); - self.pth_run_state.hash(state); - self.pth_flags.hash(state); - self.pth_sleep_time.hash(state); - self.pth_curpri.hash(state); - self.pth_priority.hash(state); - self.pth_maxpriority.hash(state); - self.pth_name.hash(state); - } - } - impl PartialEq for thread_identifier_info { - fn eq(&self, other: &thread_identifier_info) -> bool { - self.thread_id == other.thread_id - && self.thread_handle == other.thread_handle - && self.dispatch_qaddr == other.dispatch_qaddr - } - } - impl Eq for thread_identifier_info {} - impl hash::Hash for thread_identifier_info { - fn hash(&self, state: &mut H) { - self.thread_id.hash(state); - self.thread_handle.hash(state); - self.dispatch_qaddr.hash(state); - } - } - impl PartialEq for if_data64 { - fn eq(&self, other: &if_data64) -> bool { - self.ifi_type == other.ifi_type - && self.ifi_typelen == other.ifi_typelen - && self.ifi_physical == other.ifi_physical - && self.ifi_addrlen == other.ifi_addrlen - && self.ifi_hdrlen == other.ifi_hdrlen - && self.ifi_recvquota == other.ifi_recvquota - && self.ifi_xmitquota == other.ifi_xmitquota - && self.ifi_unused1 == other.ifi_unused1 - && self.ifi_mtu == other.ifi_mtu - && self.ifi_metric == other.ifi_metric - && self.ifi_baudrate == other.ifi_baudrate - && self.ifi_ipackets == other.ifi_ipackets - && self.ifi_ierrors == other.ifi_ierrors - && self.ifi_opackets == other.ifi_opackets - && self.ifi_oerrors == other.ifi_oerrors - && self.ifi_collisions == other.ifi_collisions - && self.ifi_ibytes == other.ifi_ibytes - && self.ifi_obytes == other.ifi_obytes - && self.ifi_imcasts == other.ifi_imcasts - && self.ifi_omcasts == other.ifi_omcasts - && self.ifi_iqdrops == other.ifi_iqdrops - && self.ifi_noproto == other.ifi_noproto - && self.ifi_recvtiming == other.ifi_recvtiming - && self.ifi_xmittiming == other.ifi_xmittiming - && self.ifi_lastchange == other.ifi_lastchange - } - } - impl Eq for if_data64 {} - impl hash::Hash for if_data64 { - fn hash(&self, state: &mut H) { - let ifi_type = self.ifi_type; - let ifi_typelen = self.ifi_typelen; - let ifi_physical = self.ifi_physical; - let ifi_addrlen = self.ifi_addrlen; - let ifi_hdrlen = self.ifi_hdrlen; - let ifi_recvquota = self.ifi_recvquota; - let ifi_xmitquota = self.ifi_xmitquota; - let ifi_unused1 = self.ifi_unused1; - let ifi_mtu = self.ifi_mtu; - let ifi_metric = self.ifi_metric; - let ifi_baudrate = self.ifi_baudrate; - let ifi_ipackets = self.ifi_ipackets; - let ifi_ierrors = self.ifi_ierrors; - let ifi_opackets = self.ifi_opackets; - let ifi_oerrors = self.ifi_oerrors; - let ifi_collisions = self.ifi_collisions; - let ifi_ibytes = self.ifi_ibytes; - let ifi_obytes = self.ifi_obytes; - let ifi_imcasts = self.ifi_imcasts; - let ifi_omcasts = self.ifi_omcasts; - let ifi_iqdrops = self.ifi_iqdrops; - let ifi_noproto = self.ifi_noproto; - let ifi_recvtiming = self.ifi_recvtiming; - let ifi_xmittiming = self.ifi_xmittiming; - let ifi_lastchange = self.ifi_lastchange; - ifi_type.hash(state); - ifi_typelen.hash(state); - ifi_physical.hash(state); - ifi_addrlen.hash(state); - ifi_hdrlen.hash(state); - ifi_recvquota.hash(state); - ifi_xmitquota.hash(state); - ifi_unused1.hash(state); - ifi_mtu.hash(state); - ifi_metric.hash(state); - ifi_baudrate.hash(state); - ifi_ipackets.hash(state); - ifi_ierrors.hash(state); - ifi_opackets.hash(state); - ifi_oerrors.hash(state); - ifi_collisions.hash(state); - ifi_ibytes.hash(state); - ifi_obytes.hash(state); - ifi_imcasts.hash(state); - ifi_omcasts.hash(state); - ifi_iqdrops.hash(state); - ifi_noproto.hash(state); - ifi_recvtiming.hash(state); - ifi_xmittiming.hash(state); - ifi_lastchange.hash(state); - } - } - impl PartialEq for if_msghdr2 { - fn eq(&self, other: &if_msghdr2) -> bool { - self.ifm_msglen == other.ifm_msglen - && self.ifm_version == other.ifm_version - && self.ifm_type == other.ifm_type - && self.ifm_addrs == other.ifm_addrs - && self.ifm_flags == other.ifm_flags - && self.ifm_index == other.ifm_index - && self.ifm_snd_len == other.ifm_snd_len - && self.ifm_snd_maxlen == other.ifm_snd_maxlen - && self.ifm_snd_drops == other.ifm_snd_drops - && self.ifm_timer == other.ifm_timer - && self.ifm_data == other.ifm_data - } - } - impl Eq for if_msghdr2 {} - impl hash::Hash for if_msghdr2 { - fn hash(&self, state: &mut H) { - let ifm_msglen = self.ifm_msglen; - let ifm_version = self.ifm_version; - let ifm_type = self.ifm_type; - let ifm_addrs = self.ifm_addrs; - let ifm_flags = self.ifm_flags; - let ifm_index = self.ifm_index; - let ifm_snd_len = self.ifm_snd_len; - let ifm_snd_maxlen = self.ifm_snd_maxlen; - let ifm_snd_drops = self.ifm_snd_drops; - let ifm_timer = self.ifm_timer; - let ifm_data = self.ifm_data; - ifm_msglen.hash(state); - ifm_version.hash(state); - ifm_type.hash(state); - ifm_addrs.hash(state); - ifm_flags.hash(state); - ifm_index.hash(state); - ifm_snd_len.hash(state); - ifm_snd_maxlen.hash(state); - ifm_snd_drops.hash(state); - ifm_timer.hash(state); - ifm_data.hash(state); - } - } - impl PartialEq for vm_statistics64 { - fn eq(&self, other: &vm_statistics64) -> bool { - // Otherwise rustfmt crashes... - let total_uncompressed = self.total_uncompressed_pages_in_compressor; - self.free_count == other.free_count - && self.active_count == other.active_count - && self.inactive_count == other.inactive_count - && self.wire_count == other.wire_count - && self.zero_fill_count == other.zero_fill_count - && self.reactivations == other.reactivations - && self.pageins == other.pageins - && self.pageouts == other.pageouts - && self.faults == other.faults - && self.cow_faults == other.cow_faults - && self.lookups == other.lookups - && self.hits == other.hits - && self.purges == other.purges - && self.purgeable_count == other.purgeable_count - && self.speculative_count == other.speculative_count - && self.decompressions == other.decompressions - && self.compressions == other.compressions - && self.swapins == other.swapins - && self.swapouts == other.swapouts - && self.compressor_page_count == other.compressor_page_count - && self.throttled_count == other.throttled_count - && self.external_page_count == other.external_page_count - && self.internal_page_count == other.internal_page_count - && total_uncompressed == other.total_uncompressed_pages_in_compressor - } - } - impl Eq for vm_statistics64 {} - impl hash::Hash for vm_statistics64 { - fn hash(&self, state: &mut H) { - let free_count = self.free_count; - let active_count = self.active_count; - let inactive_count = self.inactive_count; - let wire_count = self.wire_count; - let zero_fill_count = self.zero_fill_count; - let reactivations = self.reactivations; - let pageins = self.pageins; - let pageouts = self.pageouts; - let faults = self.faults; - let cow_faults = self.cow_faults; - let lookups = self.lookups; - let hits = self.hits; - let purges = self.purges; - let purgeable_count = self.purgeable_count; - let speculative_count = self.speculative_count; - let decompressions = self.decompressions; - let compressions = self.compressions; - let swapins = self.swapins; - let swapouts = self.swapouts; - let compressor_page_count = self.compressor_page_count; - let throttled_count = self.throttled_count; - let external_page_count = self.external_page_count; - let internal_page_count = self.internal_page_count; - // Otherwise rustfmt crashes... - let total_uncompressed = self.total_uncompressed_pages_in_compressor; - free_count.hash(state); - active_count.hash(state); - inactive_count.hash(state); - wire_count.hash(state); - zero_fill_count.hash(state); - reactivations.hash(state); - pageins.hash(state); - pageouts.hash(state); - faults.hash(state); - cow_faults.hash(state); - lookups.hash(state); - hits.hash(state); - purges.hash(state); - purgeable_count.hash(state); - speculative_count.hash(state); - decompressions.hash(state); - compressions.hash(state); - swapins.hash(state); - swapouts.hash(state); - compressor_page_count.hash(state); - throttled_count.hash(state); - external_page_count.hash(state); - internal_page_count.hash(state); - total_uncompressed.hash(state); - } - } - - impl PartialEq for mach_task_basic_info { - fn eq(&self, other: &mach_task_basic_info) -> bool { - self.virtual_size == other.virtual_size - && self.resident_size == other.resident_size - && self.resident_size_max == other.resident_size_max - && self.user_time == other.user_time - && self.system_time == other.system_time - && self.policy == other.policy - && self.suspend_count == other.suspend_count - } - } - impl Eq for mach_task_basic_info {} - impl hash::Hash for mach_task_basic_info { - fn hash(&self, state: &mut H) { - let virtual_size = self.virtual_size; - let resident_size = self.resident_size; - let resident_size_max = self.resident_size_max; - let user_time = self.user_time; - let system_time = self.system_time; - let policy = self.policy; - let suspend_count = self.suspend_count; - virtual_size.hash(state); - resident_size.hash(state); - resident_size_max.hash(state); - user_time.hash(state); - system_time.hash(state); - policy.hash(state); - suspend_count.hash(state); - } - } - - impl PartialEq for log2phys { - fn eq(&self, other: &log2phys) -> bool { - self.l2p_flags == other.l2p_flags - && self.l2p_contigbytes == other.l2p_contigbytes - && self.l2p_devoffset == other.l2p_devoffset - } - } - impl Eq for log2phys {} - impl hash::Hash for log2phys { - fn hash(&self, state: &mut H) { - let l2p_flags = self.l2p_flags; - let l2p_contigbytes = self.l2p_contigbytes; - let l2p_devoffset = self.l2p_devoffset; - l2p_flags.hash(state); - l2p_contigbytes.hash(state); - l2p_devoffset.hash(state); - } - } - impl PartialEq for os_unfair_lock { - fn eq(&self, other: &os_unfair_lock) -> bool { - self._os_unfair_lock_opaque == other._os_unfair_lock_opaque - } - } - - impl Eq for os_unfair_lock {} - - impl hash::Hash for os_unfair_lock { - fn hash(&self, state: &mut H) { - self._os_unfair_lock_opaque.hash(state); - } - } - - impl PartialEq for sockaddr_vm { - fn eq(&self, other: &sockaddr_vm) -> bool { - self.svm_len == other.svm_len - && self.svm_family == other.svm_family - && self.svm_reserved1 == other.svm_reserved1 - && self.svm_port == other.svm_port - && self.svm_cid == other.svm_cid - } - } - - impl Eq for sockaddr_vm {} - - impl hash::Hash for sockaddr_vm { - fn hash(&self, state: &mut H) { - let svm_len = self.svm_len; - let svm_family = self.svm_family; - let svm_reserved1 = self.svm_reserved1; - let svm_port = self.svm_port; - let svm_cid = self.svm_cid; - - svm_len.hash(state); - svm_family.hash(state); - svm_reserved1.hash(state); - svm_port.hash(state); - svm_cid.hash(state); - } - } - - impl PartialEq for ifdevmtu { - fn eq(&self, other: &ifdevmtu) -> bool { - self.ifdm_current == other.ifdm_current - && self.ifdm_min == other.ifdm_min - && self.ifdm_max == other.ifdm_max - } - } - - impl Eq for ifdevmtu {} - - impl hash::Hash for ifdevmtu { - fn hash(&self, state: &mut H) { - self.ifdm_current.hash(state); - self.ifdm_min.hash(state); - self.ifdm_max.hash(state); - } - } impl PartialEq for __c_anonymous_ifk_data { fn eq(&self, other: &__c_anonymous_ifk_data) -> bool { @@ -2522,21 +1684,6 @@ cfg_if! { } } - impl PartialEq for ifkpi { - fn eq(&self, other: &ifkpi) -> bool { - self.ifk_module_id == other.ifk_module_id && self.ifk_type == other.ifk_type - } - } - - impl Eq for ifkpi {} - - impl hash::Hash for ifkpi { - fn hash(&self, state: &mut H) { - self.ifk_module_id.hash(state); - self.ifk_type.hash(state); - } - } - impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -2589,21 +1736,6 @@ cfg_if! { } } - impl PartialEq for ifreq { - fn eq(&self, other: &ifreq) -> bool { - self.ifr_name == other.ifr_name && self.ifr_ifru == other.ifr_ifru - } - } - - impl Eq for ifreq {} - - impl hash::Hash for ifreq { - fn hash(&self, state: &mut H) { - self.ifr_name.hash(state); - self.ifr_ifru.hash(state); - } - } - impl PartialEq for __c_anonymous_ifr_ifru6 { fn eq(&self, other: &__c_anonymous_ifr_ifru6) -> bool { unsafe { @@ -2639,14 +1771,6 @@ cfg_if! { } } } - - impl PartialEq for in6_ifreq { - fn eq(&self, other: &in6_ifreq) -> bool { - self.ifr_name == other.ifr_name && self.ifr_ifru == other.ifr_ifru - } - } - - impl Eq for in6_ifreq {} } } diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 0c1e075139dbf..2b49d26112bc4 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -409,9 +409,7 @@ s! { pub data: *mut c_void, pub size: size_t, } -} -s_no_extra_traits! { pub struct utmpx { pub ut_name: [c_char; 32], pub ut_id: [c_char; 4], @@ -531,255 +529,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_name == other.ut_name - && self.ut_id == other.ut_id - && self.ut_line == other.ut_line - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.ut_unused == other.ut_unused - && self.ut_session == other.ut_session - && self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_exit == other.ut_exit - && self.ut_ss == other.ut_ss - && self.ut_tv == other.ut_tv - && self.ut_unused2 == other.ut_unused2 - } - } - impl Eq for utmpx {} - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_name.hash(state); - self.ut_id.hash(state); - self.ut_line.hash(state); - self.ut_host.hash(state); - self.ut_unused.hash(state); - self.ut_session.hash(state); - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_exit.hash(state); - self.ut_ss.hash(state); - self.ut_tv.hash(state); - self.ut_unused2.hash(state); - } - } - impl PartialEq for lastlogx { - fn eq(&self, other: &lastlogx) -> bool { - self.ll_tv == other.ll_tv - && self.ll_line == other.ll_line - && self.ll_host == other.ll_host - && self.ll_ss == other.ll_ss - } - } - impl Eq for lastlogx {} - impl hash::Hash for lastlogx { - fn hash(&self, state: &mut H) { - self.ll_tv.hash(state); - self.ll_line.hash(state); - self.ll_host.hash(state); - self.ll_ss.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_namlen == other.d_namlen - && self.d_type == other.d_type - // Ignore __unused1 - // Ignore __unused2 - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a,b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_namlen.hash(state); - self.d_type.hash(state); - // Ignore __unused1 - // Ignore __unused2 - self.d_name.hash(state); - } - } - - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_fsid == other.f_fsid - && self.f_owner == other.f_owner - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_fstypename == other.f_fstypename - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_fsid.hash(state); - self.f_owner.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_fstypename.hash(state); - self.f_mntonname.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_mntfromname.hash(state); - } - } - - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - } - } - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_onstack == other.mc_onstack - && self.mc_rdi == other.mc_rdi - && self.mc_rsi == other.mc_rsi - && self.mc_rdx == other.mc_rdx - && self.mc_rcx == other.mc_rcx - && self.mc_r8 == other.mc_r8 - && self.mc_r9 == other.mc_r9 - && self.mc_rax == other.mc_rax - && self.mc_rbx == other.mc_rbx - && self.mc_rbp == other.mc_rbp - && self.mc_r10 == other.mc_r10 - && self.mc_r11 == other.mc_r11 - && self.mc_r12 == other.mc_r12 - && self.mc_r13 == other.mc_r13 - && self.mc_r14 == other.mc_r14 - && self.mc_r15 == other.mc_r15 - && self.mc_xflags == other.mc_xflags - && self.mc_trapno == other.mc_trapno - && self.mc_addr == other.mc_addr - && self.mc_flags == other.mc_flags - && self.mc_err == other.mc_err - && self.mc_rip == other.mc_rip - && self.mc_cs == other.mc_cs - && self.mc_rflags == other.mc_rflags - && self.mc_rsp == other.mc_rsp - && self.mc_ss == other.mc_ss - && self.mc_len == other.mc_len - && self.mc_fpformat == other.mc_fpformat - && self.mc_ownedfp == other.mc_ownedfp - && self.mc_fpregs == other.mc_fpregs - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_onstack.hash(state); - self.mc_rdi.hash(state); - self.mc_rsi.hash(state); - self.mc_rdx.hash(state); - self.mc_rcx.hash(state); - self.mc_r8.hash(state); - self.mc_r9.hash(state); - self.mc_rax.hash(state); - self.mc_rbx.hash(state); - self.mc_rbp.hash(state); - self.mc_r10.hash(state); - self.mc_r11.hash(state); - self.mc_r10.hash(state); - self.mc_r11.hash(state); - self.mc_r12.hash(state); - self.mc_r13.hash(state); - self.mc_r14.hash(state); - self.mc_r15.hash(state); - self.mc_xflags.hash(state); - self.mc_trapno.hash(state); - self.mc_addr.hash(state); - self.mc_flags.hash(state); - self.mc_err.hash(state); - self.mc_rip.hash(state); - self.mc_cs.hash(state); - self.mc_rflags.hash(state); - self.mc_rsp.hash(state); - self.mc_ss.hash(state); - self.mc_len.hash(state); - self.mc_fpformat.hash(state); - self.mc_ownedfp.hash(state); - self.mc_fpregs.hash(state); - } - } - // FIXME(msrv): suggested method was added in 1.85 - #[allow(unpredictable_function_pointer_comparisons)] - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_sigmask == other.uc_sigmask - && self.uc_mcontext == other.uc_mcontext - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_cofunc == other.uc_cofunc - && self.uc_arg == other.uc_arg - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_sigmask.hash(state); - self.uc_mcontext.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_cofunc.hash(state); - self.uc_arg.hash(state); - } - } - } -} - pub const RAND_MAX: c_int = 0x7fff_ffff; pub const PTHREAD_STACK_MIN: size_t = 16384; pub const SIGSTKSZ: size_t = 40960; diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index e74c26bb46e2c..232770f6e00fa 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -6,7 +6,7 @@ pub type time_t = i64; pub type suseconds_t = i64; pub type register_t = i64; -s_no_extra_traits! { +s! { pub struct gpregs { pub gp_x: [crate::register_t; 30], pub gp_lr: crate::register_t, @@ -35,74 +35,6 @@ s_no_extra_traits! { pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for gpregs { - fn eq(&self, other: &gpregs) -> bool { - self.gp_x.iter().zip(other.gp_x.iter()).all(|(a, b)| a == b) - && self.gp_lr == other.gp_lr - && self.gp_sp == other.gp_sp - && self.gp_elr == other.gp_elr - && self.gp_spsr == other.gp_spsr - && self.gp_pad == other.gp_pad - } - } - impl Eq for gpregs {} - impl hash::Hash for gpregs { - fn hash(&self, state: &mut H) { - self.gp_x.hash(state); - self.gp_lr.hash(state); - self.gp_sp.hash(state); - self.gp_elr.hash(state); - self.gp_spsr.hash(state); - self.gp_pad.hash(state); - } - } - impl PartialEq for fpregs { - fn eq(&self, other: &fpregs) -> bool { - self.fp_q == other.fp_q - && self.fp_sr == other.fp_sr - && self.fp_cr == other.fp_cr - && self.fp_flags == other.fp_flags - && self.fp_pad == other.fp_pad - } - } - impl Eq for fpregs {} - impl hash::Hash for fpregs { - fn hash(&self, state: &mut H) { - self.fp_q.hash(state); - self.fp_sr.hash(state); - self.fp_cr.hash(state); - self.fp_flags.hash(state); - self.fp_pad.hash(state); - } - } - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_gpregs == other.mc_gpregs - && self.mc_fpregs == other.mc_fpregs - && self.mc_flags == other.mc_flags - && self.mc_pad == other.mc_pad - && self - .mc_spare - .iter() - .zip(other.mc_spare.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_gpregs.hash(state); - self.mc_fpregs.hash(state); - self.mc_flags.hash(state); - self.mc_pad.hash(state); - self.mc_spare.hash(state); - } - } - } -} - pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; pub const MAP_32BIT: c_int = 0x00080000; diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index c17e12913d8f8..a0f51834d45dd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -8,7 +8,7 @@ pub type register_t = i32; pub type __greg_t = c_uint; pub type __gregset_t = [crate::__greg_t; 17]; -s_no_extra_traits! { +s! { pub struct mcontext_t { pub __gregs: crate::__gregset_t, pub mc_vfp_size: usize, @@ -17,32 +17,6 @@ s_no_extra_traits! { } } -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 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); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 83b058f8cec6f..d9c8c82f32311 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -210,9 +210,6 @@ s! { /// kthread flag. pub ki_tdflags: c_long, } -} - -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_reclen: u16, @@ -261,122 +258,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_version == other.f_version - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self.f_fstypename == other.f_fstypename - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_version.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_fsid.hash(state); - self.f_fstypename.hash(state); - self.f_mntfromname.hash(state); - self.f_mntonname.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self.d_name[..self.d_namlen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name[..self.d_namlen as _].hash(state); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_mntdir == other.vn_mntdir - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_mntdir.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - pub const ELAST: c_int = 96; pub const RAND_MAX: c_int = 0x7fff_fffd; pub const KI_NSPARE_PTR: usize = 6; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 8dcf4707749b3..f6eebeb30bf95 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -254,9 +254,7 @@ s! { pub st_gen: u64, pub st_spare: [u64; 10], } -} -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_off: off_t, @@ -305,125 +303,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_version == other.f_version - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self.f_fstypename == other.f_fstypename - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_version.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_fsid.hash(state); - self.f_charspare.hash(state); - self.f_fstypename.hash(state); - self.f_mntfromname.hash(state); - self.f_mntonname.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self.d_name[..self.d_namlen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name[..self.d_namlen as _].hash(state); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_mntdir == other.vn_mntdir - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_mntdir.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - pub const RAND_MAX: c_int = 0x7fff_fffd; pub const ELAST: c_int = 97; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 06b4304fc5326..2044d583069ea 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -267,9 +267,7 @@ s! { pub st_gen: u64, pub st_spare: [u64; 10], } -} -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_off: off_t, @@ -318,125 +316,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_version == other.f_version - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self.f_fstypename == other.f_fstypename - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_version.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_fsid.hash(state); - self.f_charspare.hash(state); - self.f_fstypename.hash(state); - self.f_mntfromname.hash(state); - self.f_mntonname.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self.d_name[..self.d_namlen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name[..self.d_namlen as _].hash(state); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_mntdir == other.vn_mntdir - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_mntdir.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - pub const RAND_MAX: c_int = 0x7fff_ffff; pub const ELAST: c_int = 97; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index 1413ef7a8de4f..263dbc12f9b98 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -269,9 +269,7 @@ s! { pub st_filerev: u64, pub st_spare: [u64; 9], } -} -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_off: off_t, @@ -320,125 +318,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_version == other.f_version - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self.f_fstypename == other.f_fstypename - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_version.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_fsid.hash(state); - self.f_charspare.hash(state); - self.f_fstypename.hash(state); - self.f_mntfromname.hash(state); - self.f_mntonname.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self.d_name[..self.d_namlen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name[..self.d_namlen as _].hash(state); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_mntdir == other.vn_mntdir - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_mntdir.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - pub const RAND_MAX: c_int = 0x7fff_ffff; pub const ELAST: c_int = 97; diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 72af5f164df99..e7a948cf9d06e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -271,9 +271,7 @@ s! { pub st_filerev: u64, pub st_spare: [u64; 9], } -} -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_off: off_t, @@ -322,125 +320,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_version == other.f_version - && self.f_type == other.f_type - && self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncwrites == other.f_asyncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncreads == other.f_asyncreads - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_fsid == other.f_fsid - && self.f_fstypename == other.f_fstypename - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statfs {} - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_version.hash(state); - self.f_type.hash(state); - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncreads.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_fsid.hash(state); - self.f_charspare.hash(state); - self.f_fstypename.hash(state); - self.f_mntfromname.hash(state); - self.f_mntonname.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self.d_name[..self.d_namlen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name[..self.d_namlen as _].hash(state); - } - } - - impl PartialEq for vnstat { - fn eq(&self, other: &vnstat) -> bool { - let self_vn_devname: &[c_char] = &self.vn_devname; - let other_vn_devname: &[c_char] = &other.vn_devname; - - self.vn_fileid == other.vn_fileid - && self.vn_size == other.vn_size - && self.vn_dev == other.vn_dev - && self.vn_fsid == other.vn_fsid - && self.vn_mntdir == other.vn_mntdir - && self.vn_type == other.vn_type - && self.vn_mode == other.vn_mode - && self_vn_devname == other_vn_devname - } - } - impl Eq for vnstat {} - impl hash::Hash for vnstat { - fn hash(&self, state: &mut H) { - let self_vn_devname: &[c_char] = &self.vn_devname; - - self.vn_fileid.hash(state); - self.vn_size.hash(state); - self.vn_dev.hash(state); - self.vn_fsid.hash(state); - self.vn_mntdir.hash(state); - self.vn_type.hash(state); - self.vn_mode.hash(state); - self_vn_devname.hash(state); - } - } - } -} - pub const RAND_MAX: c_int = 0x7fff_ffff; pub const ELAST: c_int = 97; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index a6168ca069723..edbfe7dbe99f9 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1355,34 +1355,6 @@ s! { pub sp_max: off_t, pub sp_idle: crate::timeval, } -} - -s_no_extra_traits! { - pub struct __aiocb_private { - status: c_long, - error: c_long, - spare: *mut c_void, - } - - pub struct aiocb { - pub aio_fildes: c_int, - pub aio_offset: off_t, - pub aio_buf: *mut c_void, - pub aio_nbytes: size_t, - __spare__: [c_int; 2], - __spare2__: *mut c_void, - pub aio_lio_opcode: c_int, - pub aio_reqprio: c_int, - _aiocb_private: __aiocb_private, - pub aio_sigevent: sigevent, - } - - pub union __c_anonymous_sigev_un { - pub _threadid: crate::__lwpid_t, - pub _sigev_thread: __c_anonymous_sigev_thread, - pub _kevent_flags: c_ushort, - __spare__: [c_long; 8], - } pub struct utmpx { pub ut_type: c_short, @@ -1395,11 +1367,6 @@ s_no_extra_traits! { pub __ut_spare: [c_char; 64], } - pub union __c_anonymous_cr_pid { - __cr_unused: *mut c_void, - pub cr_pid: crate::pid_t, - } - pub struct xucred { pub cr_version: c_uint, pub cr_uid: crate::uid_t, @@ -1427,13 +1394,6 @@ s_no_extra_traits! { __reserved: [c_long; 4], } - pub struct sigevent { - pub sigev_notify: c_int, - pub sigev_signo: c_int, - pub sigev_value: crate::sigval, - pub _sigev_un: __c_anonymous_sigev_un, - } - pub struct ptsstat { #[cfg(any(freebsd12, freebsd13, freebsd14, freebsd15))] pub dev: u64, @@ -1442,25 +1402,16 @@ s_no_extra_traits! { pub devname: [c_char; SPECNAMELEN as usize + 1], } - pub union __c_anonymous_elf32_auxv_union { - pub a_val: c_int, - } - pub struct Elf32_Auxinfo { pub a_type: c_int, pub a_un: __c_anonymous_elf32_auxv_union, } - pub union __c_anonymous_ifi_epoch { - pub tt: crate::time_t, - pub ph: u64, - } - - pub union __c_anonymous_ifi_lastchange { - pub tv: crate::timeval, - pub ph: __c_anonymous_ph, + pub struct ifreq { + /// if name, e.g. "en0" + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, } - pub struct if_data { /// ethernet, tokenring, etc pub ifi_type: u8, @@ -1514,35 +1465,6 @@ s_no_extra_traits! { pub __ifi_lastchange: __c_anonymous_ifi_lastchange, } - pub union __c_anonymous_ifr_ifru { - pub ifru_addr: crate::sockaddr, - pub ifru_dstaddr: crate::sockaddr, - pub ifru_broadaddr: crate::sockaddr, - pub ifru_buffer: ifreq_buffer, - pub ifru_flags: [c_short; 2], - pub ifru_index: c_short, - pub ifru_jid: c_int, - pub ifru_metric: c_int, - pub ifru_mtu: c_int, - pub ifru_phys: c_int, - pub ifru_media: c_int, - pub ifru_data: crate::caddr_t, - pub ifru_cap: [c_int; 2], - pub ifru_fib: c_uint, - pub ifru_vlan_pcp: c_uchar, - } - - pub struct ifreq { - /// if name, e.g. "en0" - pub ifr_name: [c_char; crate::IFNAMSIZ], - pub ifr_ifru: __c_anonymous_ifr_ifru, - } - - pub union __c_anonymous_ifc_ifcu { - pub ifcu_buf: crate::caddr_t, - pub ifcu_req: *mut ifreq, - } - pub struct ifstat { /// if name, e.g. "en0" pub ifs_name: [c_char; crate::IFNAMSIZ as usize], @@ -1664,6 +1586,83 @@ s_no_extra_traits! { _kf_cap_spare: u64, pub kf_path: [c_char; crate::PATH_MAX as usize], } +} + +s_no_extra_traits! { + pub struct __aiocb_private { + status: c_long, + error: c_long, + spare: *mut c_void, + } + + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_offset: off_t, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + __spare__: [c_int; 2], + __spare2__: *mut c_void, + pub aio_lio_opcode: c_int, + pub aio_reqprio: c_int, + _aiocb_private: __aiocb_private, + pub aio_sigevent: sigevent, + } + + pub union __c_anonymous_sigev_un { + pub _threadid: crate::__lwpid_t, + pub _sigev_thread: __c_anonymous_sigev_thread, + pub _kevent_flags: c_ushort, + __spare__: [c_long; 8], + } + + pub union __c_anonymous_cr_pid { + __cr_unused: *mut c_void, + pub cr_pid: crate::pid_t, + } + + pub struct sigevent { + pub sigev_notify: c_int, + pub sigev_signo: c_int, + pub sigev_value: crate::sigval, + pub _sigev_un: __c_anonymous_sigev_un, + } + + pub union __c_anonymous_elf32_auxv_union { + pub a_val: c_int, + } + + pub union __c_anonymous_ifi_epoch { + pub tt: crate::time_t, + pub ph: u64, + } + + pub union __c_anonymous_ifi_lastchange { + pub tv: crate::timeval, + pub ph: __c_anonymous_ph, + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_buffer: ifreq_buffer, + pub ifru_flags: [c_short; 2], + pub ifru_index: c_short, + pub ifru_jid: c_int, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_phys: c_int, + pub ifru_media: c_int, + pub ifru_data: crate::caddr_t, + pub ifru_cap: [c_int; 2], + pub ifru_fib: c_uint, + pub ifru_vlan_pcp: c_uchar, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: crate::caddr_t, + pub ifcu_req: *mut ifreq, + } pub struct ucontext_t { pub uc_sigmask: crate::sigset_t, @@ -1746,40 +1745,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_tv == other.ut_tv - && self.ut_id == other.ut_id - && self.ut_pid == other.ut_pid - && self.ut_user == other.ut_user - && self.ut_line == other.ut_line - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self - .__ut_spare - .iter() - .zip(other.__ut_spare.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for utmpx {} - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_tv.hash(state); - self.ut_id.hash(state); - self.ut_pid.hash(state); - self.ut_user.hash(state); - self.ut_line.hash(state); - self.ut_host.hash(state); - self.__ut_spare.hash(state); - } - } - impl PartialEq for __c_anonymous_cr_pid { fn eq(&self, other: &__c_anonymous_cr_pid) -> bool { unsafe { self.cr_pid == other.cr_pid } @@ -1792,104 +1757,17 @@ cfg_if! { } } - impl PartialEq for xucred { - fn eq(&self, other: &xucred) -> bool { - self.cr_version == other.cr_version - && self.cr_uid == other.cr_uid - && self.cr_ngroups == other.cr_ngroups - && self.cr_groups == other.cr_groups - && self.cr_pid__c_anonymous_union == other.cr_pid__c_anonymous_union - } - } - impl Eq for xucred {} - impl hash::Hash for xucred { - fn hash(&self, state: &mut H) { - self.cr_version.hash(state); - self.cr_uid.hash(state); - self.cr_ngroups.hash(state); - self.cr_groups.hash(state); - self.cr_pid__c_anonymous_union.hash(state); - } - } - - impl PartialEq for sockaddr_dl { - fn eq(&self, other: &sockaddr_dl) -> bool { - self.sdl_len == other.sdl_len - && self.sdl_family == other.sdl_family - && self.sdl_index == other.sdl_index - && self.sdl_type == other.sdl_type - && self.sdl_nlen == other.sdl_nlen - && self.sdl_alen == other.sdl_alen - && self.sdl_slen == other.sdl_slen - && self - .sdl_data - .iter() - .zip(other.sdl_data.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_dl {} - impl hash::Hash for sockaddr_dl { - fn hash(&self, state: &mut H) { - self.sdl_len.hash(state); - self.sdl_family.hash(state); - self.sdl_index.hash(state); - self.sdl_type.hash(state); - self.sdl_nlen.hash(state); - self.sdl_alen.hash(state); - self.sdl_slen.hash(state); - self.sdl_data.hash(state); - } - } - - impl PartialEq for mq_attr { - fn eq(&self, other: &mq_attr) -> bool { - self.mq_flags == other.mq_flags - && self.mq_maxmsg == other.mq_maxmsg - && self.mq_msgsize == other.mq_msgsize - && self.mq_curmsgs == other.mq_curmsgs - } - } - impl Eq for mq_attr {} - impl hash::Hash for mq_attr { - fn hash(&self, state: &mut H) { - self.mq_flags.hash(state); - self.mq_maxmsg.hash(state); - self.mq_msgsize.hash(state); - self.mq_curmsgs.hash(state); - } - } - - impl PartialEq for ptsstat { - fn eq(&self, other: &ptsstat) -> bool { - let self_devname: &[c_char] = &self.devname; - let other_devname: &[c_char] = &other.devname; - - self.dev == other.dev && self_devname == other_devname - } - } - impl Eq for ptsstat {} - impl hash::Hash for ptsstat { - fn hash(&self, state: &mut H) { - let self_devname: &[c_char] = &self.devname; - - self.dev.hash(state); - self_devname.hash(state); - } - } - impl PartialEq for __c_anonymous_elf32_auxv_union { fn eq(&self, other: &__c_anonymous_elf32_auxv_union) -> bool { unsafe { self.a_val == other.a_val } } } impl Eq for __c_anonymous_elf32_auxv_union {} - impl PartialEq for Elf32_Auxinfo { - fn eq(&self, other: &Elf32_Auxinfo) -> bool { - self.a_type == other.a_type && self.a_un == other.a_un + impl hash::Hash for __c_anonymous_elf32_auxv_union { + fn hash(&self, _state: &mut H) { + unimplemented!("traits"); } } - impl Eq for Elf32_Auxinfo {} impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { @@ -1933,27 +1811,12 @@ cfg_if! { } } - impl PartialEq for ifreq { - fn eq(&self, other: &ifreq) -> bool { - self.ifr_name == other.ifr_name && self.ifr_ifru == other.ifr_ifru - } - } - impl Eq for ifreq {} - impl hash::Hash for ifreq { - fn hash(&self, state: &mut H) { - self.ifr_name.hash(state); - self.ifr_ifru.hash(state); - } - } - - impl Eq for __c_anonymous_ifc_ifcu {} - impl PartialEq for __c_anonymous_ifc_ifcu { fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { unsafe { self.ifcu_buf == other.ifcu_buf && self.ifcu_req == other.ifcu_req } } } - + impl Eq for __c_anonymous_ifc_ifcu {} impl hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { self.ifcu_buf.hash(state) }; @@ -1961,66 +1824,6 @@ cfg_if! { } } - impl PartialEq for ifstat { - fn eq(&self, other: &ifstat) -> bool { - let self_ascii: &[c_char] = &self.ascii; - let other_ascii: &[c_char] = &other.ascii; - - self.ifs_name == other.ifs_name && self_ascii == other_ascii - } - } - impl Eq for ifstat {} - impl hash::Hash for ifstat { - fn hash(&self, state: &mut H) { - self.ifs_name.hash(state); - self.ascii.hash(state); - } - } - - impl PartialEq for ifrsskey { - fn eq(&self, other: &ifrsskey) -> bool { - let self_ifrk_key: &[u8] = &self.ifrk_key; - let other_ifrk_key: &[u8] = &other.ifrk_key; - - self.ifrk_name == other.ifrk_name - && self.ifrk_func == other.ifrk_func - && self.ifrk_spare0 == other.ifrk_spare0 - && self.ifrk_keylen == other.ifrk_keylen - && self_ifrk_key == other_ifrk_key - } - } - impl Eq for ifrsskey {} - impl hash::Hash for ifrsskey { - fn hash(&self, state: &mut H) { - self.ifrk_name.hash(state); - self.ifrk_func.hash(state); - self.ifrk_spare0.hash(state); - self.ifrk_keylen.hash(state); - self.ifrk_key.hash(state); - } - } - - impl PartialEq for ifdownreason { - fn eq(&self, other: &ifdownreason) -> bool { - let self_ifdr_msg: &[c_char] = &self.ifdr_msg; - let other_ifdr_msg: &[c_char] = &other.ifdr_msg; - - self.ifdr_name == other.ifdr_name - && self.ifdr_reason == other.ifdr_reason - && self.ifdr_vendor == other.ifdr_vendor - && self_ifdr_msg == other_ifdr_msg - } - } - impl Eq for ifdownreason {} - impl hash::Hash for ifdownreason { - fn hash(&self, state: &mut H) { - self.ifdr_name.hash(state); - self.ifdr_reason.hash(state); - self.ifdr_vendor.hash(state); - self.ifdr_msg.hash(state); - } - } - impl PartialEq for __c_anonymous_ifi_epoch { fn eq(&self, other: &__c_anonymous_ifi_epoch) -> bool { unsafe { self.tt == other.tt && self.ph == other.ph } @@ -2050,291 +1853,6 @@ cfg_if! { } } } - - impl PartialEq for if_data { - fn eq(&self, other: &if_data) -> bool { - self.ifi_type == other.ifi_type - && self.ifi_physical == other.ifi_physical - && self.ifi_addrlen == other.ifi_addrlen - && self.ifi_hdrlen == other.ifi_hdrlen - && self.ifi_link_state == other.ifi_link_state - && self.ifi_vhid == other.ifi_vhid - && self.ifi_datalen == other.ifi_datalen - && self.ifi_mtu == other.ifi_mtu - && self.ifi_metric == other.ifi_metric - && self.ifi_baudrate == other.ifi_baudrate - && self.ifi_ipackets == other.ifi_ipackets - && self.ifi_ierrors == other.ifi_ierrors - && self.ifi_opackets == other.ifi_opackets - && self.ifi_oerrors == other.ifi_oerrors - && self.ifi_collisions == other.ifi_collisions - && self.ifi_ibytes == other.ifi_ibytes - && self.ifi_obytes == other.ifi_obytes - && self.ifi_imcasts == other.ifi_imcasts - && self.ifi_omcasts == other.ifi_omcasts - && self.ifi_iqdrops == other.ifi_iqdrops - && self.ifi_oqdrops == other.ifi_oqdrops - && self.ifi_noproto == other.ifi_noproto - && self.ifi_hwassist == other.ifi_hwassist - && self.__ifi_epoch == other.__ifi_epoch - && self.__ifi_lastchange == other.__ifi_lastchange - } - } - impl Eq for if_data {} - impl hash::Hash for if_data { - fn hash(&self, state: &mut H) { - self.ifi_type.hash(state); - self.ifi_physical.hash(state); - self.ifi_addrlen.hash(state); - self.ifi_hdrlen.hash(state); - self.ifi_link_state.hash(state); - self.ifi_vhid.hash(state); - self.ifi_datalen.hash(state); - self.ifi_mtu.hash(state); - self.ifi_metric.hash(state); - self.ifi_baudrate.hash(state); - self.ifi_ipackets.hash(state); - self.ifi_ierrors.hash(state); - self.ifi_opackets.hash(state); - self.ifi_oerrors.hash(state); - self.ifi_collisions.hash(state); - self.ifi_ibytes.hash(state); - self.ifi_obytes.hash(state); - self.ifi_imcasts.hash(state); - self.ifi_omcasts.hash(state); - self.ifi_iqdrops.hash(state); - self.ifi_oqdrops.hash(state); - self.ifi_noproto.hash(state); - self.ifi_hwassist.hash(state); - self.__ifi_epoch.hash(state); - self.__ifi_lastchange.hash(state); - } - } - - impl PartialEq for sctphdr { - fn eq(&self, other: &sctphdr) -> bool { - return { self.src_port } == { other.src_port } - && { self.dest_port } == { other.dest_port } - && { self.v_tag } == { other.v_tag } - && { self.checksum } == { other.checksum }; - } - } - impl Eq for sctphdr {} - impl hash::Hash for sctphdr { - fn hash(&self, state: &mut H) { - { self.src_port }.hash(state); - { self.dest_port }.hash(state); - { self.v_tag }.hash(state); - { self.checksum }.hash(state); - } - } - - impl PartialEq for sctp_chunkhdr { - fn eq(&self, other: &sctp_chunkhdr) -> bool { - return { self.chunk_type } == { other.chunk_type } - && { self.chunk_flags } == { other.chunk_flags } - && { self.chunk_length } == { other.chunk_length }; - } - } - impl Eq for sctp_chunkhdr {} - impl hash::Hash for sctp_chunkhdr { - fn hash(&self, state: &mut H) { - { self.chunk_type }.hash(state); - { self.chunk_flags }.hash(state); - { self.chunk_length }.hash(state); - } - } - - impl PartialEq for sctp_paramhdr { - fn eq(&self, other: &sctp_paramhdr) -> bool { - return { self.param_type } == { other.param_type } && { self.param_length } == { - other.param_length - }; - } - } - impl Eq for sctp_paramhdr {} - impl hash::Hash for sctp_paramhdr { - fn hash(&self, state: &mut H) { - { self.param_type }.hash(state); - { self.param_length }.hash(state); - } - } - - impl PartialEq for sctp_gen_error_cause { - fn eq(&self, other: &sctp_gen_error_cause) -> bool { - return { self.code } == { other.code } && { self.length } == { other.length } && { - self.info - } - .iter() - .zip({ other.info }.iter()) - .all(|(a, b)| a == b); - } - } - impl Eq for sctp_gen_error_cause {} - impl hash::Hash for sctp_gen_error_cause { - fn hash(&self, state: &mut H) { - { self.code }.hash(state); - { self.length }.hash(state); - { self.info }.hash(state); - } - } - - impl PartialEq for sctp_error_cause { - fn eq(&self, other: &sctp_error_cause) -> bool { - return { self.code } == { other.code } && { self.length } == { other.length }; - } - } - impl Eq for sctp_error_cause {} - impl hash::Hash for sctp_error_cause { - fn hash(&self, state: &mut H) { - { self.code }.hash(state); - { self.length }.hash(state); - } - } - - impl PartialEq for sctp_error_invalid_stream { - fn eq(&self, other: &sctp_error_invalid_stream) -> bool { - return { self.cause } == { other.cause } && { self.stream_id } == { - other.stream_id - }; - } - } - impl Eq for sctp_error_invalid_stream {} - impl hash::Hash for sctp_error_invalid_stream { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.stream_id }.hash(state); - } - } - - impl PartialEq for sctp_error_missing_param { - fn eq(&self, other: &sctp_error_missing_param) -> bool { - return { self.cause } == { other.cause } - && { self.num_missing_params } == { other.num_missing_params } - && { self.tpe } - .iter() - .zip({ other.tpe }.iter()) - .all(|(a, b)| a == b); - } - } - impl Eq for sctp_error_missing_param {} - impl hash::Hash for sctp_error_missing_param { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.num_missing_params }.hash(state); - { self.tpe }.hash(state); - } - } - - impl PartialEq for sctp_error_stale_cookie { - fn eq(&self, other: &sctp_error_stale_cookie) -> bool { - return { self.cause } == { other.cause } && { self.stale_time } == { - other.stale_time - }; - } - } - impl Eq for sctp_error_stale_cookie {} - impl hash::Hash for sctp_error_stale_cookie { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.stale_time }.hash(state); - } - } - - impl PartialEq for sctp_error_out_of_resource { - fn eq(&self, other: &sctp_error_out_of_resource) -> bool { - return { self.cause } == { other.cause }; - } - } - impl Eq for sctp_error_out_of_resource {} - impl hash::Hash for sctp_error_out_of_resource { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - } - } - - impl PartialEq for sctp_error_unresolv_addr { - fn eq(&self, other: &sctp_error_unresolv_addr) -> bool { - return { self.cause } == { other.cause }; - } - } - impl Eq for sctp_error_unresolv_addr {} - impl hash::Hash for sctp_error_unresolv_addr { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - } - } - - impl PartialEq for sctp_error_unrecognized_chunk { - fn eq(&self, other: &sctp_error_unrecognized_chunk) -> bool { - return { self.cause } == { other.cause } && { self.ch } == { other.ch }; - } - } - impl Eq for sctp_error_unrecognized_chunk {} - impl hash::Hash for sctp_error_unrecognized_chunk { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.ch }.hash(state); - } - } - - impl PartialEq for sctp_error_no_user_data { - fn eq(&self, other: &sctp_error_no_user_data) -> bool { - return { self.cause } == { other.cause } && { self.tsn } == { other.tsn }; - } - } - impl Eq for sctp_error_no_user_data {} - impl hash::Hash for sctp_error_no_user_data { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.tsn }.hash(state); - } - } - - impl PartialEq for sctp_error_auth_invalid_hmac { - fn eq(&self, other: &sctp_error_auth_invalid_hmac) -> bool { - return { self.cause } == { other.cause } && { self.hmac_id } == { other.hmac_id }; - } - } - impl Eq for sctp_error_auth_invalid_hmac {} - impl hash::Hash for sctp_error_auth_invalid_hmac { - fn hash(&self, state: &mut H) { - { self.cause }.hash(state); - { self.hmac_id }.hash(state); - } - } - - impl PartialEq for kinfo_file { - fn eq(&self, other: &kinfo_file) -> bool { - self.kf_structsize == other.kf_structsize - && self.kf_type == other.kf_type - && self.kf_fd == other.kf_fd - && self.kf_ref_count == other.kf_ref_count - && self.kf_flags == other.kf_flags - && self.kf_offset == other.kf_offset - && self.kf_status == other.kf_status - && self.kf_cap_rights == other.kf_cap_rights - && self - .kf_path - .iter() - .zip(other.kf_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for kinfo_file {} - impl hash::Hash for kinfo_file { - fn hash(&self, state: &mut H) { - self.kf_structsize.hash(state); - self.kf_type.hash(state); - self.kf_fd.hash(state); - self.kf_ref_count.hash(state); - self.kf_flags.hash(state); - self.kf_offset.hash(state); - self.kf_status.hash(state); - self.kf_cap_rights.hash(state); - self.kf_path.hash(state); - } - } } } diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index e4275b10ba508..4c0e165af9d24 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -6,7 +6,7 @@ pub type time_t = i64; pub type suseconds_t = i32; pub type register_t = i32; -s_no_extra_traits! { +s! { #[repr(align(16))] pub struct mcontext_t { pub mc_vers: c_int, @@ -21,38 +21,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(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 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); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index b5a81311ecc60..bfc6d5c2ccc2e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -6,7 +6,7 @@ pub type time_t = i64; pub type suseconds_t = i64; pub type register_t = i64; -s_no_extra_traits! { +s! { #[repr(align(16))] pub struct mcontext_t { pub mc_vers: c_int, @@ -21,38 +21,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(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 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); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index 5ae5d34a74660..e2d7920541d9a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -6,7 +6,7 @@ pub type time_t = i64; pub type suseconds_t = c_long; pub type register_t = i64; -s_no_extra_traits! { +s! { pub struct gpregs { pub gp_ra: crate::register_t, pub gp_sp: crate::register_t, @@ -35,78 +35,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for gpregs { - fn eq(&self, other: &gpregs) -> bool { - self.gp_ra == other.gp_ra - && self.gp_sp == other.gp_sp - && self.gp_gp == other.gp_gp - && self.gp_tp == other.gp_tp - && self.gp_t.iter().zip(other.gp_t.iter()).all(|(a, b)| a == b) - && self.gp_s.iter().zip(other.gp_s.iter()).all(|(a, b)| a == b) - && self.gp_a.iter().zip(other.gp_a.iter()).all(|(a, b)| a == b) - && self.gp_sepc == other.gp_sepc - && self.gp_sstatus == other.gp_sstatus - } - } - impl Eq for gpregs {} - impl hash::Hash for gpregs { - fn hash(&self, state: &mut H) { - self.gp_ra.hash(state); - self.gp_sp.hash(state); - self.gp_gp.hash(state); - self.gp_tp.hash(state); - self.gp_t.hash(state); - self.gp_s.hash(state); - self.gp_a.hash(state); - self.gp_sepc.hash(state); - self.gp_sstatus.hash(state); - } - } - impl PartialEq for fpregs { - fn eq(&self, other: &fpregs) -> bool { - self.fp_x == other.fp_x - && self.fp_fcsr == other.fp_fcsr - && self.fp_flags == other.fp_flags - && self.pad == other.pad - } - } - impl Eq for fpregs {} - impl hash::Hash for fpregs { - fn hash(&self, state: &mut H) { - self.fp_x.hash(state); - self.fp_fcsr.hash(state); - self.fp_flags.hash(state); - self.pad.hash(state); - } - } - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_gpregs == other.mc_gpregs - && self.mc_fpregs == other.mc_fpregs - && self.mc_flags == other.mc_flags - && self.mc_pad == other.mc_pad - && self - .mc_spare - .iter() - .zip(other.mc_spare.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_gpregs.hash(state); - self.mc_fpregs.hash(state); - self.mc_flags.hash(state); - self.mc_pad.hash(state); - self.mc_spare.hash(state); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 899ccd9f1b036..a95914d8a49a2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -6,7 +6,7 @@ pub type time_t = i32; pub type suseconds_t = i32; pub type register_t = i32; -s_no_extra_traits! { +s! { #[repr(align(16))] pub struct mcontext_t { pub mc_onstack: register_t, @@ -44,88 +44,6 @@ s_no_extra_traits! { pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_onstack == other.mc_onstack - && self.mc_gs == other.mc_gs - && self.mc_fs == other.mc_fs - && self.mc_es == other.mc_es - && self.mc_ds == other.mc_ds - && self.mc_edi == other.mc_edi - && self.mc_esi == other.mc_esi - && self.mc_ebp == other.mc_ebp - && self.mc_isp == other.mc_isp - && self.mc_ebx == other.mc_ebx - && self.mc_edx == other.mc_edx - && self.mc_ecx == other.mc_ecx - && self.mc_eax == other.mc_eax - && self.mc_trapno == other.mc_trapno - && self.mc_err == other.mc_err - && self.mc_eip == other.mc_eip - && self.mc_cs == other.mc_cs - && self.mc_eflags == other.mc_eflags - && self.mc_esp == other.mc_esp - && self.mc_ss == other.mc_ss - && self.mc_len == other.mc_len - && self.mc_fpformat == other.mc_fpformat - && self.mc_ownedfp == other.mc_ownedfp - && self.mc_flags == other.mc_flags - && self - .mc_fpstate - .iter() - .zip(other.mc_fpstate.iter()) - .all(|(a, b)| a == b) - && self.mc_fsbase == other.mc_fsbase - && self.mc_gsbase == other.mc_gsbase - && self.mc_xfpustate == other.mc_xfpustate - && self.mc_xfpustate_len == other.mc_xfpustate_len - && self - .mc_spare2 - .iter() - .zip(other.mc_spare2.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_onstack.hash(state); - self.mc_gs.hash(state); - self.mc_fs.hash(state); - self.mc_es.hash(state); - self.mc_ds.hash(state); - self.mc_edi.hash(state); - self.mc_esi.hash(state); - self.mc_ebp.hash(state); - self.mc_isp.hash(state); - self.mc_ebx.hash(state); - self.mc_edx.hash(state); - self.mc_ecx.hash(state); - self.mc_eax.hash(state); - self.mc_trapno.hash(state); - self.mc_err.hash(state); - self.mc_eip.hash(state); - self.mc_cs.hash(state); - self.mc_eflags.hash(state); - self.mc_esp.hash(state); - self.mc_ss.hash(state); - self.mc_len.hash(state); - self.mc_fpformat.hash(state); - self.mc_ownedfp.hash(state); - self.mc_flags.hash(state); - self.mc_fpstate.hash(state); - self.mc_fsbase.hash(state); - self.mc_gsbase.hash(state); - self.mc_xfpustate.hash(state); - self.mc_xfpustate_len.hash(state); - self.mc_spare2.hash(state); - } - } - } -} - pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index d665e3da01e87..2d7a2b66621cf 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -57,9 +57,7 @@ s! { pub r_rsp: i64, pub r_ss: i64, } -} -s_no_extra_traits! { pub struct fpreg32 { pub fpr_env: [u32; 7], pub fpr_acc: [[u8; 10]; 8], @@ -80,23 +78,6 @@ s_no_extra_traits! { pub xmm_reg: [[u8; 16]; 8], pub xmm_pad: [u8; 224], } - - pub union __c_anonymous_elf64_auxv_union { - pub a_val: c_long, - pub a_ptr: *mut c_void, - pub a_fcn: extern "C" fn(), - } - - pub struct Elf64_Auxinfo { - pub a_type: c_long, - pub a_un: __c_anonymous_elf64_auxv_union, - } - - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4], - } - #[repr(align(16))] #[cfg_attr(not(any(freebsd11, freebsd12, freebsd13, freebsd14)), non_exhaustive)] pub struct mcontext_t { @@ -148,70 +129,26 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for fpreg32 { - fn eq(&self, other: &fpreg32) -> bool { - self.fpr_env == other.fpr_env - && self.fpr_acc == other.fpr_acc - && self.fpr_ex_sw == other.fpr_ex_sw - && self - .fpr_pad - .iter() - .zip(other.fpr_pad.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for fpreg32 {} - impl hash::Hash for fpreg32 { - fn hash(&self, state: &mut H) { - self.fpr_env.hash(state); - self.fpr_acc.hash(state); - self.fpr_ex_sw.hash(state); - self.fpr_pad.hash(state); - } - } +s_no_extra_traits! { + pub union __c_anonymous_elf64_auxv_union { + pub a_val: c_long, + pub a_ptr: *mut c_void, + pub a_fcn: extern "C" fn(), + } - impl PartialEq for fpreg { - fn eq(&self, other: &fpreg) -> bool { - self.fpr_env == other.fpr_env - && self.fpr_acc == other.fpr_acc - && self.fpr_xacc == other.fpr_xacc - && self.fpr_spare == other.fpr_spare - } - } - impl Eq for fpreg {} - impl hash::Hash for fpreg { - fn hash(&self, state: &mut H) { - self.fpr_env.hash(state); - self.fpr_acc.hash(state); - self.fpr_xacc.hash(state); - self.fpr_spare.hash(state); - } - } + pub struct Elf64_Auxinfo { + pub a_type: c_long, + pub a_un: __c_anonymous_elf64_auxv_union, + } - impl PartialEq for xmmreg { - fn eq(&self, other: &xmmreg) -> bool { - self.xmm_env == other.xmm_env - && self.xmm_acc == other.xmm_acc - && self.xmm_reg == other.xmm_reg - && self - .xmm_pad - .iter() - .zip(other.xmm_pad.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for xmmreg {} - impl hash::Hash for xmmreg { - fn hash(&self, state: &mut H) { - self.xmm_env.hash(state); - self.xmm_acc.hash(state); - self.xmm_reg.hash(state); - self.xmm_pad.hash(state); - } - } + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} +cfg_if! { + if #[cfg(feature = "extra_traits")] { // FIXME(msrv): suggested method was added in 1.85 #[allow(unpredictable_function_pointer_comparisons)] impl PartialEq for __c_anonymous_elf64_auxv_union { @@ -224,102 +161,6 @@ cfg_if! { } } impl Eq for __c_anonymous_elf64_auxv_union {} - impl PartialEq for Elf64_Auxinfo { - fn eq(&self, other: &Elf64_Auxinfo) -> bool { - self.a_type == other.a_type && self.a_un == other.a_un - } - } - impl Eq for Elf64_Auxinfo {} - - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.mc_onstack == other.mc_onstack - && self.mc_rdi == other.mc_rdi - && self.mc_rsi == other.mc_rsi - && self.mc_rdx == other.mc_rdx - && self.mc_rcx == other.mc_rcx - && self.mc_r8 == other.mc_r8 - && self.mc_r9 == other.mc_r9 - && self.mc_rax == other.mc_rax - && self.mc_rbx == other.mc_rbx - && self.mc_rbp == other.mc_rbp - && self.mc_r10 == other.mc_r10 - && self.mc_r11 == other.mc_r11 - && self.mc_r12 == other.mc_r12 - && self.mc_r13 == other.mc_r13 - && self.mc_r14 == other.mc_r14 - && self.mc_r15 == other.mc_r15 - && self.mc_trapno == other.mc_trapno - && self.mc_fs == other.mc_fs - && self.mc_gs == other.mc_gs - && self.mc_addr == other.mc_addr - && self.mc_flags == other.mc_flags - && self.mc_es == other.mc_es - && self.mc_ds == other.mc_ds - && self.mc_err == other.mc_err - && self.mc_rip == other.mc_rip - && self.mc_cs == other.mc_cs - && self.mc_rflags == other.mc_rflags - && self.mc_rsp == other.mc_rsp - && self.mc_ss == other.mc_ss - && self.mc_len == other.mc_len - && self.mc_fpformat == other.mc_fpformat - && self.mc_ownedfp == other.mc_ownedfp - && self - .mc_fpstate - .iter() - .zip(other.mc_fpstate.iter()) - .all(|(a, b)| a == b) - && self.mc_fsbase == other.mc_fsbase - && self.mc_gsbase == other.mc_gsbase - && self.mc_xfpustate == other.mc_xfpustate - && self.mc_xfpustate_len == other.mc_xfpustate_len - && self.mc_spare == other.mc_spare - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.mc_onstack.hash(state); - self.mc_rdi.hash(state); - self.mc_rsi.hash(state); - self.mc_rdx.hash(state); - self.mc_rcx.hash(state); - self.mc_r8.hash(state); - self.mc_r9.hash(state); - self.mc_rax.hash(state); - self.mc_rbx.hash(state); - self.mc_rbp.hash(state); - self.mc_r10.hash(state); - self.mc_r11.hash(state); - self.mc_r12.hash(state); - self.mc_r13.hash(state); - self.mc_r14.hash(state); - self.mc_r15.hash(state); - self.mc_trapno.hash(state); - self.mc_fs.hash(state); - self.mc_gs.hash(state); - self.mc_addr.hash(state); - self.mc_flags.hash(state); - self.mc_es.hash(state); - self.mc_ds.hash(state); - self.mc_err.hash(state); - self.mc_rip.hash(state); - self.mc_cs.hash(state); - self.mc_rflags.hash(state); - self.mc_rsp.hash(state); - self.mc_ss.hash(state); - self.mc_len.hash(state); - self.mc_fpformat.hash(state); - self.mc_ownedfp.hash(state); - self.mc_fpstate.hash(state); - self.mc_fsbase.hash(state); - self.mc_gsbase.hash(state); - self.mc_xfpustate.hash(state); - self.mc_xfpustate_len.hash(state); - self.mc_spare.hash(state); - } - } } } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 4469ada4a8c5b..fe180c69f4ea8 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -381,9 +381,7 @@ s! { pub struct eui64 { pub octet: [u8; EUI64_LEN], } -} -s_no_extra_traits! { pub struct sockaddr_storage { pub ss_len: u8, pub ss_family: crate::sa_family_t, @@ -393,34 +391,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self.__ss_pad1 == other.__ss_pad1 - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } - } - } -} - // Non-public helper constant const SIZEOF_LONG: usize = size_of::(); diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index bccf17354168b..420ff3b1bab1f 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -131,9 +131,6 @@ s! { pub flag: *mut c_int, pub val: c_int, } -} - -s_no_extra_traits! { pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, @@ -164,73 +161,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_len == other.sun_len - && self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_un {} - - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_len.hash(state); - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utsname {} - - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - } - } - } -} - pub const LC_ALL: c_int = 0; pub const LC_COLLATE: c_int = 1; pub const LC_CTYPE: c_int = 2; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 1d9b26657c49e..e7f0d08aca0ac 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -792,9 +792,7 @@ s! { pub tcpi_snd_zerowin: u32, pub __tcpi_pad: [u32; 26], } -} -s_no_extra_traits! { pub struct utmpx { pub ut_name: [c_char; _UTX_USERSIZE], pub ut_id: [c_char; _UTX_IDSIZE], @@ -903,7 +901,9 @@ s_no_extra_traits! { __unused1: *mut c_void, //actually a function pointer pub sigev_notify_attributes: *mut c_void, } +} +s_no_extra_traits! { pub union __c_anonymous_posix_spawn_fae { pub open: __c_anonymous_posix_spawn_fae_open, pub dup2: __c_anonymous_posix_spawn_fae_dup2, @@ -917,295 +917,12 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_name == other.ut_name - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_ss == other.ut_ss - && self - .ut_pad - .iter() - .zip(other.ut_pad.iter()) - .all(|(a, b)| a == b) - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_name.hash(state); - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_ss.hash(state); - self.ut_pad.hash(state); - } - } - - impl PartialEq for lastlogx { - fn eq(&self, other: &lastlogx) -> bool { - self.ll_tv == other.ll_tv - && self.ll_line == other.ll_line - && self.ll_ss == other.ll_ss - && self - .ll_host - .iter() - .zip(other.ll_host.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for lastlogx {} - - impl hash::Hash for lastlogx { - fn hash(&self, state: &mut H) { - self.ll_tv.hash(state); - self.ll_line.hash(state); - self.ll_host.hash(state); - self.ll_ss.hash(state); - } - } - - impl PartialEq for in_pktinfo { - fn eq(&self, other: &in_pktinfo) -> bool { - self.ipi_addr == other.ipi_addr && self.ipi_ifindex == other.ipi_ifindex - } - } - impl Eq for in_pktinfo {} - impl hash::Hash for in_pktinfo { - fn hash(&self, state: &mut H) { - self.ipi_addr.hash(state); - self.ipi_ifindex.hash(state); - } - } - - impl PartialEq for arphdr { - fn eq(&self, other: &arphdr) -> bool { - self.ar_hrd == other.ar_hrd - && self.ar_pro == other.ar_pro - && self.ar_hln == other.ar_hln - && self.ar_pln == other.ar_pln - && self.ar_op == other.ar_op - } - } - impl Eq for arphdr {} - impl hash::Hash for arphdr { - fn hash(&self, state: &mut H) { - let ar_hrd = self.ar_hrd; - let ar_pro = self.ar_pro; - let ar_op = self.ar_op; - ar_hrd.hash(state); - ar_pro.hash(state); - self.ar_hln.hash(state); - self.ar_pln.hash(state); - ar_op.hash(state); - } - } - - impl PartialEq for in_addr { - fn eq(&self, other: &in_addr) -> bool { - self.s_addr == other.s_addr - } - } - impl Eq for in_addr {} - impl hash::Hash for in_addr { - fn hash(&self, state: &mut H) { - let s_addr = self.s_addr; - s_addr.hash(state); - } - } - - impl PartialEq for ip_mreq { - fn eq(&self, other: &ip_mreq) -> bool { - self.imr_multiaddr == other.imr_multiaddr - && self.imr_interface == other.imr_interface - } - } - impl Eq for ip_mreq {} - impl hash::Hash for ip_mreq { - fn hash(&self, state: &mut H) { - self.imr_multiaddr.hash(state); - self.imr_interface.hash(state); - } - } - - impl PartialEq for sockaddr_in { - fn eq(&self, other: &sockaddr_in) -> bool { - self.sin_len == other.sin_len - && self.sin_family == other.sin_family - && self.sin_port == other.sin_port - && self.sin_addr == other.sin_addr - && self.sin_zero == other.sin_zero - } - } - impl Eq for sockaddr_in {} - impl hash::Hash for sockaddr_in { - fn hash(&self, state: &mut H) { - self.sin_len.hash(state); - self.sin_family.hash(state); - self.sin_port.hash(state); - self.sin_addr.hash(state); - self.sin_zero.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_reclen == other.d_reclen - && self.d_namlen == other.d_namlen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_reclen.hash(state); - self.d_namlen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for statvfs { - fn eq(&self, other: &statvfs) -> bool { - self.f_flag == other.f_flag - && self.f_bsize == other.f_bsize - && self.f_frsize == other.f_frsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_bresvd == other.f_bresvd - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_favail == other.f_favail - && self.f_fresvd == other.f_fresvd - && self.f_syncreads == other.f_syncreads - && self.f_syncwrites == other.f_syncwrites - && self.f_asyncreads == other.f_asyncreads - && self.f_asyncwrites == other.f_asyncwrites - && self.f_fsidx == other.f_fsidx - && self.f_fsid == other.f_fsid - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_spare == other.f_spare - && self.f_fstypename == other.f_fstypename - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for statvfs {} - impl hash::Hash for statvfs { - fn hash(&self, state: &mut H) { - self.f_flag.hash(state); - self.f_bsize.hash(state); - self.f_frsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_bresvd.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_favail.hash(state); - self.f_fresvd.hash(state); - self.f_syncreads.hash(state); - self.f_syncwrites.hash(state); - self.f_asyncreads.hash(state); - self.f_asyncwrites.hash(state); - self.f_fsidx.hash(state); - self.f_fsid.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_spare.hash(state); - self.f_fstypename.hash(state); - self.f_mntonname.hash(state); - self.f_mntfromname.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self.__ss_pad1 == other.__ss_pad1 - && self.__ss_pad2 == other.__ss_pad2 - && self - .__ss_pad3 - .iter() - .zip(other.__ss_pad3.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_pad2.hash(state); - self.__ss_pad3.hash(state); - } - } - - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - && self.sigev_notify_attributes == other.sigev_notify_attributes - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - self.sigev_notify_attributes.hash(state); - } - } - impl Eq for __c_anonymous_posix_spawn_fae {} - impl PartialEq for __c_anonymous_posix_spawn_fae { fn eq(&self, other: &__c_anonymous_posix_spawn_fae) -> bool { unsafe { self.open == other.open || self.dup2 == other.dup2 } } } - impl hash::Hash for __c_anonymous_posix_spawn_fae { fn hash(&self, state: &mut H) { unsafe { @@ -1216,13 +933,11 @@ cfg_if! { } impl Eq for __c_anonymous_ifc_ifcu {} - impl PartialEq for __c_anonymous_ifc_ifcu { fn eq(&self, other: &__c_anonymous_ifc_ifcu) -> bool { unsafe { self.ifcu_buf == other.ifcu_buf || self.ifcu_req == other.ifcu_req } } } - impl hash::Hash for __c_anonymous_ifc_ifcu { fn hash(&self, state: &mut H) { unsafe { diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index b07129b884c09..12f9fd45dd137 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -609,62 +609,7 @@ s! { pub tcpi_so_snd_sb_lowat: u32, pub tcpi_so_snd_sb_wat: u32, } -} - -impl siginfo_t { - pub unsafe fn si_addr(&self) -> *mut c_char { - self.si_addr - } - pub unsafe fn si_code(&self) -> c_int { - self.si_code - } - - pub unsafe fn si_errno(&self) -> c_int { - self.si_errno - } - - pub unsafe fn si_pid(&self) -> crate::pid_t { - #[repr(C)] - struct siginfo_timer { - _si_signo: c_int, - _si_code: c_int, - _si_errno: c_int, - _pad: [c_int; SI_PAD], - _pid: crate::pid_t, - } - (*(self as *const siginfo_t).cast::())._pid - } - - pub unsafe fn si_uid(&self) -> crate::uid_t { - #[repr(C)] - struct siginfo_timer { - _si_signo: c_int, - _si_code: c_int, - _si_errno: c_int, - _pad: [c_int; SI_PAD], - _pid: crate::pid_t, - _uid: crate::uid_t, - } - (*(self as *const siginfo_t).cast::())._uid - } - - pub unsafe fn si_value(&self) -> crate::sigval { - #[repr(C)] - struct siginfo_timer { - _si_signo: c_int, - _si_code: c_int, - _si_errno: c_int, - _pad: [c_int; SI_PAD], - _pid: crate::pid_t, - _uid: crate::uid_t, - value: crate::sigval, - } - (*(self as *const siginfo_t).cast::()).value - } -} - -s_no_extra_traits! { pub struct dirent { pub d_fileno: crate::ino_t, pub d_off: off_t, @@ -707,29 +652,6 @@ s_no_extra_traits! { pub ut_time: crate::time_t, } - pub union mount_info { - pub ufs_args: ufs_args, - pub mfs_args: mfs_args, - pub nfs_args: nfs_args, - pub iso_args: iso_args, - pub msdosfs_args: msdosfs_args, - pub ntfs_args: ntfs_args, - pub tmpfs_args: tmpfs_args, - align: [c_char; 160], - } - - pub union __c_anonymous_ifr_ifru { - pub ifru_addr: crate::sockaddr, - pub ifru_dstaddr: crate::sockaddr, - pub ifru_broadaddr: crate::sockaddr, - pub ifru_flags: c_short, - pub ifru_metric: c_int, - pub ifru_vnetid: i64, - pub ifru_media: u64, - pub ifru_data: crate::caddr_t, - pub ifru_index: c_uint, - } - pub struct statfs { pub f_flags: u32, pub f_bsize: u32, @@ -756,148 +678,111 @@ s_no_extra_traits! { } } +s_no_extra_traits! { + pub union mount_info { + pub ufs_args: ufs_args, + pub mfs_args: mfs_args, + pub nfs_args: nfs_args, + pub iso_args: iso_args, + pub msdosfs_args: msdosfs_args, + pub ntfs_args: ntfs_args, + pub tmpfs_args: tmpfs_args, + align: [c_char; 160], + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_fileno == other.d_fileno - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self.d_namlen == other.d_namlen - && self - .d_name + impl PartialEq for mount_info { + fn eq(&self, other: &mount_info) -> bool { + unsafe { + self.align .iter() - .zip(other.d_name.iter()) + .zip(other.align.iter()) .all(|(a, b)| a == b) + } } } - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_fileno.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_namlen.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len && self.ss_family == other.ss_family - } - } - - impl Eq for sockaddr_storage {} - - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - } - } - - impl PartialEq for siginfo_t { - fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo - && self.si_code == other.si_code - && self.si_errno == other.si_errno - && self.si_addr == other.si_addr - } - } - - impl Eq for siginfo_t {} + impl Eq for mount_info {} - impl hash::Hash for siginfo_t { + impl hash::Hash for mount_info { fn hash(&self, state: &mut H) { - self.si_signo.hash(state); - self.si_code.hash(state); - self.si_errno.hash(state); - self.si_addr.hash(state); + unsafe { self.align.hash(state) }; } } + } +} - impl PartialEq for lastlog { - fn eq(&self, other: &lastlog) -> bool { - self.ll_time == other.ll_time - && self - .ll_line - .iter() - .zip(other.ll_line.iter()) - .all(|(a, b)| a == b) - && self - .ll_host - .iter() - .zip(other.ll_host.iter()) - .all(|(a, b)| a == b) - } - } +impl siginfo_t { + pub unsafe fn si_addr(&self) -> *mut c_char { + self.si_addr + } - impl Eq for lastlog {} + pub unsafe fn si_code(&self) -> c_int { + self.si_code + } - impl hash::Hash for lastlog { - fn hash(&self, state: &mut H) { - self.ll_time.hash(state); - self.ll_line.hash(state); - self.ll_host.hash(state); - } - } + pub unsafe fn si_errno(&self) -> c_int { + self.si_errno + } - impl PartialEq for utmp { - fn eq(&self, other: &utmp) -> bool { - self.ut_time == other.ut_time - && self - .ut_line - .iter() - .zip(other.ut_line.iter()) - .all(|(a, b)| a == b) - && self - .ut_name - .iter() - .zip(other.ut_name.iter()) - .all(|(a, b)| a == b) - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - } + pub unsafe fn si_pid(&self) -> crate::pid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_code: c_int, + _si_errno: c_int, + _pad: [c_int; SI_PAD], + _pid: crate::pid_t, } + (*(self as *const siginfo_t).cast::())._pid + } - impl Eq for utmp {} - - impl hash::Hash for utmp { - fn hash(&self, state: &mut H) { - self.ut_line.hash(state); - self.ut_name.hash(state); - self.ut_host.hash(state); - self.ut_time.hash(state); - } + pub unsafe fn si_uid(&self) -> crate::uid_t { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_code: c_int, + _si_errno: c_int, + _pad: [c_int; SI_PAD], + _pid: crate::pid_t, + _uid: crate::uid_t, } + (*(self as *const siginfo_t).cast::())._uid + } - impl PartialEq for mount_info { - fn eq(&self, other: &mount_info) -> bool { - unsafe { - self.align - .iter() - .zip(other.align.iter()) - .all(|(a, b)| a == b) - } - } + pub unsafe fn si_value(&self) -> crate::sigval { + #[repr(C)] + struct siginfo_timer { + _si_signo: c_int, + _si_code: c_int, + _si_errno: c_int, + _pad: [c_int; SI_PAD], + _pid: crate::pid_t, + _uid: crate::uid_t, + value: crate::sigval, } + (*(self as *const siginfo_t).cast::()).value + } +} - impl Eq for mount_info {} - - impl hash::Hash for mount_info { - fn hash(&self, state: &mut H) { - unsafe { self.align.hash(state) }; - } - } +s_no_extra_traits! { + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_flags: c_short, + pub ifru_metric: c_int, + pub ifru_vnetid: i64, + pub ifru_media: u64, + pub ifru_data: crate::caddr_t, + pub ifru_index: c_uint, + } +} +cfg_if! { + if #[cfg(feature = "extra_traits")] { impl PartialEq for __c_anonymous_ifr_ifru { fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { unsafe { @@ -931,78 +816,6 @@ cfg_if! { } } } - - impl PartialEq for statfs { - fn eq(&self, other: &statfs) -> bool { - self.f_flags == other.f_flags - && self.f_bsize == other.f_bsize - && self.f_iosize == other.f_iosize - && self.f_blocks == other.f_blocks - && self.f_bfree == other.f_bfree - && self.f_bavail == other.f_bavail - && self.f_files == other.f_files - && self.f_ffree == other.f_ffree - && self.f_favail == other.f_favail - && self.f_syncwrites == other.f_syncwrites - && self.f_syncreads == other.f_syncreads - && self.f_asyncwrites == other.f_asyncwrites - && self.f_asyncreads == other.f_asyncreads - && self.f_fsid == other.f_fsid - && self.f_namemax == other.f_namemax - && self.f_owner == other.f_owner - && self.f_ctime == other.f_ctime - && self - .f_fstypename - .iter() - .zip(other.f_fstypename.iter()) - .all(|(a, b)| a == b) - && self - .f_mntonname - .iter() - .zip(other.f_mntonname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntfromname - .iter() - .zip(other.f_mntfromname.iter()) - .all(|(a, b)| a == b) - && self - .f_mntfromspec - .iter() - .zip(other.f_mntfromspec.iter()) - .all(|(a, b)| a == b) - && self.mount_info == other.mount_info - } - } - - impl Eq for statfs {} - - impl hash::Hash for statfs { - fn hash(&self, state: &mut H) { - self.f_flags.hash(state); - self.f_bsize.hash(state); - self.f_iosize.hash(state); - self.f_blocks.hash(state); - self.f_bfree.hash(state); - self.f_bavail.hash(state); - self.f_files.hash(state); - self.f_ffree.hash(state); - self.f_favail.hash(state); - self.f_syncwrites.hash(state); - self.f_syncreads.hash(state); - self.f_asyncwrites.hash(state); - self.f_asyncreads.hash(state); - self.f_fsid.hash(state); - self.f_namemax.hash(state); - self.f_owner.hash(state); - self.f_ctime.hash(state); - self.f_fstypename.hash(state); - self.f_mntonname.hash(state); - self.f_mntfromname.hash(state); - self.f_mntfromspec.hash(state); - self.mount_info.hash(state); - } - } } } diff --git a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs index 984570c387013..4abe8a1a7c5ed 100644 --- a/src/unix/bsd/netbsdlike/openbsd/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsd/x86_64.rs @@ -36,9 +36,7 @@ s! { pub sc_mask: c_int, pub sc_cookie: c_long, } -} -s_no_extra_traits! { #[repr(packed)] pub struct fxsave64 { pub fx_fcw: u16, @@ -56,48 +54,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - // `fxsave64` is packed, so field access is unaligned. - // use {x} to create temporary storage, copy field to it, and do aligned access. - impl PartialEq for fxsave64 { - fn eq(&self, other: &fxsave64) -> bool { - return { self.fx_fcw } == { other.fx_fcw } - && { self.fx_fsw } == { other.fx_fsw } - && { self.fx_ftw } == { other.fx_ftw } - && { self.fx_fop } == { other.fx_fop } - && { self.fx_rip } == { other.fx_rip } - && { self.fx_rdp } == { other.fx_rdp } - && { self.fx_mxcsr } == { other.fx_mxcsr } - && { self.fx_mxcsr_mask } == { other.fx_mxcsr_mask } - && { self.fx_st } - .iter() - .zip({ other.fx_st }.iter()) - .all(|(a, b)| a == b) - && { self.fx_xmm } - .iter() - .zip({ other.fx_xmm }.iter()) - .all(|(a, b)| a == b); - } - } - impl Eq for fxsave64 {} - impl hash::Hash for fxsave64 { - fn hash(&self, state: &mut H) { - { self.fx_fcw }.hash(state); - { self.fx_fsw }.hash(state); - { self.fx_ftw }.hash(state); - { self.fx_fop }.hash(state); - { self.fx_rip }.hash(state); - { self.fx_rdp }.hash(state); - { self.fx_mxcsr }.hash(state); - { self.fx_mxcsr_mask }.hash(state); - { self.fx_st }.hash(state); - { self.fx_xmm }.hash(state); - } - } - } -} - pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; pub const _MAX_PAGE_SHIFT: u32 = 12; diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 0e5faff17fb8f..6dee1217953cc 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -440,12 +440,19 @@ s! { pub f_namelen: c_long, pub f_spare: [c_long; 6], } -} -s_no_extra_traits! { - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4], + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct utsname { + pub sysname: [c_char; 66], + pub nodename: [c_char; 65], + pub release: [c_char; 65], + pub version: [c_char; 65], + pub machine: [c_char; 65], + pub domainname: [c_char; 65], } pub struct siginfo_t { @@ -457,6 +464,22 @@ s_no_extra_traits! { __pad: [u32; 32], } + pub struct dirent { + __d_version: u32, + pub d_ino: ino_t, + pub d_type: c_uchar, + __d_unused1: [c_uchar; 3], + __d_internal1: u32, + pub d_name: [c_char; 256], + } +} + +s_no_extra_traits! { + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } + pub union __c_anonymous_ifr_ifru { pub ifru_addr: sockaddr, pub ifru_broadaddr: sockaddr, @@ -486,29 +509,6 @@ s_no_extra_traits! { pub ifc_len: c_int, pub ifc_ifcu: __c_anonymous_ifc_ifcu, } - - pub struct dirent { - __d_version: u32, - pub d_ino: ino_t, - pub d_type: c_uchar, - __d_unused1: [c_uchar; 3], - __d_internal1: u32, - pub d_name: [c_char; 256], - } - - pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [c_char; 108], - } - - pub struct utsname { - pub sysname: [c_char; 66], - pub nodename: [c_char; 65], - pub release: [c_char; 65], - pub version: [c_char; 65], - pub machine: [c_char; 65], - pub domainname: [c_char; 65], - } } impl siginfo_t { @@ -560,122 +560,6 @@ impl siginfo_t { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for siginfo_t { - fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo - && self.si_code == other.si_code - && self.si_pid == other.si_pid - && self.si_uid == other.si_uid - && self.si_errno == other.si_errno - } - } - - impl Eq for siginfo_t {} - - impl hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { - self.si_signo.hash(state); - self.si_code.hash(state); - self.si_pid.hash(state); - self.si_uid.hash(state); - self.si_errno.hash(state); - // Ignore __pad - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_un {} - - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - && self - .domainname - .iter() - .zip(other.domainname.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utsname {} - - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - self.domainname.hash(state); - } - } - } -} - pub const FD_SETSIZE: usize = 1024; pub const CPU_SETSIZE: c_int = 0x400; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index e234926c0a9d6..7bea75978d535 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -457,9 +457,7 @@ s! { pub flag: *mut c_int, pub val: c_int, } -} -s_no_extra_traits! { pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, @@ -501,132 +499,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_tv == other.ut_tv - && self.ut_id == other.ut_id - && self.ut_pid == other.ut_pid - && self.ut_user == other.ut_user - && self.ut_line == other.ut_line - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.__ut_reserved == other.__ut_reserved - } - } - - impl Eq for utmpx {} - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_tv.hash(state); - self.ut_id.hash(state); - self.ut_pid.hash(state); - self.ut_user.hash(state); - self.ut_line.hash(state); - self.ut_host.hash(state); - self.__ut_reserved.hash(state); - } - } - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_len == other.sun_len - && self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_un {} - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_len.hash(state); - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self - .__ss_pad1 - .iter() - .zip(other.__ss_pad1.iter()) - .all(|(a, b)| a == b) - && self.__ss_pad2 == other.__ss_pad2 - && self - .__ss_pad3 - .iter() - .zip(other.__ss_pad3.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_pad2.hash(state); - self.__ss_pad3.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_dev == other.d_dev - && self.d_pdev == other.d_pdev - && self.d_ino == other.d_ino - && self.d_pino == other.d_pino - && self.d_reclen == other.d_reclen - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_dev.hash(state); - self.d_pdev.hash(state); - self.d_ino.hash(state); - self.d_pino.hash(state); - self.d_reclen.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - && self.sigev_notify_attributes == other.sigev_notify_attributes - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - self.sigev_notify_attributes.hash(state); - } - } - } -} - pub const EXIT_FAILURE: c_int = 1; pub const EXIT_SUCCESS: c_int = 0; pub const RAND_MAX: c_int = 2147483647; diff --git a/src/unix/haiku/native.rs b/src/unix/haiku/native.rs index 13a203f92ff56..6c7f69acbd4ee 100644 --- a/src/unix/haiku/native.rs +++ b/src/unix/haiku/native.rs @@ -451,6 +451,13 @@ s! { pub edx: u32, pub ecx: u32, } + + pub struct cpu_topology_node_info { + pub id: u32, + pub type_: topology_level_type, + pub level: u32, + pub data: __c_anonymous_cpu_topology_info_data, + } } s_no_extra_traits! { @@ -468,13 +475,6 @@ s_no_extra_traits! { pub package: cpu_topology_package_info, pub core: cpu_topology_core_info, } - - pub struct cpu_topology_node_info { - pub id: u32, - pub type_: topology_level_type, - pub level: u32, - pub data: __c_anonymous_cpu_topology_info_data, - } } cfg_if! { @@ -492,6 +492,11 @@ cfg_if! { } } impl Eq for cpuid_info {} + impl hash::Hash for cpuid_info { + fn hash(&self, _state: &mut H) { + unimplemented!("traits"); + } + } impl PartialEq for __c_anonymous_cpu_topology_info_data { fn eq(&self, other: &__c_anonymous_cpu_topology_info_data) -> bool { @@ -503,14 +508,11 @@ cfg_if! { } } impl Eq for __c_anonymous_cpu_topology_info_data {} - - impl PartialEq for cpu_topology_node_info { - fn eq(&self, other: &cpu_topology_node_info) -> bool { - self.id == other.id && self.type_ == other.type_ && self.level == other.level + impl hash::Hash for __c_anonymous_cpu_topology_info_data { + fn hash(&self, _state: &mut H) { + unimplemented!("traits"); } } - - impl Eq for cpu_topology_node_info {} } } diff --git a/src/unix/haiku/x86_64.rs b/src/unix/haiku/x86_64.rs index 16e2612ed760d..538ae30d438bf 100644 --- a/src/unix/haiku/x86_64.rs +++ b/src/unix/haiku/x86_64.rs @@ -1,6 +1,6 @@ use crate::prelude::*; -s_no_extra_traits! { +s! { pub struct fpu_state { pub control: c_ushort, pub status: c_ushort, @@ -56,153 +56,3 @@ s_no_extra_traits! { pub uc_mcontext: mcontext_t, } } - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for fpu_state { - fn eq(&self, other: &fpu_state) -> bool { - self.control == other.control - && self.status == other.status - && self.tag == other.tag - && self.opcode == other.opcode - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mscsr_mask == other.mscsr_mask - && self - ._fpreg - .iter() - .zip(other._fpreg.iter()) - .all(|(a, b)| a == b) - && self._xmm.iter().zip(other._xmm.iter()).all(|(a, b)| a == b) - && self - ._reserved_416_511 - .iter() - .zip(other._reserved_416_511.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for fpu_state {} - impl hash::Hash for fpu_state { - fn hash(&self, state: &mut H) { - self.control.hash(state); - self.status.hash(state); - self.tag.hash(state); - self.opcode.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mscsr_mask.hash(state); - self._fpreg.hash(state); - self._xmm.hash(state); - self._reserved_416_511.hash(state); - } - } - - impl PartialEq for xstate_hdr { - fn eq(&self, other: &xstate_hdr) -> bool { - self.bv == other.bv - && self.xcomp_bv == other.xcomp_bv - && self - ._reserved - .iter() - .zip(other._reserved.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for xstate_hdr {} - impl hash::Hash for xstate_hdr { - fn hash(&self, state: &mut H) { - self.bv.hash(state); - self.xcomp_bv.hash(state); - self._reserved.hash(state); - } - } - - impl PartialEq for savefpu { - fn eq(&self, other: &savefpu) -> bool { - self.fp_fxsave == other.fp_fxsave - && self.fp_xstate == other.fp_xstate - && self - ._fp_ymm - .iter() - .zip(other._fp_ymm.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for savefpu {} - impl hash::Hash for savefpu { - fn hash(&self, state: &mut H) { - self.fp_fxsave.hash(state); - self.fp_xstate.hash(state); - self._fp_ymm.hash(state); - } - } - - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.rax == other.rax - && self.rbx == other.rbx - && self.rbx == other.rbx - && self.rcx == other.rcx - && self.rdx == other.rdx - && self.rdi == other.rdi - && self.rsi == other.rsi - && self.r8 == other.r8 - && self.r9 == other.r9 - && self.r10 == other.r10 - && self.r11 == other.r11 - && self.r12 == other.r12 - && self.r13 == other.r13 - && self.r14 == other.r14 - && self.r15 == other.r15 - && self.rsp == other.rsp - && self.rip == other.rip - && self.rflags == other.rflags - && self.fpu == other.fpu - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.rax.hash(state); - self.rbx.hash(state); - self.rcx.hash(state); - self.rdx.hash(state); - self.rdi.hash(state); - self.rsi.hash(state); - self.rbp.hash(state); - self.r8.hash(state); - self.r9.hash(state); - self.r10.hash(state); - self.r11.hash(state); - self.r12.hash(state); - self.r13.hash(state); - self.r14.hash(state); - self.r15.hash(state); - self.rsp.hash(state); - self.rip.hash(state); - self.rflags.hash(state); - self.fpu.hash(state); - } - } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_link == other.uc_link - && self.uc_sigmask == other.uc_sigmask - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_link.hash(state); - self.uc_sigmask.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - } - } - } -} diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index d88f6f933e18a..3760b2fa734ac 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -1019,9 +1019,7 @@ s! { pub flag: *mut c_int, pub val: c_int, } -} -s_no_extra_traits! { pub struct utmpx { pub ut_type: c_short, pub ut_pid: crate::pid_t, @@ -1047,48 +1045,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_user == other.ut_user - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_addr_v6 == other.ut_addr_v6 - && self.__glibc_reserved == other.__glibc_reserved - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_user.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_addr_v6.hash(state); - self.__glibc_reserved.hash(state); - } - } - } -} - impl siginfo_t { pub unsafe fn si_addr(&self) -> *mut c_void { self.si_addr diff --git a/src/unix/linux_like/android/b32/arm.rs b/src/unix/linux_like/android/b32/arm.rs index b78c8a83623ea..7fb2ff663bcac 100644 --- a/src/unix/linux_like/android/b32/arm.rs +++ b/src/unix/linux_like/android/b32/arm.rs @@ -28,20 +28,13 @@ s! { pub arm_cpsr: c_ulong, pub fault_address: c_ulong, } -} -s_no_extra_traits! { pub struct __c_anonymous_uc_sigmask_with_padding { pub uc_sigmask: crate::sigset_t, /* Android has a wrong (smaller) sigset_t on x86. */ __padding_rt_sigset: u32, } - pub union __c_anonymous_uc_sigmask { - uc_sigmask: __c_anonymous_uc_sigmask_with_padding, - uc_sigmask64: crate::sigset64_t, - } - pub struct ucontext_t { pub uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -56,22 +49,15 @@ s_no_extra_traits! { } } +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: __c_anonymous_uc_sigmask_with_padding, + uc_sigmask64: crate::sigset64_t, + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask_with_padding { - fn eq(&self, other: &__c_anonymous_uc_sigmask_with_padding) -> bool { - self.uc_sigmask == other.uc_sigmask - // Ignore padding - } - } - impl Eq for __c_anonymous_uc_sigmask_with_padding {} - impl hash::Hash for __c_anonymous_uc_sigmask_with_padding { - fn hash(&self, state: &mut H) { - self.uc_sigmask.hash(state) - // Ignore padding - } - } - impl PartialEq for __c_anonymous_uc_sigmask { fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { unsafe { self.uc_sigmask == other.uc_sigmask } @@ -83,30 +69,6 @@ cfg_if! { unsafe { self.uc_sigmask.hash(state) } } } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &Self) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask__c_anonymous_union == other.uc_sigmask__c_anonymous_union - && &self.uc_regspace[..] == &other.uc_regspace[..] - // Ignore padding field - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask__c_anonymous_union.hash(state); - self.uc_regspace[..].hash(state); - // Ignore padding field - } - } } } diff --git a/src/unix/linux_like/android/b32/x86/mod.rs b/src/unix/linux_like/android/b32/x86/mod.rs index ca46c3c462246..22a8766e88bb3 100644 --- a/src/unix/linux_like/android/b32/x86/mod.rs +++ b/src/unix/linux_like/android/b32/x86/mod.rs @@ -27,20 +27,13 @@ s! { pub oldmask: c_ulong, pub cr2: c_ulong, } -} -s_no_extra_traits! { pub struct __c_anonymous_uc_sigmask_with_padding { pub uc_sigmask: crate::sigset_t, /* Android has a wrong (smaller) sigset_t on x86. */ __padding_rt_sigset: u32, } - pub union __c_anonymous_uc_sigmask { - uc_sigmask: __c_anonymous_uc_sigmask_with_padding, - uc_sigmask64: crate::sigset64_t, - } - pub struct ucontext_t { pub uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -50,6 +43,13 @@ s_no_extra_traits! { __padding_rt_sigset: u32, __fpregs_mem: _libc_fpstate, } +} + +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: __c_anonymous_uc_sigmask_with_padding, + uc_sigmask64: crate::sigset64_t, + } #[repr(align(8))] pub struct max_align_t { @@ -59,20 +59,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask_with_padding { - fn eq(&self, other: &__c_anonymous_uc_sigmask_with_padding) -> bool { - self.uc_sigmask == other.uc_sigmask - // Ignore padding - } - } - impl Eq for __c_anonymous_uc_sigmask_with_padding {} - impl hash::Hash for __c_anonymous_uc_sigmask_with_padding { - fn hash(&self, state: &mut H) { - self.uc_sigmask.hash(state) - // Ignore padding - } - } - impl PartialEq for __c_anonymous_uc_sigmask { fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { unsafe { self.uc_sigmask == other.uc_sigmask } @@ -84,28 +70,6 @@ cfg_if! { unsafe { self.uc_sigmask.hash(state) } } } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &Self) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask__c_anonymous_union == other.uc_sigmask__c_anonymous_union - // Ignore padding field - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask__c_anonymous_union.hash(state); - // Ignore padding field - } - } } } diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index 46ceed4c6dcba..7d5baef752e44 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -115,9 +115,7 @@ s! { pub struct pthread_spinlock_t { __private: i64, } -} -s_no_extra_traits! { pub struct pthread_mutex_t { value: c_int, __reserved: [c_char; 36], @@ -142,78 +140,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.value == other.value - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for pthread_mutex_t {} - - impl hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.value.hash(state); - self.__reserved.hash(state); - } - } - - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.value == other.value - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for pthread_cond_t {} - - impl hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.value.hash(state); - self.__reserved.hash(state); - } - } - - impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.numLocks == other.numLocks - && self.writerThreadId == other.writerThreadId - && self.pendingReaders == other.pendingReaders - && self.pendingWriters == other.pendingWriters - && self.attr == other.attr - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for pthread_rwlock_t {} - - impl hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.numLocks.hash(state); - self.writerThreadId.hash(state); - self.pendingReaders.hash(state); - self.pendingWriters.hash(state); - self.attr.hash(state); - self.__reserved.hash(state); - } - } - } -} - // These constants must be of the same type of sigaction.sa_flags pub const SA_NOCLDSTOP: c_int = 0x00000001; pub const SA_NOCLDWAIT: c_int = 0x00000002; diff --git a/src/unix/linux_like/android/b64/x86_64/mod.rs b/src/unix/linux_like/android/b64/x86_64/mod.rs index 0fddeb7bc267f..fd678d1f11108 100644 --- a/src/unix/linux_like/android/b64/x86_64/mod.rs +++ b/src/unix/linux_like/android/b64/x86_64/mod.rs @@ -104,37 +104,7 @@ s! { pub error_code: c_ulong, pub fault_address: c_ulong, } -} - -s_no_extra_traits! { - pub union __c_anonymous_uc_sigmask { - uc_sigmask: crate::sigset_t, - uc_sigmask64: crate::sigset64_t, - } - #[repr(align(16))] - pub struct max_align_t { - priv_: [f64; 4], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_uc_sigmask { - fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { - unsafe { self.uc_sigmask == other.uc_sigmask } - } - } - impl Eq for __c_anonymous_uc_sigmask {} - impl hash::Hash for __c_anonymous_uc_sigmask { - fn hash(&self, state: &mut H) { - unsafe { self.uc_sigmask.hash(state) } - } - } - } -} - -s_no_extra_traits! { pub struct _libc_fpxreg { pub significand: [u16; 4], pub exponent: u16, @@ -185,127 +155,29 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for _libc_fpxreg { - fn eq(&self, other: &Self) -> bool { - self.significand == other.significand && self.exponent == other.exponent - // Ignore padding field - } - } - impl Eq for _libc_fpxreg {} - impl hash::Hash for _libc_fpxreg { - fn hash(&self, state: &mut H) { - self.significand.hash(state); - self.exponent.hash(state); - // Ignore padding field - } - } - - impl PartialEq for _libc_fpstate { - fn eq(&self, other: &Self) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.ftw == other.ftw - && self.fop == other.fop - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mxcr_mask == other.mxcr_mask - && self._st == other._st - && self._xmm == other._xmm - // Ignore padding field - } - } - impl Eq for _libc_fpstate {} - impl hash::Hash for _libc_fpstate { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.swd.hash(state); - self.ftw.hash(state); - self.fop.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mxcr_mask.hash(state); - self._st.hash(state); - self._xmm.hash(state); - // Ignore padding field - } - } - - impl PartialEq for mcontext_t { - fn eq(&self, other: &Self) -> bool { - self.gregs == other.gregs && self.fpregs == other.fpregs - // Ignore padding field - } - } - impl Eq for mcontext_t {} - impl hash::Hash for mcontext_t { - fn hash(&self, state: &mut H) { - self.gregs.hash(state); - self.fpregs.hash(state); - // Ignore padding field - } - } +s_no_extra_traits! { + pub union __c_anonymous_uc_sigmask { + uc_sigmask: crate::sigset_t, + uc_sigmask64: crate::sigset64_t, + } - impl PartialEq for ucontext_t { - fn eq(&self, other: &Self) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask64 == other.uc_sigmask64 - // Ignore padding field - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask64.hash(state); - // Ignore padding field - } - } + #[repr(align(16))] + pub struct max_align_t { + priv_: [f64; 4], + } +} - impl PartialEq for user_fpregs_struct { - fn eq(&self, other: &user_fpregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.ftw == other.ftw - && self.fop == other.fop - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mxcr_mask == other.mxcr_mask - && self.st_space == other.st_space - && self - .xmm_space - .iter() - .zip(other.xmm_space.iter()) - .all(|(a, b)| a == b) - // Ignore padding field +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_uc_sigmask { + fn eq(&self, other: &__c_anonymous_uc_sigmask) -> bool { + unsafe { self.uc_sigmask == other.uc_sigmask } } } - - impl Eq for user_fpregs_struct {} - - impl hash::Hash for user_fpregs_struct { + impl Eq for __c_anonymous_uc_sigmask {} + impl hash::Hash for __c_anonymous_uc_sigmask { fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.swd.hash(state); - self.ftw.hash(state); - self.fop.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mxcr_mask.hash(state); - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field + unsafe { self.uc_sigmask.hash(state) } } } } diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 6dab111402978..f9362fd5e1157 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -500,9 +500,7 @@ s! { pub if_index: c_uint, pub if_name: *mut c_char, } -} -s_no_extra_traits! { pub struct sockaddr_nl { pub nl_family: crate::sa_family_t, nl_pad: c_ushort, @@ -578,16 +576,18 @@ s_no_extra_traits! { pub absflat: [crate::__s32; ABS_CNT], } - pub struct af_alg_iv { - pub ivlen: u32, - pub iv: [c_uchar; 0], - } - pub struct prop_info { __name: [c_char; 32], __serial: c_uint, __value: [c_char; 92], } +} + +s_no_extra_traits! { + pub struct af_alg_iv { + pub ivlen: u32, + pub iv: [c_uchar; 0], + } pub union __c_anonymous_ifr_ifru { pub ifru_addr: crate::sockaddr, @@ -622,253 +622,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for sockaddr_nl { - fn eq(&self, other: &sockaddr_nl) -> bool { - self.nl_family == other.nl_family - && self.nl_pid == other.nl_pid - && self.nl_groups == other.nl_groups - } - } - impl Eq for sockaddr_nl {} - impl hash::Hash for sockaddr_nl { - fn hash(&self, state: &mut H) { - self.nl_family.hash(state); - self.nl_pid.hash(state); - self.nl_groups.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for dirent64 { - fn eq(&self, other: &dirent64) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent64 {} - - impl hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for siginfo_t { - fn eq(&self, other: &siginfo_t) -> bool { - self.si_signo == other.si_signo - && self.si_errno == other.si_errno - && self.si_code == other.si_code - // Ignore _pad - // Ignore _align - } - } - - impl Eq for siginfo_t {} - - impl hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { - self.si_signo.hash(state); - self.si_errno.hash(state); - self.si_code.hash(state); - // Ignore _pad - // Ignore _align - } - } - - impl PartialEq for lastlog { - fn eq(&self, other: &lastlog) -> bool { - self.ll_time == other.ll_time - && self - .ll_line - .iter() - .zip(other.ll_line.iter()) - .all(|(a, b)| a == b) - && self - .ll_host - .iter() - .zip(other.ll_host.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for lastlog {} - - impl hash::Hash for lastlog { - fn hash(&self, state: &mut H) { - self.ll_time.hash(state); - self.ll_line.hash(state); - self.ll_host.hash(state); - } - } - - impl PartialEq for utmp { - fn eq(&self, other: &utmp) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self - .ut_line - .iter() - .zip(other.ut_line.iter()) - .all(|(a, b)| a == b) - && self.ut_id == other.ut_id - && self - .ut_user - .iter() - .zip(other.ut_user.iter()) - .all(|(a, b)| a == b) - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_addr_v6 == other.ut_addr_v6 - && self.unused == other.unused - } - } - - impl Eq for utmp {} - - impl hash::Hash for utmp { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_user.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_addr_v6.hash(state); - self.unused.hash(state); - } - } - - impl PartialEq for sockaddr_alg { - fn eq(&self, other: &sockaddr_alg) -> bool { - self.salg_family == other.salg_family - && self - .salg_type - .iter() - .zip(other.salg_type.iter()) - .all(|(a, b)| a == b) - && self.salg_feat == other.salg_feat - && self.salg_mask == other.salg_mask - && self - .salg_name - .iter() - .zip(other.salg_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_alg {} - - impl hash::Hash for sockaddr_alg { - fn hash(&self, state: &mut H) { - self.salg_family.hash(state); - self.salg_type.hash(state); - self.salg_feat.hash(state); - self.salg_mask.hash(state); - self.salg_name.hash(state); - } - } - - impl PartialEq for uinput_setup { - fn eq(&self, other: &uinput_setup) -> bool { - self.id == other.id - && self.name[..] == other.name[..] - && self.ff_effects_max == other.ff_effects_max - } - } - impl Eq for uinput_setup {} - - impl hash::Hash for uinput_setup { - fn hash(&self, state: &mut H) { - self.id.hash(state); - self.name.hash(state); - self.ff_effects_max.hash(state); - } - } - - impl PartialEq for uinput_user_dev { - fn eq(&self, other: &uinput_user_dev) -> bool { - self.name[..] == other.name[..] - && self.id == other.id - && self.ff_effects_max == other.ff_effects_max - && self.absmax[..] == other.absmax[..] - && self.absmin[..] == other.absmin[..] - && self.absfuzz[..] == other.absfuzz[..] - && self.absflat[..] == other.absflat[..] - } - } - impl Eq for uinput_user_dev {} - - impl hash::Hash for uinput_user_dev { - fn hash(&self, state: &mut H) { - self.name.hash(state); - self.id.hash(state); - self.ff_effects_max.hash(state); - self.absmax.hash(state); - self.absmin.hash(state); - self.absfuzz.hash(state); - self.absflat.hash(state); - } - } - - impl PartialEq for prop_info { - fn eq(&self, other: &prop_info) -> bool { - self.__name == other.__name - && self.__serial == other.__serial - && self.__value == other.__value - } - } - impl Eq for prop_info {} - } -} - pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MS_NOUSER: c_ulong = 0xffffffff80000000; pub const MS_RMT_MASK: c_ulong = 0x02800051; diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 91e506c57cc22..306cf180e5c0b 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -334,9 +334,7 @@ s! { pub struct pthread_condattr_t { size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], } -} -s_no_extra_traits! { pub struct dirent { pub d_ino: crate::ino_t, pub d_off: off_t, @@ -375,113 +373,15 @@ s_no_extra_traits! { pub struct pthread_cond_t { size: [u8; crate::__SIZEOF_PTHREAD_COND_T], } +} +s_no_extra_traits! { #[repr(align(8))] pub struct max_align_t { priv_: [f64; 3], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for dirent {} - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sysinfo { - fn eq(&self, other: &sysinfo) -> bool { - self.uptime == other.uptime - && self.loads == other.loads - && self.totalram == other.totalram - && self.freeram == other.freeram - && self.sharedram == other.sharedram - && self.bufferram == other.bufferram - && self.totalswap == other.totalswap - && self.freeswap == other.freeswap - && self.procs == other.procs - && self.pad == other.pad - && self.totalhigh == other.totalhigh - && self.freehigh == other.freehigh - && self.mem_unit == other.mem_unit - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sysinfo {} - impl hash::Hash for sysinfo { - fn hash(&self, state: &mut H) { - self.uptime.hash(state); - self.loads.hash(state); - self.totalram.hash(state); - self.freeram.hash(state); - self.sharedram.hash(state); - self.bufferram.hash(state); - self.totalswap.hash(state); - self.freeswap.hash(state); - self.procs.hash(state); - self.pad.hash(state); - self.totalhigh.hash(state); - self.freehigh.hash(state); - self.mem_unit.hash(state); - self.__reserved.hash(state); - } - } - - impl PartialEq for mq_attr { - fn eq(&self, other: &mq_attr) -> bool { - self.mq_flags == other.mq_flags - && self.mq_maxmsg == other.mq_maxmsg - && self.mq_msgsize == other.mq_msgsize - && self.mq_curmsgs == other.mq_curmsgs - } - } - impl Eq for mq_attr {} - impl hash::Hash for mq_attr { - fn hash(&self, state: &mut H) { - self.mq_flags.hash(state); - self.mq_maxmsg.hash(state); - self.mq_msgsize.hash(state); - self.mq_curmsgs.hash(state); - } - } - - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - impl Eq for pthread_cond_t {} - impl hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - } -} - pub const MADV_SOFT_OFFLINE: c_int = 101; pub const MS_NOUSER: c_ulong = 0x80000000; pub const MS_RMT_MASK: c_ulong = 0x02800051; diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 0f7181e2aee1a..40d90159553a9 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -232,13 +232,6 @@ s! { pub arm_cpsr: c_ulong, pub arm_orig_r0: c_ulong, } -} - -s_no_extra_traits! { - #[repr(align(8))] - pub struct max_align_t { - priv_: [i64; 2], - } #[repr(align(8))] pub struct ucontext_t { @@ -251,27 +244,10 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - } - } +s_no_extra_traits! { + #[repr(align(8))] + pub struct max_align_t { + priv_: [i64; 2], } } diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index 26a95f85972f1..4882acb8fd0e2 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -261,9 +261,7 @@ s! { pub ss_flags: c_int, pub ss_size: size_t, } -} -s_no_extra_traits! { pub struct user_fpxregs_struct { pub cwd: c_ushort, pub swd: c_ushort, @@ -289,79 +287,15 @@ s_no_extra_traits! { __private: [u8; 112], __ssp: [c_ulong; 4], } +} +s_no_extra_traits! { #[repr(align(16))] pub struct max_align_t { priv_: [f64; 6], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for user_fpxregs_struct { - fn eq(&self, other: &user_fpxregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.twd == other.twd - && self.fop == other.fop - && self.fip == other.fip - && self.fcs == other.fcs - && self.foo == other.foo - && self.fos == other.fos - && self.mxcsr == other.mxcsr - // Ignore __reserved field - && self.st_space == other.st_space - && self.xmm_space == other.xmm_space - // Ignore padding field - } - } - - impl Eq for user_fpxregs_struct {} - - impl hash::Hash for user_fpxregs_struct { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.swd.hash(state); - self.twd.hash(state); - self.fop.hash(state); - self.fip.hash(state); - self.fcs.hash(state); - self.foo.hash(state); - self.fos.hash(state); - self.mxcsr.hash(state); - // Ignore __reserved field - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field - } - } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - // Ignore __private field - } - } - - impl Eq for ucontext_t {} - - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - // Ignore __private field - } - } - } -} - pub const VEOF: usize = 4; pub const RTLD_DEEPBIND: c_int = 0x8; pub const RTLD_GLOBAL: c_int = 0x100; diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index e100871275776..f58d8bba480f8 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -289,9 +289,7 @@ s! { pub set_tid_size: c_ulonglong, pub cgroup: c_ulonglong, } -} -s_no_extra_traits! { pub struct user_fpregs_struct { pub cwd: c_ushort, pub swd: c_ushort, @@ -315,78 +313,15 @@ s_no_extra_traits! { __private: [u8; 512], __ssp: [c_ulonglong; 4], } +} +s_no_extra_traits! { #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for user_fpregs_struct { - fn eq(&self, other: &user_fpregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.ftw == other.ftw - && self.fop == other.fop - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mxcr_mask == other.mxcr_mask - && self.st_space == other.st_space - && self - .xmm_space - .iter() - .zip(other.xmm_space.iter()) - .all(|(a, b)| a == b) - // Ignore padding field - } - } - - impl Eq for user_fpregs_struct {} - - impl hash::Hash for user_fpregs_struct { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.ftw.hash(state); - self.fop.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mxcr_mask.hash(state); - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field - } - } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - // Ignore __private field - } - } - - impl Eq for ucontext_t {} - - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - // Ignore __private field - } - } - } -} - pub const POSIX_FADV_DONTNEED: c_int = 4; pub const POSIX_FADV_NOREUSE: c_int = 5; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 93f3a94d94cf4..0ac59d5b8eb0c 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -328,6 +328,50 @@ s! { #[cfg(all(gnu_time_bits64, target_endian = "little"))] __pad: i32, } + + pub struct utmpx { + pub ut_type: c_short, + pub ut_pid: crate::pid_t, + pub ut_line: [c_char; __UT_LINESIZE], + pub ut_id: [c_char; 4], + + pub ut_user: [c_char; __UT_NAMESIZE], + pub ut_host: [c_char; __UT_HOSTSIZE], + pub ut_exit: __exit_status, + + #[cfg(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + ))] + pub ut_session: c_long, + #[cfg(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + ))] + pub ut_tv: crate::timeval, + + #[cfg(not(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + )))] + pub ut_session: i32, + #[cfg(not(any( + target_arch = "aarch64", + target_arch = "s390x", + target_arch = "loongarch64", + all(target_pointer_width = "32", not(target_arch = "x86_64")) + )))] + pub ut_tv: __timeval, + + pub ut_addr_v6: [i32; 4], + __glibc_reserved: [c_char; 20], + } } impl siginfo_t { @@ -445,92 +489,10 @@ s_no_extra_traits! { pub exit: __c_anonymous_ptrace_syscall_info_exit, pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, } - - pub struct utmpx { - pub ut_type: c_short, - pub ut_pid: crate::pid_t, - pub ut_line: [c_char; __UT_LINESIZE], - pub ut_id: [c_char; 4], - - pub ut_user: [c_char; __UT_NAMESIZE], - pub ut_host: [c_char; __UT_HOSTSIZE], - pub ut_exit: __exit_status, - - #[cfg(any( - target_arch = "aarch64", - target_arch = "s390x", - target_arch = "loongarch64", - all(target_pointer_width = "32", not(target_arch = "x86_64")) - ))] - pub ut_session: c_long, - #[cfg(any( - target_arch = "aarch64", - target_arch = "s390x", - target_arch = "loongarch64", - all(target_pointer_width = "32", not(target_arch = "x86_64")) - ))] - pub ut_tv: crate::timeval, - - #[cfg(not(any( - target_arch = "aarch64", - target_arch = "s390x", - target_arch = "loongarch64", - all(target_pointer_width = "32", not(target_arch = "x86_64")) - )))] - pub ut_session: i32, - #[cfg(not(any( - target_arch = "aarch64", - target_arch = "s390x", - target_arch = "loongarch64", - all(target_pointer_width = "32", not(target_arch = "x86_64")) - )))] - pub ut_tv: __timeval, - - pub ut_addr_v6: [i32; 4], - __glibc_reserved: [c_char; 20], - } } cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_user == other.ut_user - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_addr_v6 == other.ut_addr_v6 - && self.__glibc_reserved == other.__glibc_reserved - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_user.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_addr_v6.hash(state); - self.__glibc_reserved.hash(state); - } - } - impl PartialEq for __c_anonymous_ptrace_syscall_info_data { fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool { unsafe { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 95155996663ae..2f638ae8def3c 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1366,46 +1366,7 @@ s! { pub token_start: crate::__u32, pub token_count: crate::__u32, } -} - -cfg_if! { - if #[cfg(not(target_arch = "sparc64"))] { - s! { - pub struct iw_thrspy { - pub addr: crate::sockaddr, - pub qual: iw_quality, - pub low: iw_quality, - pub high: iw_quality, - } - - pub struct iw_mlme { - pub cmd: __u16, - pub reason_code: __u16, - pub addr: crate::sockaddr, - } - - pub struct iw_michaelmicfailure { - pub flags: __u32, - pub src_addr: crate::sockaddr, - pub tsc: [__u8; IW_ENCODE_SEQ_MAX_SIZE], - } - - pub struct __c_anonymous_elf32_rela { - pub r_offset: Elf32_Addr, - pub r_info: Elf32_Word, - pub r_addend: Elf32_Sword, - } - - pub struct __c_anonymous_elf64_rela { - pub r_offset: Elf64_Addr, - pub r_info: Elf64_Xword, - pub r_addend: Elf64_Sxword, - } - } - } -} -s_no_extra_traits! { pub struct sockaddr_nl { pub nl_family: crate::sa_family_t, nl_pad: c_ushort, @@ -1421,6 +1382,14 @@ s_no_extra_traits! { pub d_name: [c_char; 256], } + pub struct dirent64 { + pub d_ino: crate::ino64_t, + pub d_off: off64_t, + pub d_reclen: c_ushort, + pub d_type: c_uchar, + pub d_name: [c_char; 256], + } + pub struct sockaddr_alg { pub salg_family: crate::sa_family_t, pub salg_type: [c_uchar; 14], @@ -1445,11 +1414,6 @@ s_no_extra_traits! { pub absflat: [__s32; ABS_CNT], } - pub struct af_alg_iv { - pub ivlen: u32, - pub iv: [c_uchar; 0], - } - // x32 compatibility // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 pub struct mq_attr { @@ -1476,55 +1440,12 @@ s_no_extra_traits! { pad: [c_long; 4], } - pub union __c_anonymous_ifr_ifru { - pub ifru_addr: crate::sockaddr, - pub ifru_dstaddr: crate::sockaddr, - pub ifru_broadaddr: crate::sockaddr, - pub ifru_netmask: crate::sockaddr, - pub ifru_hwaddr: crate::sockaddr, - pub ifru_flags: c_short, - pub ifru_ifindex: c_int, - pub ifru_metric: c_int, - pub ifru_mtu: c_int, - pub ifru_map: __c_anonymous_ifru_map, - pub ifru_slave: [c_char; crate::IFNAMSIZ], - pub ifru_newname: [c_char; crate::IFNAMSIZ], - pub ifru_data: *mut c_char, - } - - pub struct ifreq { - /// interface name, e.g. "en0" - pub ifr_name: [c_char; crate::IFNAMSIZ], - pub ifr_ifru: __c_anonymous_ifr_ifru, - } - - pub union __c_anonymous_ifc_ifcu { - pub ifcu_buf: *mut c_char, - pub ifcu_req: *mut crate::ifreq, - } - - /// Structure used in SIOCGIFCONF request. Used to retrieve interface configuration for - /// machine (useful for programs which must know all networks accessible). - pub struct ifconf { - /// Size of buffer - pub ifc_len: c_int, - pub ifc_ifcu: __c_anonymous_ifc_ifcu, - } - pub struct hwtstamp_config { pub flags: c_int, pub tx_type: c_int, pub rx_filter: c_int, } - pub struct dirent64 { - pub d_ino: crate::ino64_t, - pub d_off: off64_t, - pub d_reclen: c_ushort, - pub d_type: c_uchar, - pub d_name: [c_char; 256], - } - pub struct sched_attr { pub size: __u32, pub sched_policy: __u32, @@ -1536,21 +1457,6 @@ s_no_extra_traits! { pub sched_period: crate::__u64, } - pub union tpacket_req_u { - pub req: crate::tpacket_req, - pub req3: crate::tpacket_req3, - } - - pub union tpacket_bd_header_u { - pub bh1: crate::tpacket_hdr_v1, - } - - pub struct tpacket_block_desc { - pub version: __u32, - pub offset_to_priv: __u32, - pub hdr: crate::tpacket_bd_header_u, - } - #[cfg_attr( all( any(target_env = "musl", target_env = "ohos"), @@ -1703,6 +1609,100 @@ s_no_extra_traits! { pub struct pthread_barrier_t { size: [u8; crate::__SIZEOF_PTHREAD_BARRIER_T], } +} + +cfg_if! { + if #[cfg(not(target_arch = "sparc64"))] { + s! { + pub struct iw_thrspy { + pub addr: crate::sockaddr, + pub qual: iw_quality, + pub low: iw_quality, + pub high: iw_quality, + } + + pub struct iw_mlme { + pub cmd: __u16, + pub reason_code: __u16, + pub addr: crate::sockaddr, + } + + pub struct iw_michaelmicfailure { + pub flags: __u32, + pub src_addr: crate::sockaddr, + pub tsc: [__u8; IW_ENCODE_SEQ_MAX_SIZE], + } + + pub struct __c_anonymous_elf32_rela { + pub r_offset: Elf32_Addr, + pub r_info: Elf32_Word, + pub r_addend: Elf32_Sword, + } + + pub struct __c_anonymous_elf64_rela { + pub r_offset: Elf64_Addr, + pub r_info: Elf64_Xword, + pub r_addend: Elf64_Sxword, + } + } + } +} + +s_no_extra_traits! { + pub struct af_alg_iv { + pub ivlen: u32, + pub iv: [c_uchar; 0], + } + + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: crate::sockaddr, + pub ifru_dstaddr: crate::sockaddr, + pub ifru_broadaddr: crate::sockaddr, + pub ifru_netmask: crate::sockaddr, + pub ifru_hwaddr: crate::sockaddr, + pub ifru_flags: c_short, + pub ifru_ifindex: c_int, + pub ifru_metric: c_int, + pub ifru_mtu: c_int, + pub ifru_map: __c_anonymous_ifru_map, + pub ifru_slave: [c_char; crate::IFNAMSIZ], + pub ifru_newname: [c_char; crate::IFNAMSIZ], + pub ifru_data: *mut c_char, + } + + pub struct ifreq { + /// interface name, e.g. "en0" + pub ifr_name: [c_char; crate::IFNAMSIZ], + pub ifr_ifru: __c_anonymous_ifr_ifru, + } + + pub union __c_anonymous_ifc_ifcu { + pub ifcu_buf: *mut c_char, + pub ifcu_req: *mut crate::ifreq, + } + + /// Structure used in SIOCGIFCONF request. Used to retrieve interface configuration for + /// machine (useful for programs which must know all networks accessible). + pub struct ifconf { + /// Size of buffer + pub ifc_len: c_int, + pub ifc_ifcu: __c_anonymous_ifc_ifcu, + } + + pub union tpacket_req_u { + pub req: crate::tpacket_req, + pub req3: crate::tpacket_req3, + } + + pub union tpacket_bd_header_u { + pub bh1: crate::tpacket_hdr_v1, + } + + pub struct tpacket_block_desc { + pub version: __u32, + pub offset_to_priv: __u32, + pub hdr: crate::tpacket_bd_header_u, + } // linux/net_tstamp.h pub struct sock_txtime { @@ -1778,265 +1778,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for sockaddr_nl { - fn eq(&self, other: &sockaddr_nl) -> bool { - self.nl_family == other.nl_family - && self.nl_pid == other.nl_pid - && self.nl_groups == other.nl_groups - } - } - impl Eq for sockaddr_nl {} - impl hash::Hash for sockaddr_nl { - fn hash(&self, state: &mut H) { - self.nl_family.hash(state); - self.nl_pid.hash(state); - self.nl_groups.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for dirent64 { - fn eq(&self, other: &dirent64) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent64 {} - - impl hash::Hash for dirent64 { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for pthread_cond_t { - fn eq(&self, other: &pthread_cond_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - - impl Eq for pthread_cond_t {} - - impl hash::Hash for pthread_cond_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_mutex_t { - fn eq(&self, other: &pthread_mutex_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - - impl Eq for pthread_mutex_t {} - - impl hash::Hash for pthread_mutex_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_rwlock_t { - fn eq(&self, other: &pthread_rwlock_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - - impl Eq for pthread_rwlock_t {} - - impl hash::Hash for pthread_rwlock_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for pthread_barrier_t { - fn eq(&self, other: &pthread_barrier_t) -> bool { - self.size.iter().zip(other.size.iter()).all(|(a, b)| a == b) - } - } - - impl Eq for pthread_barrier_t {} - - impl hash::Hash for pthread_barrier_t { - fn hash(&self, state: &mut H) { - self.size.hash(state); - } - } - - impl PartialEq for sockaddr_alg { - fn eq(&self, other: &sockaddr_alg) -> bool { - self.salg_family == other.salg_family - && self - .salg_type - .iter() - .zip(other.salg_type.iter()) - .all(|(a, b)| a == b) - && self.salg_feat == other.salg_feat - && self.salg_mask == other.salg_mask - && self - .salg_name - .iter() - .zip(other.salg_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_alg {} - - impl hash::Hash for sockaddr_alg { - fn hash(&self, state: &mut H) { - self.salg_family.hash(state); - self.salg_type.hash(state); - self.salg_feat.hash(state); - self.salg_mask.hash(state); - self.salg_name.hash(state); - } - } - - impl PartialEq for uinput_setup { - fn eq(&self, other: &uinput_setup) -> bool { - self.id == other.id - && self.name[..] == other.name[..] - && self.ff_effects_max == other.ff_effects_max - } - } - impl Eq for uinput_setup {} - - impl hash::Hash for uinput_setup { - fn hash(&self, state: &mut H) { - self.id.hash(state); - self.name.hash(state); - self.ff_effects_max.hash(state); - } - } - - impl PartialEq for uinput_user_dev { - fn eq(&self, other: &uinput_user_dev) -> bool { - self.name[..] == other.name[..] - && self.id == other.id - && self.ff_effects_max == other.ff_effects_max - && self.absmax[..] == other.absmax[..] - && self.absmin[..] == other.absmin[..] - && self.absfuzz[..] == other.absfuzz[..] - && self.absflat[..] == other.absflat[..] - } - } - impl Eq for uinput_user_dev {} - - impl hash::Hash for uinput_user_dev { - fn hash(&self, state: &mut H) { - self.name.hash(state); - self.id.hash(state); - self.ff_effects_max.hash(state); - self.absmax.hash(state); - self.absmin.hash(state); - self.absfuzz.hash(state); - self.absflat.hash(state); - } - } - - impl PartialEq for mq_attr { - fn eq(&self, other: &mq_attr) -> bool { - self.mq_flags == other.mq_flags - && self.mq_maxmsg == other.mq_maxmsg - && self.mq_msgsize == other.mq_msgsize - && self.mq_curmsgs == other.mq_curmsgs - } - } - impl Eq for mq_attr {} - impl hash::Hash for mq_attr { - fn hash(&self, state: &mut H) { - self.mq_flags.hash(state); - self.mq_maxmsg.hash(state); - self.mq_msgsize.hash(state); - self.mq_curmsgs.hash(state); - } - } - impl PartialEq for hwtstamp_config { - fn eq(&self, other: &hwtstamp_config) -> bool { - self.flags == other.flags - && self.tx_type == other.tx_type - && self.rx_filter == other.rx_filter - } - } - impl Eq for hwtstamp_config {} - impl hash::Hash for hwtstamp_config { - fn hash(&self, state: &mut H) { - self.flags.hash(state); - self.tx_type.hash(state); - self.rx_filter.hash(state); - } - } - - impl PartialEq for sched_attr { - fn eq(&self, other: &sched_attr) -> bool { - self.size == other.size - && self.sched_policy == other.sched_policy - && self.sched_flags == other.sched_flags - && self.sched_nice == other.sched_nice - && self.sched_priority == other.sched_priority - && self.sched_runtime == other.sched_runtime - && self.sched_deadline == other.sched_deadline - && self.sched_period == other.sched_period - } - } - impl Eq for sched_attr {} - impl hash::Hash for sched_attr { - fn hash(&self, state: &mut H) { - self.size.hash(state); - self.sched_policy.hash(state); - self.sched_flags.hash(state); - self.sched_nice.hash(state); - self.sched_priority.hash(state); - self.sched_runtime.hash(state); - self.sched_deadline.hash(state); - self.sched_period.hash(state); - } - } - } -} - cfg_if! { if #[cfg(any( target_env = "gnu", diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 189a294ea624f..02fe6d6294a47 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -130,9 +130,6 @@ s! { pub arm_cpsr: c_ulong, pub fault_address: c_ulong, } -} - -s_no_extra_traits! { pub struct ucontext_t { pub uc_flags: c_ulong, pub uc_link: *mut ucontext_t, @@ -141,37 +138,15 @@ s_no_extra_traits! { pub uc_sigmask: crate::sigset_t, pub uc_regspace: [c_ulonglong; 64], } +} +s_no_extra_traits! { #[repr(align(8))] pub struct max_align_t { priv_: (i64, i64), } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - } - } - impl Eq for ucontext_t {} - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - } - } - } -} - pub const SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 43ea2e88ff467..5b7a3e8d10984 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -110,9 +110,7 @@ s! { __pad1: c_ulong, __pad2: c_ulong, } -} -s_no_extra_traits! { pub struct user_fpxregs_struct { pub cwd: c_ushort, pub swd: c_ushort, @@ -137,83 +135,15 @@ s_no_extra_traits! { pub uc_sigmask: crate::sigset_t, __private: [u8; 112], } +} +s_no_extra_traits! { #[repr(align(8))] pub struct max_align_t { priv_: [f64; 3], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for user_fpxregs_struct { - fn eq(&self, other: &user_fpxregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.twd == other.twd - && self.fop == other.fop - && self.fip == other.fip - && self.fcs == other.fcs - && self.foo == other.foo - && self.fos == other.fos - && self.mxcsr == other.mxcsr - // Ignore __reserved field - && self.st_space == other.st_space - && self.xmm_space == other.xmm_space - // Ignore padding field - } - } - - impl Eq for user_fpxregs_struct {} - - impl hash::Hash for user_fpxregs_struct { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.swd.hash(state); - self.twd.hash(state); - self.fop.hash(state); - self.fip.hash(state); - self.fcs.hash(state); - self.foo.hash(state); - self.fos.hash(state); - self.mxcsr.hash(state); - // Ignore __reserved field - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field - } - } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - && self - .__private - .iter() - .zip(other.__private.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for ucontext_t {} - - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - self.__private.hash(state); - } - } - } -} - pub const SIGSTKSZ: size_t = 8192; pub const MINSIGSTKSZ: size_t = 2048; diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index ebb8084468b66..2ad8eb774ded8 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -145,9 +145,7 @@ s! { pub set_tid_size: c_ulonglong, pub cgroup: c_ulonglong, } -} -s_no_extra_traits! { pub struct user_fpregs_struct { pub cwd: c_ushort, pub swd: c_ushort, @@ -170,82 +168,15 @@ s_no_extra_traits! { pub uc_sigmask: crate::sigset_t, __private: [u8; 512], } +} +s_no_extra_traits! { #[repr(align(16))] pub struct max_align_t { priv_: [f64; 4], } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for user_fpregs_struct { - fn eq(&self, other: &user_fpregs_struct) -> bool { - self.cwd == other.cwd - && self.swd == other.swd - && self.ftw == other.ftw - && self.fop == other.fop - && self.rip == other.rip - && self.rdp == other.rdp - && self.mxcsr == other.mxcsr - && self.mxcr_mask == other.mxcr_mask - && self.st_space == other.st_space - && self - .xmm_space - .iter() - .zip(other.xmm_space.iter()) - .all(|(a, b)| a == b) - // Ignore padding field - } - } - - impl Eq for user_fpregs_struct {} - - impl hash::Hash for user_fpregs_struct { - fn hash(&self, state: &mut H) { - self.cwd.hash(state); - self.ftw.hash(state); - self.fop.hash(state); - self.rip.hash(state); - self.rdp.hash(state); - self.mxcsr.hash(state); - self.mxcr_mask.hash(state); - self.st_space.hash(state); - self.xmm_space.hash(state); - // Ignore padding field - } - } - - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_sigmask == other.uc_sigmask - && self - .__private - .iter() - .zip(other.__private.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for ucontext_t {} - - impl hash::Hash for ucontext_t { - fn hash(&self, state: &mut H) { - self.uc_flags.hash(state); - self.uc_link.hash(state); - self.uc_stack.hash(state); - self.uc_mcontext.hash(state); - self.uc_sigmask.hash(state); - self.__private.hash(state); - } - } - } -} - // Syscall table pub const SYS_read: c_long = 0; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 4787ea51ff73a..63dba385ad429 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -405,25 +405,6 @@ s! { pub f_flags: c_ulong, pub f_spare: [c_ulong; 4], } -} - -s_no_extra_traits! { - pub struct aiocb { - pub aio_fildes: c_int, - pub aio_lio_opcode: c_int, - pub aio_reqprio: c_int, - pub aio_buf: *mut c_void, - pub aio_nbytes: size_t, - pub aio_sigevent: crate::sigevent, - __td: *mut c_void, - __lock: [c_int; 2], - __err: c_int, - __ret: ssize_t, - pub aio_offset: off_t, - __next: *mut c_void, - __prev: *mut c_void, - __dummy4: [c_char; 32 - 2 * size_of::<*const ()>()], - } pub struct sysinfo { pub uptime: c_ulong, @@ -477,95 +458,22 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for sysinfo { - fn eq(&self, other: &sysinfo) -> bool { - self.uptime == other.uptime - && self.loads == other.loads - && self.totalram == other.totalram - && self.freeram == other.freeram - && self.sharedram == other.sharedram - && self.bufferram == other.bufferram - && self.totalswap == other.totalswap - && self.freeswap == other.freeswap - && self.procs == other.procs - && self.pad == other.pad - && self.totalhigh == other.totalhigh - && self.freehigh == other.freehigh - && self.mem_unit == other.mem_unit - && self - .__reserved - .iter() - .zip(other.__reserved.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sysinfo {} - - impl hash::Hash for sysinfo { - fn hash(&self, state: &mut H) { - self.uptime.hash(state); - self.loads.hash(state); - self.totalram.hash(state); - self.freeram.hash(state); - self.sharedram.hash(state); - self.bufferram.hash(state); - self.totalswap.hash(state); - self.freeswap.hash(state); - self.procs.hash(state); - self.pad.hash(state); - self.totalhigh.hash(state); - self.freehigh.hash(state); - self.mem_unit.hash(state); - self.__reserved.hash(state); - } - } - - impl PartialEq for utmpx { - #[allow(deprecated)] - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - //&& self.__ut_pad1 == other.__ut_pad1 - && self.ut_pid == other.ut_pid - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_user == other.ut_user - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a,b)| a == b) - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - //&& self.__ut_pad2 == other.__ut_pad2 - && self.ut_tv == other.ut_tv - && self.ut_addr_v6 == other.ut_addr_v6 - && self.__unused == other.__unused - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - #[allow(deprecated)] - fn hash(&self, state: &mut H) { - self.ut_type.hash(state); - //self.__ut_pad1.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_user.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - //self.__ut_pad2.hash(state); - self.ut_tv.hash(state); - self.ut_addr_v6.hash(state); - self.__unused.hash(state); - } - } +s_no_extra_traits! { + pub struct aiocb { + pub aio_fildes: c_int, + pub aio_lio_opcode: c_int, + pub aio_reqprio: c_int, + pub aio_buf: *mut c_void, + pub aio_nbytes: size_t, + pub aio_sigevent: crate::sigevent, + __td: *mut c_void, + __lock: [c_int; 2], + __err: c_int, + __ret: ssize_t, + pub aio_offset: off_t, + __next: *mut c_void, + __prev: *mut c_void, + __dummy4: [c_char; 32 - 2 * size_of::<*const ()>()], } } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 793609052d485..4545f90f0f54c 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -211,6 +211,29 @@ s! { pub msg_hdr: crate::msghdr, pub msg_len: c_uint, } + + pub struct sockaddr_un { + pub sun_family: sa_family_t, + pub sun_path: [c_char; 108], + } + + pub struct sockaddr_storage { + pub ss_family: sa_family_t, + #[cfg(target_pointer_width = "32")] + __ss_pad2: [u8; 128 - 2 - 4], + #[cfg(target_pointer_width = "64")] + __ss_pad2: [u8; 128 - 2 - 8], + __ss_align: size_t, + } + + pub struct utsname { + pub sysname: [c_char; 65], + pub nodename: [c_char; 65], + pub release: [c_char; 65], + pub version: [c_char; 65], + pub machine: [c_char; 65], + pub domainname: [c_char; 65], + } } cfg_if! { @@ -305,29 +328,6 @@ s_no_extra_traits! { pub _sigev_thread: __c_anonymous_sigev_thread, } - pub struct sockaddr_un { - pub sun_family: sa_family_t, - pub sun_path: [c_char; 108], - } - - pub struct sockaddr_storage { - pub ss_family: sa_family_t, - #[cfg(target_pointer_width = "32")] - __ss_pad2: [u8; 128 - 2 - 4], - #[cfg(target_pointer_width = "64")] - __ss_pad2: [u8; 128 - 2 - 8], - __ss_align: size_t, - } - - pub struct utsname { - pub sysname: [c_char; 65], - pub nodename: [c_char; 65], - pub release: [c_char; 65], - pub version: [c_char; 65], - pub machine: [c_char; 65], - pub domainname: [c_char; 65], - } - pub struct sigevent { pub sigev_value: crate::sigval, pub sigev_signo: c_int, @@ -370,91 +370,6 @@ cfg_if! { } } - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_un {} - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_family == other.ss_family - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_storage {} - - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_family.hash(state); - self.__ss_pad2.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - && self - .domainname - .iter() - .zip(other.domainname.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utsname {} - - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - self.domainname.hash(state); - } - } - impl PartialEq for __c_anonymous_ifaddrs_ifa_ifu { fn eq(&self, _other: &__c_anonymous_ifaddrs_ifa_ifu) -> bool { unimplemented!("traits") diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index bcb9534f2cc37..0deff9db71ccd 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -176,6 +176,8 @@ s! { pub f_namemax: c_ulong, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { pub sa_handler: extern "C" fn(arg1: c_int), pub sa_mask: sigset_t, diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index e1cea02cc2602..64f57270463d6 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -306,6 +306,8 @@ s! { pub rlim_max: rlim64_t, } + // FIXME(1.0): This should not implement `PartialEq` + #[allow(unpredictable_function_pointer_comparisons)] pub struct glob_t { pub gl_pathc: size_t, pub gl_matchc: c_int, @@ -668,9 +670,6 @@ s! { pub uc_stack: stack_t, pub uc_mcontext: mcontext_t, } -} - -s_no_extra_traits! { pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, @@ -722,6 +721,32 @@ s_no_extra_traits! { pub mq_recvwait: c_long, } + #[cfg(not(target_env = "nto71_iosock"))] + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: crate::sa_family_t, + pub sdl_index: u16, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 12], + } + + #[cfg(target_env = "nto71_iosock")] + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: c_uchar, + pub sdl_index: c_ushort, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 46], + } +} + +s_no_extra_traits! { pub struct msg { pub msg_next: *mut crate::msg, pub msg_type: c_long, @@ -748,30 +773,6 @@ s_no_extra_traits! { msg_pad4: [c_long; 4], } - #[cfg(not(target_env = "nto71_iosock"))] - pub struct sockaddr_dl { - pub sdl_len: c_uchar, - pub sdl_family: crate::sa_family_t, - pub sdl_index: u16, - pub sdl_type: c_uchar, - pub sdl_nlen: c_uchar, - pub sdl_alen: c_uchar, - pub sdl_slen: c_uchar, - pub sdl_data: [c_char; 12], - } - - #[cfg(target_env = "nto71_iosock")] - pub struct sockaddr_dl { - pub sdl_len: c_uchar, - pub sdl_family: c_uchar, - pub sdl_index: c_ushort, - pub sdl_type: c_uchar, - pub sdl_nlen: c_uchar, - pub sdl_alen: c_uchar, - pub sdl_slen: c_uchar, - pub sdl_data: [c_char; 46], - } - pub struct sync_t { __u: c_uint, // union pub __owner: c_uint, @@ -796,215 +797,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - // sigevent - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - && self.__sigev_un2 == other.__sigev_un2 - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - self.__sigev_un2.hash(state); - } - } - - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_len == other.sun_len - && self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_un {} - - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_len.hash(state); - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - // sigset_t - impl PartialEq for sigset_t { - fn eq(&self, other: &sigset_t) -> bool { - self.__val == other.__val - } - } - impl Eq for sigset_t {} - impl hash::Hash for sigset_t { - fn hash(&self, state: &mut H) { - self.__val.hash(state); - } - } - - // msg - - // msqid_ds - - // sockaddr_dl - impl PartialEq for sockaddr_dl { - fn eq(&self, other: &sockaddr_dl) -> bool { - self.sdl_len == other.sdl_len - && self.sdl_family == other.sdl_family - && self.sdl_index == other.sdl_index - && self.sdl_type == other.sdl_type - && self.sdl_nlen == other.sdl_nlen - && self.sdl_alen == other.sdl_alen - && self.sdl_slen == other.sdl_slen - && self - .sdl_data - .iter() - .zip(other.sdl_data.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_dl {} - impl hash::Hash for sockaddr_dl { - fn hash(&self, state: &mut H) { - self.sdl_len.hash(state); - self.sdl_family.hash(state); - self.sdl_index.hash(state); - self.sdl_type.hash(state); - self.sdl_nlen.hash(state); - self.sdl_alen.hash(state); - self.sdl_slen.hash(state); - self.sdl_data.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utsname {} - - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - } - } - - impl PartialEq for mq_attr { - fn eq(&self, other: &mq_attr) -> bool { - self.mq_maxmsg == other.mq_maxmsg - && self.mq_msgsize == other.mq_msgsize - && self.mq_flags == other.mq_flags - && self.mq_curmsgs == other.mq_curmsgs - && self.mq_msgsize == other.mq_msgsize - && self.mq_sendwait == other.mq_sendwait - && self.mq_recvwait == other.mq_recvwait - } - } - - impl Eq for mq_attr {} - - impl hash::Hash for mq_attr { - fn hash(&self, state: &mut H) { - self.mq_maxmsg.hash(state); - self.mq_msgsize.hash(state); - self.mq_flags.hash(state); - self.mq_curmsgs.hash(state); - self.mq_sendwait.hash(state); - self.mq_recvwait.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_len == other.ss_len - && self.ss_family == other.ss_family - && self.__ss_pad1 == other.__ss_pad1 - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_storage {} - - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_len.hash(state); - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } - } - - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_offset == other.d_offset - && self.d_reclen == other.d_reclen - && self.d_namelen == other.d_namelen - && self.d_name[..self.d_namelen as _] - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_offset.hash(state); - self.d_reclen.hash(state); - self.d_namelen.hash(state); - self.d_name[..self.d_namelen as _].hash(state); - } - } - } -} - pub const _SYSNAME_SIZE: usize = 256 + 1; pub const RLIM_INFINITY: crate::rlim_t = 0xfffffffffffffffd; pub const O_LARGEFILE: c_int = 0o0100000; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 527af5f6466e3..ad2a6d75a34f8 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -36,7 +36,7 @@ extern_ty! { pub enum timezone {} } -s_no_extra_traits! { +s! { #[repr(C)] pub struct utsname { pub sysname: [c_char; UTSLENGTH], @@ -65,9 +65,7 @@ s_no_extra_traits! { __ss_padding: [u8; 128 - size_of::() - size_of::()], __ss_align: c_ulong, } -} -s! { pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, @@ -1379,122 +1377,3 @@ extern "C" { // utmp.h pub fn login_tty(fd: c_int) -> c_int; } - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for dirent { - fn eq(&self, other: &dirent) -> bool { - self.d_ino == other.d_ino - && self.d_off == other.d_off - && self.d_reclen == other.d_reclen - && self.d_type == other.d_type - && self - .d_name - .iter() - .zip(other.d_name.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for dirent {} - - impl hash::Hash for dirent { - fn hash(&self, state: &mut H) { - self.d_ino.hash(state); - self.d_off.hash(state); - self.d_reclen.hash(state); - self.d_type.hash(state); - self.d_name.hash(state); - } - } - - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_un {} - - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_family == other.ss_family - && self.__ss_align == self.__ss_align - && self - .__ss_padding - .iter() - .zip(other.__ss_padding.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for sockaddr_storage {} - - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_family.hash(state); - self.__ss_padding.hash(state); - self.__ss_align.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - && self - .domainname - .iter() - .zip(other.domainname.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utsname {} - - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - self.domainname.hash(state); - } - } - } -} diff --git a/src/unix/solarish/illumos.rs b/src/unix/solarish/illumos.rs index 42aa5731f9aaa..d83a24075e0b4 100644 --- a/src/unix/solarish/illumos.rs +++ b/src/unix/solarish/illumos.rs @@ -47,9 +47,7 @@ s! { pub fi_pos: c_int, pub fi_name: [c_char; crate::FILNAME_MAX as usize], } -} -s_no_extra_traits! { #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"), repr(packed(4)))] pub struct epoll_event { pub events: u32, @@ -71,63 +69,6 @@ s_no_extra_traits! { } } -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_user == other.ut_user - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_syslen == other.ut_syslen - && self.ut_pad == other.ut_pad - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_user.hash(state); - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_syslen.hash(state); - self.ut_pad.hash(state); - } - } - - impl PartialEq for epoll_event { - fn eq(&self, other: &epoll_event) -> bool { - self.events == other.events && self.u64 == other.u64 - } - } - impl Eq for epoll_event {} - impl hash::Hash for epoll_event { - fn hash(&self, state: &mut H) { - let events = self.events; - let u64 = self.u64; - events.hash(state); - u64.hash(state); - } - } - } -} - pub const _UTX_USERSIZE: usize = 32; pub const _UTX_LINESIZE: usize = 32; pub const _UTX_PADSIZE: usize = 5; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 0ed2047d2e926..7ef46b87e75a7 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -484,9 +484,7 @@ s! { pub flag: *mut c_int, pub val: c_int, } -} -s_no_extra_traits! { pub struct sockaddr_un { pub sun_family: sa_family_t, pub sun_path: [c_char; 108], @@ -514,17 +512,6 @@ s_no_extra_traits! { __ss_pad2: [u8; 240], } - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - pub struct siginfo_t { - pub si_signo: c_int, - pub si_code: c_int, - pub si_errno: c_int, - #[cfg(target_pointer_width = "64")] - pub si_pad: c_int, - - __data_pad: [c_int; SIGINFO_DATA_SIZE], - } - pub struct sockaddr_dl { pub sdl_family: c_ushort, pub sdl_index: c_ushort, @@ -543,6 +530,19 @@ s_no_extra_traits! { pub sigev_notify_attributes: *const crate::pthread_attr_t, __sigev_pad2: c_int, } +} + +s_no_extra_traits! { + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + pub struct siginfo_t { + pub si_signo: c_int, + pub si_code: c_int, + pub si_errno: c_int, + #[cfg(target_pointer_width = "64")] + pub si_pad: c_int, + + __data_pad: [c_int; SIGINFO_DATA_SIZE], + } #[repr(align(16))] pub union pad128_t { @@ -559,100 +559,6 @@ s_no_extra_traits! { cfg_if! { if #[cfg(feature = "extra_traits")] { - impl PartialEq for sockaddr_un { - fn eq(&self, other: &sockaddr_un) -> bool { - self.sun_family == other.sun_family - && self - .sun_path - .iter() - .zip(other.sun_path.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_un {} - impl hash::Hash for sockaddr_un { - fn hash(&self, state: &mut H) { - self.sun_family.hash(state); - self.sun_path.hash(state); - } - } - - impl PartialEq for utsname { - fn eq(&self, other: &utsname) -> bool { - self.sysname - .iter() - .zip(other.sysname.iter()) - .all(|(a, b)| a == b) - && self - .nodename - .iter() - .zip(other.nodename.iter()) - .all(|(a, b)| a == b) - && self - .release - .iter() - .zip(other.release.iter()) - .all(|(a, b)| a == b) - && self - .version - .iter() - .zip(other.version.iter()) - .all(|(a, b)| a == b) - && self - .machine - .iter() - .zip(other.machine.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for utsname {} - impl hash::Hash for utsname { - fn hash(&self, state: &mut H) { - self.sysname.hash(state); - self.nodename.hash(state); - self.release.hash(state); - self.version.hash(state); - self.machine.hash(state); - } - } - - impl PartialEq for fd_set { - fn eq(&self, other: &fd_set) -> bool { - self.fds_bits - .iter() - .zip(other.fds_bits.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for fd_set {} - impl hash::Hash for fd_set { - fn hash(&self, state: &mut H) { - self.fds_bits.hash(state); - } - } - - impl PartialEq for sockaddr_storage { - fn eq(&self, other: &sockaddr_storage) -> bool { - self.ss_family == other.ss_family - && self.__ss_pad1 == other.__ss_pad1 - && self.__ss_align == other.__ss_align - && self - .__ss_pad2 - .iter() - .zip(other.__ss_pad2.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_storage {} - impl hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { - self.ss_family.hash(state); - self.__ss_pad1.hash(state); - self.__ss_align.hash(state); - self.__ss_pad2.hash(state); - } - } - impl siginfo_t { /// The siginfo_t will have differing contents based on the delivered signal. Based on /// `si_signo`, this determines how many of the `c_int` pad fields contain valid data @@ -717,54 +623,6 @@ cfg_if! { } } - impl PartialEq for sockaddr_dl { - fn eq(&self, other: &sockaddr_dl) -> bool { - self.sdl_family == other.sdl_family - && self.sdl_index == other.sdl_index - && self.sdl_type == other.sdl_type - && self.sdl_nlen == other.sdl_nlen - && self.sdl_alen == other.sdl_alen - && self.sdl_slen == other.sdl_slen - && self - .sdl_data - .iter() - .zip(other.sdl_data.iter()) - .all(|(a, b)| a == b) - } - } - impl Eq for sockaddr_dl {} - impl hash::Hash for sockaddr_dl { - fn hash(&self, state: &mut H) { - self.sdl_family.hash(state); - self.sdl_index.hash(state); - self.sdl_type.hash(state); - self.sdl_nlen.hash(state); - self.sdl_alen.hash(state); - self.sdl_slen.hash(state); - self.sdl_data.hash(state); - } - } - - impl PartialEq for sigevent { - fn eq(&self, other: &sigevent) -> bool { - self.sigev_notify == other.sigev_notify - && self.sigev_signo == other.sigev_signo - && self.sigev_value == other.sigev_value - && self.ss_sp == other.ss_sp - && self.sigev_notify_attributes == other.sigev_notify_attributes - } - } - impl Eq for sigevent {} - impl hash::Hash for sigevent { - fn hash(&self, state: &mut H) { - self.sigev_notify.hash(state); - self.sigev_signo.hash(state); - self.sigev_value.hash(state); - self.ss_sp.hash(state); - self.sigev_notify_attributes.hash(state); - } - } - impl PartialEq for pad128_t { fn eq(&self, other: &pad128_t) -> bool { unsafe { diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index ad0a0b251fff1..06373845a94e1 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -62,6 +62,20 @@ s! { pub xrs_id: c_ulong, pub xrs_ptr: *mut c_char, } + + pub struct utmpx { + pub ut_user: [c_char; _UTMP_USER_LEN], + pub ut_id: [c_char; _UTMP_ID_LEN], + pub ut_line: [c_char; _UTMP_LINE_LEN], + pub ut_pid: crate::pid_t, + pub ut_type: c_short, + pub ut_exit: exit_status, + pub ut_tv: crate::timeval, + pub ut_session: c_int, + pub pad: [c_int; 5], + pub ut_syslen: c_short, + pub ut_host: [c_char; 257], + } } s_no_extra_traits! { @@ -89,62 +103,6 @@ s_no_extra_traits! { pub rbuf: *const c_char, pub rsize: size_t, } - - pub struct utmpx { - pub ut_user: [c_char; _UTMP_USER_LEN], - pub ut_id: [c_char; _UTMP_ID_LEN], - pub ut_line: [c_char; _UTMP_LINE_LEN], - pub ut_pid: crate::pid_t, - pub ut_type: c_short, - pub ut_exit: exit_status, - pub ut_tv: crate::timeval, - pub ut_session: c_int, - pub pad: [c_int; 5], - pub ut_syslen: c_short, - pub ut_host: [c_char; 257], - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for utmpx { - fn eq(&self, other: &utmpx) -> bool { - self.ut_type == other.ut_type - && self.ut_pid == other.ut_pid - && self.ut_user == other.ut_user - && self.ut_line == other.ut_line - && self.ut_id == other.ut_id - && self.ut_exit == other.ut_exit - && self.ut_session == other.ut_session - && self.ut_tv == other.ut_tv - && self.ut_syslen == other.ut_syslen - && self.pad == other.pad - && self - .ut_host - .iter() - .zip(other.ut_host.iter()) - .all(|(a, b)| a == b) - } - } - - impl Eq for utmpx {} - - impl hash::Hash for utmpx { - fn hash(&self, state: &mut H) { - self.ut_user.hash(state); - self.ut_type.hash(state); - self.ut_pid.hash(state); - self.ut_line.hash(state); - self.ut_id.hash(state); - self.ut_host.hash(state); - self.ut_exit.hash(state); - self.ut_session.hash(state); - self.ut_tv.hash(state); - self.ut_syslen.hash(state); - self.pad.hash(state); - } - } - } } // FIXME(solaris): O_DIRECT and SIGINFO are NOT available on Solaris. diff --git a/src/unix/solarish/x86_64.rs b/src/unix/solarish/x86_64.rs index a45ca4b7d0976..a4c48064aaaa9 100644 --- a/src/unix/solarish/x86_64.rs +++ b/src/unix/solarish/x86_64.rs @@ -59,13 +59,6 @@ s! { #[cfg(target_os = "solaris")] pub dlpi_tls_data: *mut c_void, } -} - -s_no_extra_traits! { - pub union __c_anonymous_fp_reg_set { - pub fpchip_state: __c_anonymous_fpchip_state, - pub f_fpregs: [[u32; 13]; 10], - } pub struct fpregset_t { pub fp_reg_set: __c_anonymous_fp_reg_set, @@ -97,6 +90,13 @@ s_no_extra_traits! { } } +s_no_extra_traits! { + pub union __c_anonymous_fp_reg_set { + pub fpchip_state: __c_anonymous_fpchip_state, + pub f_fpregs: [[u32; 13]; 10], + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for __c_anonymous_fp_reg_set { @@ -112,29 +112,13 @@ cfg_if! { } } impl Eq for __c_anonymous_fp_reg_set {} - impl PartialEq for fpregset_t { - fn eq(&self, other: &fpregset_t) -> bool { - self.fp_reg_set == other.fp_reg_set - } - } - impl Eq for fpregset_t {} - impl PartialEq for mcontext_t { - fn eq(&self, other: &mcontext_t) -> bool { - self.gregs == other.gregs && self.fpregs == other.fpregs - } - } - impl Eq for mcontext_t {} - impl PartialEq for ucontext_t { - fn eq(&self, other: &ucontext_t) -> bool { - self.uc_flags == other.uc_flags - && self.uc_link == other.uc_link - && self.uc_sigmask == other.uc_sigmask - && self.uc_stack == other.uc_stack - && self.uc_mcontext == other.uc_mcontext - && self.uc_filler == other.uc_filler + impl hash::Hash for __c_anonymous_fp_reg_set { + fn hash(&self, state: &mut H) { + unsafe { + self.f_fpregs.hash(state); + } } } - impl Eq for ucontext_t {} } }