From cfbc1203e4b4fe0fb37f7639f9b740aa2e401cb8 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 27 Sep 2024 17:29:06 -0600 Subject: [PATCH] Fix the definition of several BPF related ioctls on 32-bit FreeBSD https://github.com/freebsd/freebsd-src/blob/main/sys/net/bpf.h --- 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 | 3 +++ src/unix/bsd/freebsdlike/mod.rs | 13 +++++++++---- 9 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs index 552a2dfc7f42d..0a1e51df88f36 100644 --- a/src/unix/bsd/freebsdlike/freebsd/aarch64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/aarch64.rs @@ -133,6 +133,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 0458847320542..fe014117a82b2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -50,6 +50,8 @@ cfg_if! { } pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 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 = 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 fc01d8e5463b8..03f148324c97a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -3145,7 +3145,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 c5cfe543352a0..d1a5834d6134a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc.rs @@ -69,6 +69,8 @@ cfg_if! { } pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 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 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 9f2a89e579541..bcd0d69435bce 100644 --- a/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs @@ -69,6 +69,8 @@ cfg_if! { } pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 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 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 68a4a35f917c3..020d86b377daf 100644 --- a/src/unix/bsd/freebsdlike/freebsd/riscv64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/riscv64.rs @@ -141,6 +141,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 19d90b8161dc5..f0f0dfa8f0077 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -156,5 +156,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 99662c127b6a4..cfc2ba2934338 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -220,6 +220,9 @@ cfg_if! { pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 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 43469d497423b..0d049272ab2ae 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1278,10 +1278,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;