From 34942a570715b4f6afc507dc2bd9ae9e02b437d8 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 12 Aug 2024 19:27:48 +0100 Subject: [PATCH] freebsd moving the kinfo_file type to general use. but keeping the constant KINFO_FILE_SIZE for intel archs only. --- libc-test/semver/freebsd-x86_64.txt | 1 + libc-test/semver/freebsd.txt | 1 + src/unix/bsd/freebsdlike/freebsd/mod.rs | 63 ++++++++++++++++++ src/unix/bsd/freebsdlike/freebsd/x86.rs | 2 + .../bsd/freebsdlike/freebsd/x86_64/mod.rs | 65 +------------------ 5 files changed, 69 insertions(+), 63 deletions(-) diff --git a/libc-test/semver/freebsd-x86_64.txt b/libc-test/semver/freebsd-x86_64.txt index 8edfb525633db..be73d1f7290fe 100644 --- a/libc-test/semver/freebsd-x86_64.txt +++ b/libc-test/semver/freebsd-x86_64.txt @@ -1,4 +1,5 @@ Elf64_Auxinfo +KINFO_FILE_SIZE MAP_32BIT _MC_FLAG_MASK _MC_FPFMT_NODEV diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 5a049d102114e..d427bedab574a 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1981,6 +1981,7 @@ kcmp kevent key_t killpg +kinfo_file kinfo_getvmmap kinfo_proc kinfo_vmentry diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index a2942913b95d1..995381ce12975 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1621,6 +1621,23 @@ s_no_extra_traits! { pub cause: sctp_error_cause, pub hmac_id: u16, } + + pub struct kinfo_file { + pub kf_structsize: ::c_int, + pub kf_type: ::c_int, + pub kf_fd: ::c_int, + pub kf_ref_count: ::c_int, + pub kf_flags: ::c_int, + _kf_pad0: ::c_int, + pub kf_offset: i64, + _priv: [::uintptr_t; 38], // FIXME if needed + pub kf_status: u16, + _kf_pad1: u16, + _kf_ispare0: ::c_int, + pub kf_cap_rights: ::cap_rights_t, + _kf_cap_spare: u64, + pub kf_path: [::c_char; ::PATH_MAX as usize], + } } cfg_if! { @@ -2529,6 +2546,52 @@ cfg_if! { {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 ::fmt::Debug for kinfo_file { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("kinfo_file") + .field("kf_structsize", &self.kf_structsize) + .field("kf_type", &self.kf_type) + .field("kf_fd", &self.kf_fd) + .field("kf_ref_count", &self.kf_ref_count) + .field("kf_flags", &self.kf_flags) + .field("kf_offset", &self.kf_offset) + .field("kf_status", &self.kf_status) + .field("kf_cap_rights", &self.kf_cap_rights) + .field("kf_path", &&self.kf_path[..]) + .finish() + } + } + 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/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 29689c910689f..3e3e5cc9f34fb 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -190,3 +190,5 @@ cfg_if! { } pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 + +pub const KINFO_FILE_SIZE: ::c_int = 1392; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index c94695ed06cfb..aa33345f3113f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -91,23 +91,6 @@ s_no_extra_traits! { pub a_type: ::c_long, pub a_un: __c_anonymous_elf64_auxv_union, } - - pub struct kinfo_file { - pub kf_structsize: ::c_int, - pub kf_type: ::c_int, - pub kf_fd: ::c_int, - pub kf_ref_count: ::c_int, - pub kf_flags: ::c_int, - _kf_pad0: ::c_int, - pub kf_offset: i64, - _priv: [::uintptr_t; 38], // FIXME if needed - pub kf_status: u16, - _kf_pad1: u16, - _kf_ispare0: ::c_int, - pub kf_cap_rights: ::cap_rights_t, - _kf_cap_spare: u64, - pub kf_path: [::c_char; ::PATH_MAX as usize], - } } cfg_if! { @@ -232,52 +215,6 @@ cfg_if! { .finish() } } - - 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 ::fmt::Debug for kinfo_file { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - f.debug_struct("kinfo_file") - .field("kf_structsize", &self.kf_structsize) - .field("kf_type", &self.kf_type) - .field("kf_fd", &self.kf_fd) - .field("kf_ref_count", &self.kf_ref_count) - .field("kf_flags", &self.kf_flags) - .field("kf_offset", &self.kf_offset) - .field("kf_status", &self.kf_status) - .field("kf_cap_rights", &self.kf_cap_rights) - .field("kf_path", &&self.kf_path[..]) - .finish() - } - } - 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); - } - } } } @@ -297,5 +234,7 @@ pub const _MC_FPOWNED_NONE: c_long = 0x20000; pub const _MC_FPOWNED_FPU: c_long = 0x20001; pub const _MC_FPOWNED_PCB: c_long = 0x20002; +pub const KINFO_FILE_SIZE: ::c_int = 1392; + mod align; pub use self::align::*;