From 2518f3e91cde3e7a4b0607f78192f812d7361591 Mon Sep 17 00:00:00 2001 From: Nathaniel Bennett Date: Mon, 30 Sep 2024 22:38:35 -0400 Subject: [PATCH 01/11] FreeBSD: Add ucontext_t, mcontext_t for all archs (#3848) [ gate ppc under `cfg(libc_align)` and adjust `Debug` implementations to meet msrv - Trevor ] (backport ) (cherry picked from commit 2053d5b1d82d8cef862c5630d5968381c89e7fe4) --- libc-test/semver/freebsd-x86_64.txt | 2 - libc-test/semver/freebsd.txt | 2 + src/unix/bsd/freebsdlike/freebsd/arm.rs | 44 +++++++++++++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 21 ++++++ src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 66 +++++++++++++++++++ src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 66 +++++++++++++++++++ src/unix/bsd/freebsdlike/freebsd/x86.rs | 14 +--- .../bsd/freebsdlike/freebsd/x86_64/align.rs | 11 ---- 8 files changed, 201 insertions(+), 25 deletions(-) diff --git a/libc-test/semver/freebsd-x86_64.txt b/libc-test/semver/freebsd-x86_64.txt index be73d1f7290fe..14ddc25a1b254 100644 --- a/libc-test/semver/freebsd-x86_64.txt +++ b/libc-test/semver/freebsd-x86_64.txt @@ -13,8 +13,6 @@ _MC_HASSEGS fpreg fpreg32 max_align_t -mcontext_t reg reg32 -ucontext_t xmmreg diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index c9944d1d791f7..e3418ef7d220e 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -2028,6 +2028,7 @@ mallctl mallctlbymib mallctlnametomib mallocx +mcontext_t memmem memrchr memset_s @@ -2358,6 +2359,7 @@ timer_t timex truncate ttyname_r +ucontext_t unmount useconds_t uselocale diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 8ff500c65981c..965abd33f0a48 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -5,6 +5,49 @@ pub type wchar_t = u32; pub type time_t = i64; pub type suseconds_t = i32; pub type register_t = i32; +pub type __greg_t = ::c_uint; +pub type __gregset_t = [::__greg_t; 17]; + +s_no_extra_traits! { + pub struct mcontext_t { + pub __gregs: ::__gregset_t, + pub mc_vfp_size: ::__size_t, + pub mc_vfp_ptr: *mut ::c_void, + pub mc_spare: [::c_uint; 33], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.__gregs == other.__gregs && + self.mc_vfp_size == other.mc_vfp_size && + self.mc_vfp_ptr == other.mc_vfp_ptr && + self.mc_spare.iter().zip(other.mc_spare.iter()).all(|(a, b)| a == b) + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("__gregs", &self.__gregs) + .field("mc_vfp_size", &self.mc_vfp_size) + .field("mc_vfp_ptr", &self.mc_vfp_ptr) + .field("mc_spare", &self.mc_spare) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.__gregs.hash(state); + self.mc_vfp_size.hash(state); + self.mc_vfp_ptr.hash(state); + self.mc_spare.hash(state); + } + } + } +} // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { @@ -16,5 +59,6 @@ cfg_if! { pub const _ALIGNBYTES: usize = 4 - 1; } } + pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index a15987df10775..dda108e8c0ef2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1654,6 +1654,15 @@ s_no_extra_traits! { _kf_cap_spare: u64, pub kf_path: [::c_char; ::PATH_MAX as usize], } + + pub struct ucontext_t { + pub uc_sigmask: ::sigset_t, + pub uc_mcontext: ::mcontext_t, + pub uc_link: *mut ::ucontext_t, + pub uc_stack: ::stack_t, + pub uc_flags: ::c_int, + __spare__: [::c_int; 4], + } } cfg_if! { @@ -2656,6 +2665,18 @@ cfg_if! { self.kf_path.hash(state); } } + + impl ::fmt::Debug for ucontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ucontext_t") + .field("uc_sigmask", &self.uc_sigmask) + .field("uc_mcontext", &self.uc_mcontext) + .field("uc_link", &self.uc_link) + .field("uc_stack", &self.uc_stack) + .field("uc_flags", &self.uc_flags) + .finish() + } + } } } diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index f84062ba34b93..d856e80226746 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -6,6 +6,72 @@ pub type time_t = i64; pub type suseconds_t = i32; pub type register_t = i32; +cfg_if! { + if #[cfg(libc_align)] { + s_no_extra_traits! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_vers: ::c_int, + pub mc_flags: ::c_int, + pub mc_onstack: ::c_int, + pub mc_len: ::c_int, + pub mc_avec: [u64; 64], + pub mc_av: [u32; 2], + pub mc_frame: [::register_t; 42], + pub mc_fpreg: [u64; 33], + pub mc_vsxfpreg: [u64; 32], + } + } + } +} + +cfg_if! { + if #[cfg(all(libc_align, feature = "extra_traits"))] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.mc_vers == other.mc_vers && + self.mc_flags == other.mc_flags && + self.mc_onstack == other.mc_onstack && + self.mc_len == other.mc_len && + self.mc_avec == other.mc_avec && + self.mc_av == other.mc_av && + self.mc_frame == other.mc_frame && + self.mc_fpreg == other.mc_fpreg && + self.mc_vsxfpreg == other.mc_vsxfpreg + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("mc_vers", &self.mc_vers) + .field("mc_flags", &self.mc_flags) + .field("mc_onstack", &self.mc_onstack) + .field("mc_len", &self.mc_len) + .field("mc_avec", &self.mc_avec) + .field("mc_av", &self.mc_av) + .field("mc_frame", &self.mc_frame) + .field("mc_fpreg", &self.mc_fpreg) + .field("mc_vsxfpreg", &self.mc_vsxfpreg) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.mc_vers.hash(state); + self.mc_flags.hash(state); + self.mc_onstack.hash(state); + self.mc_len.hash(state); + self.mc_avec.hash(state); + self.mc_av.hash(state); + self.mc_frame.hash(state); + self.mc_fpreg.hash(state); + self.mc_vsxfpreg.hash(state); + } + } + } +} + // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { if #[cfg(libc_const_size_of)] { diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index 69cf4c5fc88c7..ec1c17e32db3f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -6,6 +6,72 @@ pub type time_t = i64; pub type suseconds_t = i64; pub type register_t = i64; +cfg_if! { + if #[cfg(libc_align)] { + s_no_extra_traits! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_vers: ::c_int, + pub mc_flags: ::c_int, + pub mc_onstack: ::c_int, + pub mc_len: ::c_int, + pub mc_avec: [u64; 64], + pub mc_av: [u32; 2], + pub mc_frame: [::register_t; 42], + pub mc_fpreg: [u64; 33], + pub mc_vsxfpreg: [u64; 32], + } + } + } +} + +cfg_if! { + if #[cfg(all(libc_align, feature = "extra_traits"))] { + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.mc_vers == other.mc_vers && + self.mc_flags == other.mc_flags && + self.mc_onstack == other.mc_onstack && + self.mc_len == other.mc_len && + self.mc_avec == other.mc_avec && + self.mc_av == other.mc_av && + self.mc_frame == other.mc_frame && + self.mc_fpreg == other.mc_fpreg && + self.mc_vsxfpreg == other.mc_vsxfpreg + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("mc_vers", &self.mc_vers) + .field("mc_flags", &self.mc_flags) + .field("mc_onstack", &self.mc_onstack) + .field("mc_len", &self.mc_len) + .field("mc_avec", &self.mc_avec) + .field("mc_av", &self.mc_av) + .field("mc_frame", &self.mc_frame) + .field("mc_fpreg", &self.mc_fpreg) + .field("mc_vsxfpreg", &self.mc_vsxfpreg) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.mc_vers.hash(state); + self.mc_flags.hash(state); + self.mc_onstack.hash(state); + self.mc_len.hash(state); + self.mc_avec.hash(state); + self.mc_av.hash(state); + self.mc_frame.hash(state); + self.mc_fpreg.hash(state); + self.mc_vsxfpreg.hash(state); + } + } + } +} + // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { if #[cfg(libc_const_size_of)] { diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 31a660e7d0a22..e33c8e4adae7b 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -41,17 +41,6 @@ s_no_extra_traits! { } } -s! { - pub struct ucontext_t { - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: ::mcontext_t, - pub uc_link: *mut ::ucontext_t, - pub uc_stack: ::stack_t, - pub uc_flags: ::c_int, - __spare__: [::c_int; 4], - } -} - // should be pub(crate), but that requires Rust 1.18.0 cfg_if! { if #[cfg(libc_const_size_of)] { @@ -127,7 +116,8 @@ cfg_if! { .field("mc_fpformat", &self.mc_fpformat) .field("mc_ownedfp", &self.mc_ownedfp) .field("mc_flags", &self.mc_flags) - .field("mc_fpstate", &self.mc_fpstate) + // FIXME(msrv) debug not supported for arrays in old MSRV + // .field("mc_fpstate", &self.mc_fpstate) .field("mc_fsbase", &self.mc_fsbase) .field("mc_gsbase", &self.mc_gsbase) .field("mc_xfpustate", &self.mc_xfpustate) diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs index 3a016a0519852..208e7f2c90c0a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs @@ -184,14 +184,3 @@ cfg_if! { } } } - -s! { - pub struct ucontext_t { - pub uc_sigmask: ::sigset_t, - pub uc_mcontext: ::mcontext_t, - pub uc_link: *mut ::ucontext_t, - pub uc_stack: ::stack_t, - pub uc_flags: ::c_int, - __spare__: [::c_int; 4], - } -} From fabc6d10a4ab1c3bca79da0ee2038d4c27532765 Mon Sep 17 00:00:00 2001 From: Callum Thomson Date: Tue, 24 Sep 2024 19:10:55 +0100 Subject: [PATCH 02/11] Fix alignment of uc_ucontext fields on arm64 android (#3894) [ change `core` to `::core` and move ucontext_t to s_no_extra_traits for backport - Trevor ] (backport ) (cherry picked from commit 707d32cddd461854c81af494f2f488b273520586) --- src/unix/linux_like/android/b64/aarch64/align.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/android/b64/aarch64/align.rs b/src/unix/linux_like/android/b64/aarch64/align.rs index 154c2c54ce6de..9832303d7ac46 100644 --- a/src/unix/linux_like/android/b64/aarch64/align.rs +++ b/src/unix/linux_like/android/b64/aarch64/align.rs @@ -4,17 +4,19 @@ s_no_extra_traits! { pub struct max_align_t { priv_: [f32; 8] } -} -s! { + #[allow(missing_debug_implementations)] pub struct ucontext_t { pub uc_flags: ::c_ulong, pub uc_link: *mut ucontext_t, pub uc_stack: ::stack_t, pub uc_sigmask: ::sigset_t, + pub __pad: [u8; 1024 / 8 - ::core::mem::size_of::<::sigset_t>()], pub uc_mcontext: mcontext_t, } +} +s! { #[repr(align(16))] pub struct mcontext_t { pub fault_address: ::c_ulonglong, From 39e6c0963bf522f9eb36e796d823e342c720779d Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Mon, 23 Sep 2024 10:25:07 -0600 Subject: [PATCH 03/11] Fix the definition of mc_fpstate on FreeBSD x86 The definition added in b811b70f6676a24c16a786a3549eb6b35071c13c was technically wrong even though the type size was correct. It was probably defined this way because earlier versions of Rust had difficulty with fixed-size arrays of size greater than 32. This change is necessary for CI to pass on x86 FreeBSD. https://github.com/freebsd/freebsd-src/blob/main/sys/x86/include/ucontext.h (backport ) (cherry picked from commit ad2d864d0a75eb9d9c2c44a03b31fa6a7045ce5f) --- src/unix/bsd/freebsdlike/freebsd/x86.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index e33c8e4adae7b..5cb9cb6406eab 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -32,7 +32,7 @@ s_no_extra_traits! { pub mc_fpformat: ::c_int, pub mc_ownedfp: ::c_int, pub mc_flags: register_t, - pub mc_fpstate: [[::c_int; 32]; 4], + pub mc_fpstate: [::c_int; 128], pub mc_fsbase: register_t, pub mc_gsbase: register_t, pub mc_xfpustate: register_t, From c8a0faf826d91b7609cff1ade2072e50f07464ed Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 27 Sep 2024 17:19:51 -0600 Subject: [PATCH 04/11] Fix alignment of mcontext_t on FreeBSD x86 https://github.com/freebsd/freebsd-src/blob/main/sys/x86/include/ucontext.h (backport ) (cherry picked from commit 908fc71c07262473dba532fd83f4494276b1b2ec) --- src/unix/bsd/freebsdlike/freebsd/x86.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 5cb9cb6406eab..72d8add09ae83 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -7,6 +7,7 @@ pub type suseconds_t = i32; pub type register_t = i32; s_no_extra_traits! { + #[repr(align(16))] pub struct mcontext_t { pub mc_onstack: register_t, pub mc_gs: register_t, From b5aeb939e7c5205569a4364b81f627a843d7aa76 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Wed, 6 Nov 2024 16:11:47 -0600 Subject: [PATCH 05/11] Gate FreeBSD `mcontext_t` under `libc_align` Enable this backport by just dropping support for FreeBSD mcontext_t without `libc_align`, i.e. with Rust < 1.25 (2018). This is sufficiently niche that it is not worth adding a new `align` module. --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 4 +- src/unix/bsd/freebsdlike/freebsd/x86.rs | 72 +++++++++++++------------ 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index dda108e8c0ef2..4551f405a48df 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1657,6 +1657,7 @@ s_no_extra_traits! { pub struct ucontext_t { pub uc_sigmask: ::sigset_t, + #[cfg(libc_align)] pub uc_mcontext: ::mcontext_t, pub uc_link: *mut ::ucontext_t, pub uc_stack: ::stack_t, @@ -2670,7 +2671,8 @@ cfg_if! { fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("ucontext_t") .field("uc_sigmask", &self.uc_sigmask) - .field("uc_mcontext", &self.uc_mcontext) + // FIXME: enable when libc_align is dropped + // .field("uc_mcontext", &self.uc_mcontext) .field("uc_link", &self.uc_link) .field("uc_stack", &self.uc_stack) .field("uc_flags", &self.uc_flags) diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 72d8add09ae83..fce0e7940f9ca 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -6,39 +6,43 @@ pub type time_t = i32; pub type suseconds_t = i32; pub type register_t = i32; -s_no_extra_traits! { - #[repr(align(16))] - pub struct mcontext_t { - pub mc_onstack: register_t, - pub mc_gs: register_t, - pub mc_fs: register_t, - pub mc_es: register_t, - pub mc_ds: register_t, - pub mc_edi: register_t, - pub mc_esi: register_t, - pub mc_ebp: register_t, - pub mc_isp: register_t, - pub mc_ebx: register_t, - pub mc_edx: register_t, - pub mc_ecx: register_t, - pub mc_eax: register_t, - pub mc_trapno: register_t, - pub mc_err: register_t, - pub mc_eip: register_t, - pub mc_cs: register_t, - pub mc_eflags: register_t, - pub mc_esp: register_t, - pub mc_ss: register_t, - pub mc_len: ::c_int, - pub mc_fpformat: ::c_int, - pub mc_ownedfp: ::c_int, - pub mc_flags: register_t, - pub mc_fpstate: [::c_int; 128], - pub mc_fsbase: register_t, - pub mc_gsbase: register_t, - pub mc_xfpustate: register_t, - pub mc_xfpustate_len: register_t, - pub mc_spare2: [::c_int; 4], +cfg_if! { + if #[cfg(libc_align)] { + s_no_extra_traits! { + #[repr(align(16))] + pub struct mcontext_t { + pub mc_onstack: register_t, + pub mc_gs: register_t, + pub mc_fs: register_t, + pub mc_es: register_t, + pub mc_ds: register_t, + pub mc_edi: register_t, + pub mc_esi: register_t, + pub mc_ebp: register_t, + pub mc_isp: register_t, + pub mc_ebx: register_t, + pub mc_edx: register_t, + pub mc_ecx: register_t, + pub mc_eax: register_t, + pub mc_trapno: register_t, + pub mc_err: register_t, + pub mc_eip: register_t, + pub mc_cs: register_t, + pub mc_eflags: register_t, + pub mc_esp: register_t, + pub mc_ss: register_t, + pub mc_len: ::c_int, + pub mc_fpformat: ::c_int, + pub mc_ownedfp: ::c_int, + pub mc_flags: register_t, + pub mc_fpstate: [::c_int; 128], + pub mc_fsbase: register_t, + pub mc_gsbase: register_t, + pub mc_xfpustate: register_t, + pub mc_xfpustate_len: register_t, + pub mc_spare2: [::c_int; 4], + } + } } } @@ -54,7 +58,7 @@ cfg_if! { } cfg_if! { - if #[cfg(feature = "extra_traits")] { + if #[cfg(all(libc_align, feature = "extra_traits"))] { impl PartialEq for mcontext_t { fn eq(&self, other: &mcontext_t) -> bool { self.mc_onstack == other.mc_onstack && From 36b034994d96a9fb57e49fb3fa1df7fa10764fec Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Mon, 23 Sep 2024 11:06:35 -0600 Subject: [PATCH 06/11] Fix the definition of domainset_t in 32-bit FreeBSD It's always had the wrong size, but apparently never been tested on 32-bit FreeBSD. In addition to fixing its size, it ought to be moved info freebsd/mod.rs . Otherwise it's pretty much inaccessible to everyone. https://github.com/freebsd/freebsd-src/blob/main/sys/sys/_domainset.h (backport ) (cherry picked from commit 19d213d883cbe8a321fa2b0b559479f9033ac374) --- src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs | 5 ++++- src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs | 5 ++++- src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index 118404e8b089b..e6cc1fad0b591 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -41,7 +41,10 @@ s! { } pub struct __c_anonymous_domainset { - _priv: [::uintptr_t; 4], + #[cfg(target_pointer_width = "64")] + _priv: [::c_ulong; 4], + #[cfg(target_pointer_width = "32")] + _priv: [::c_ulong; 8], } pub struct kinfo_proc { diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index e624dd7201b0a..1c58bb4b5afcf 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -41,7 +41,10 @@ s! { } pub struct __c_anonymous_domainset { - _priv: [::uintptr_t; 4], + #[cfg(target_pointer_width = "64")] + _priv: [::c_ulong; 4], + #[cfg(target_pointer_width = "32")] + _priv: [::c_ulong; 8], } pub struct kinfo_proc { diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index a299af7d5d53e..00ea22a041a7d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -41,7 +41,10 @@ s! { } pub struct __c_anonymous_domainset { - _priv: [::uintptr_t; 4], + #[cfg(target_pointer_width = "64")] + _priv: [::c_ulong; 4], + #[cfg(target_pointer_width = "32")] + _priv: [::c_ulong; 8], } pub struct kinfo_proc { From d56110e5ad2365f880e42129bdb829b733c9635a Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 27 Sep 2024 17:26:09 -0600 Subject: [PATCH 07/11] Fix definition of TIOCTIMESTAMP on FreeBSD x86 https://github.com/freebsd/freebsd-src/blob/main/sys/sys/ttycom.h (backport ) (cherry picked from commit 60cf16dd91bf20d68ace4c2391a4f74c80a32d78) --- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 1 + src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 1 + src/unix/bsd/freebsdlike/freebsd/arm.rs | 1 + src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 1 + src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 1 + src/unix/bsd/freebsdlike/freebsd/riscv64.rs | 1 + src/unix/bsd/freebsdlike/freebsd/x86.rs | 1 + src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs | 2 ++ src/unix/bsd/freebsdlike/mod.rs | 1 - 9 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index 9b3b872d03948..7bff483df6ae5 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1462,6 +1462,7 @@ pub const TIOCISPTMASTER: ::c_ulong = 0x20007455; pub const TIOCMODG: ::c_ulong = 0x40047403; pub const TIOCMODS: ::c_ulong = 0x80047404; pub const TIOCREMOTE: ::c_ulong = 0x80047469; +pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; // Constants used by "at" family of system calls. pub const AT_FDCWD: ::c_int = 0xFFFAFDCD; // invalid file descriptor diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index e8be8815c028e..7dc0fd0ff938f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -144,3 +144,4 @@ cfg_if! { pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 +pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 965abd33f0a48..774018f0a89f9 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -62,3 +62,4 @@ cfg_if! { pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 +pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index d856e80226746..bd72039a71a8e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -85,3 +85,4 @@ cfg_if! { pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 +pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index ec1c17e32db3f..b891cc1b75d4f 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -85,3 +85,4 @@ cfg_if! { pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 +pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index f9fa1c2750b22..37989883cdb09 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -152,3 +152,4 @@ cfg_if! { pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 +pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index fce0e7940f9ca..b1f1b0433be4c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -171,3 +171,4 @@ cfg_if! { pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 pub const KINFO_FILE_SIZE: ::c_int = 1392; +pub const TIOCTIMESTAMP: ::c_ulong = 0x40087459; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index fb4597927f3d6..fabb83efc0add 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -265,6 +265,8 @@ pub const _MC_FPOWNED_PCB: c_long = 0x20002; pub const KINFO_FILE_SIZE: ::c_int = 1392; +pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; + cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 6ef1a59429207..d5ae29d2a620b 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1251,7 +1251,6 @@ pub const TIOCGETD: ::c_ulong = 0x4004741a; pub const TIOCSETD: ::c_ulong = 0x8004741b; pub const TIOCGDRAINWAIT: ::c_ulong = 0x40047456; pub const TIOCSDRAINWAIT: ::c_ulong = 0x80047457; -pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; pub const TIOCMGDTRWAIT: ::c_ulong = 0x4004745a; pub const TIOCMSDTRWAIT: ::c_ulong = 0x8004745b; pub const TIOCDRAIN: ::c_ulong = 0x2000745e; From edb64128f21f6f1d13777f0fcc1d9e9f4c6dbbc8 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 27 Sep 2024 17:29:06 -0600 Subject: [PATCH 08/11] Fix the definition of several BPF related ioctls on 32-bit FreeBSD https://github.com/freebsd/freebsd-src/blob/main/sys/net/bpf.h (backport ) (cherry picked from commit cfbc1203e4b4fe0fb37f7639f9b740aa2e401cb8) --- src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 2 ++ src/unix/bsd/freebsdlike/freebsd/arm.rs | 2 ++ src/unix/bsd/freebsdlike/freebsd/mod.rs | 8 +++++++- src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 2 ++ src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 2 ++ src/unix/bsd/freebsdlike/freebsd/riscv64.rs | 2 ++ src/unix/bsd/freebsdlike/freebsd/x86.rs | 2 ++ src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs | 4 ++++ src/unix/bsd/freebsdlike/mod.rs | 13 +++++++++---- 9 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 7dc0fd0ff938f..95cf8a2b46e2a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -142,6 +142,8 @@ cfg_if! { } } +pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 774018f0a89f9..1cf4f55845c67 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -60,6 +60,8 @@ cfg_if! { } } +pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 4551f405a48df..ef526fabce860 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3212,7 +3212,13 @@ pub const H4DISC: ::c_int = 0x7; pub const VM_TOTAL: ::c_int = 1; -pub const BIOCSETFNR: ::c_ulong = 0x80104282; +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + pub const BIOCSETFNR: ::c_ulong = 0x80104282; + } else { + pub const BIOCSETFNR: ::c_ulong = 0x80084282; + } +} pub const FIODGNAME: ::c_ulong = 0x80106678; pub const FIONWRITE: ::c_ulong = 0x40046677; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index bd72039a71a8e..9e76f3f5de61d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -83,6 +83,8 @@ cfg_if! { } } +pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index b891cc1b75d4f..6902e16fb7bc5 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -83,6 +83,8 @@ cfg_if! { } } +pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index 37989883cdb09..7e2c629503c6c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -150,6 +150,8 @@ cfg_if! { } } +pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index b1f1b0433be4c..228970979d5af 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -170,5 +170,7 @@ cfg_if! { pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 +pub const BIOCSRTIMEOUT: ::c_ulong = 0x8008426d; +pub const BIOCGRTIMEOUT: ::c_ulong = 0x4008426e; pub const KINFO_FILE_SIZE: ::c_int = 1392; pub const TIOCTIMESTAMP: ::c_ulong = 0x40087459; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index fabb83efc0add..75d24c7885a07 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -249,6 +249,10 @@ cfg_if! { pub const _ALIGNBYTES: usize = 8 - 1; } } + +pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; +pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; + pub const MAP_32BIT: ::c_int = 0x00080000; pub const MINSIGSTKSZ: ::size_t = 2048; // 512 * 4 diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index d5ae29d2a620b..d4749178f3c2c 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1305,10 +1305,15 @@ pub const BIOCSRSIG: ::c_ulong = 0x80044273; pub const BIOCSDLT: ::c_ulong = 0x80044278; pub const BIOCGSEESENT: ::c_ulong = 0x40044276; pub const BIOCSSEESENT: ::c_ulong = 0x80044277; -pub const BIOCSETF: ::c_ulong = 0x80104267; -pub const BIOCGDLTLIST: ::c_ulong = 0xc0104279; -pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d; -pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e; +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + pub const BIOCGDLTLIST: ::c_ulong = 0xc0104279; + pub const BIOCSETF: ::c_ulong = 0x80104267; + } else if #[cfg(target_pointer_width = "32")] { + pub const BIOCGDLTLIST: ::c_ulong = 0xc0084279; + pub const BIOCSETF: ::c_ulong = 0x80084267; + } +} pub const FIODTYPE: ::c_ulong = 0x4004667a; pub const FIOGETLBA: ::c_ulong = 0x40046679; From 8286345bcd00769eac11ee41a0cf974ff0b4298c Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 27 Sep 2024 17:37:05 -0600 Subject: [PATCH 09/11] Fix definition of clock_t on FreeBSD x86, powerpc, powerpc64, and arm. https://github.com/freebsd/freebsd-src/blob/main/sys/arm/include/_types.h https://github.com/freebsd/freebsd-src/blob/main/sys/arm64/include/_types.h https://github.com/freebsd/freebsd-src/blob/main/sys/powerpc/include/_types.h https://github.com/freebsd/freebsd-src/blob/main/sys/riscv/include/_types.h https://github.com/freebsd/freebsd-src/blob/main/sys/x86/include/_types.h (backport ) (cherry picked from commit 6605f08aeade93fb6d01c91a13d84769735dc172) --- src/unix/bsd/freebsdlike/freebsd/aarch64.rs | 1 + src/unix/bsd/freebsdlike/freebsd/arm.rs | 1 + src/unix/bsd/freebsdlike/freebsd/mod.rs | 1 - src/unix/bsd/freebsdlike/freebsd/powerpc.rs | 1 + src/unix/bsd/freebsdlike/freebsd/powerpc64.rs | 1 + src/unix/bsd/freebsdlike/freebsd/riscv64.rs | 1 + src/unix/bsd/freebsdlike/freebsd/x86.rs | 1 + src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs | 1 + 8 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 95cf8a2b46e2a..004b6266ea863 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -1,6 +1,7 @@ pub type c_char = u8; pub type c_long = i64; pub type c_ulong = u64; +pub type clock_t = i32; pub type wchar_t = u32; pub type time_t = i64; pub type suseconds_t = i64; diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index 1cf4f55845c67..c5c79323f727e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -1,6 +1,7 @@ pub type c_char = u8; pub type c_long = i32; pub type c_ulong = u32; +pub type clock_t = u32; pub type wchar_t = u32; pub type time_t = i64; pub type suseconds_t = i32; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index ef526fabce860..c04e26f4d8250 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1,5 +1,4 @@ pub type fflags_t = u32; -pub type clock_t = i32; pub type vm_prot_t = u_char; pub type kvaddr_t = u64; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs index 9e76f3f5de61d..f85df97f3666a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -1,6 +1,7 @@ pub type c_char = u8; pub type c_long = i32; pub type c_ulong = u32; +pub type clock_t = u32; pub type wchar_t = i32; pub type time_t = i64; pub type suseconds_t = i32; diff --git a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs index 6902e16fb7bc5..1b2d59c31c0cd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -1,6 +1,7 @@ pub type c_char = u8; pub type c_long = i64; pub type c_ulong = u64; +pub type clock_t = u32; pub type wchar_t = i32; pub type time_t = i64; pub type suseconds_t = i64; diff --git a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs index 7e2c629503c6c..bad84177e6f0a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -1,6 +1,7 @@ pub type c_char = u8; pub type c_long = i64; pub type c_ulong = u64; +pub type clock_t = i32; pub type wchar_t = ::c_int; pub type time_t = i64; pub type suseconds_t = ::c_long; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs index 228970979d5af..b9da7caa2001e 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -1,6 +1,7 @@ pub type c_char = i8; pub type c_long = i32; pub type c_ulong = u32; +pub type clock_t = ::c_ulong; pub type wchar_t = i32; pub type time_t = i32; pub type suseconds_t = i32; diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index 75d24c7885a07..446cc22dd1ba1 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -1,6 +1,7 @@ pub type c_char = i8; pub type c_long = i64; pub type c_ulong = u64; +pub type clock_t = i32; pub type wchar_t = i32; pub type time_t = i64; pub type suseconds_t = i64; From 255b039d9e46316eda681cc38e1d627ce1fb8068 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 27 Sep 2024 17:49:50 -0600 Subject: [PATCH 10/11] Fix size of struct kinfo_file on 32-bit FreeBSD https://github.com/freebsd/freebsd-src/blob/main/sys/sys/user.h (backport ) (cherry picked from commit f2b8b8f8c753755e74c5f0ae3440ea59b5909383) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index c04e26f4d8250..106e41765b9e5 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1645,7 +1645,7 @@ s_no_extra_traits! { pub kf_flags: ::c_int, _kf_pad0: ::c_int, pub kf_offset: i64, - _priv: [::uintptr_t; 38], // FIXME if needed + _priv: [u8; 304], // FIXME: this is really a giant union pub kf_status: u16, _kf_pad1: u16, _kf_ispare0: ::c_int, From 073c7b4b89f4a9d4cdb4dbda674e55c73a50d1c8 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 27 Sep 2024 17:56:33 -0600 Subject: [PATCH 11/11] Fix definition of FIODGNAME on 32-bit FreeBSD https://github.com/freebsd/freebsd-src/blob/main/sys/sys/filio.h (backport ) (cherry picked from commit 0b6cab8f19d32248fd84788475747ffb6708318a) --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 106e41765b9e5..56ceabe6aacb8 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3219,7 +3219,14 @@ cfg_if! { } } -pub const FIODGNAME: ::c_ulong = 0x80106678; +cfg_if! { + if #[cfg(target_pointer_width = "64")] { + pub const FIODGNAME: ::c_ulong = 0x80106678; + } else { + pub const FIODGNAME: ::c_ulong = 0x80086678; + } +} + pub const FIONWRITE: ::c_ulong = 0x40046677; pub const FIONSPACE: ::c_ulong = 0x40046676; pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;