summaryrefslogtreecommitdiff
path: root/src/unix/bsd/freebsdlike/mod.rs
diff options
context:
space:
mode:
authorJames Lee <jbit@jbit.net>2021-02-25 17:17:50 +1100
committerJames Lee <jbit@jbit.net>2021-02-25 17:17:50 +1100
commited1256a366d6059266eb8c1df3f5b1b48dd11622 (patch)
treefcb3f2d5710ce4e79ba55e4a1d3312d6b274ab79 /src/unix/bsd/freebsdlike/mod.rs
parentec101fadd69ab081e33132f3f295cd02d6b2bc39 (diff)
downloadrust-libc-ed1256a366d6059266eb8c1df3f5b1b48dd11622.tar.gz
Fix BPF_ALIGNMENT for 32bit FreeBSD
Diffstat (limited to 'src/unix/bsd/freebsdlike/mod.rs')
-rw-r--r--src/unix/bsd/freebsdlike/mod.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index 972a0471a7..b2c896d801 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -359,6 +359,14 @@ cfg_if! {
}
}
+// Non-public helper constant
+#[cfg(all(not(libc_const_size_of), target_pointer_width = "32"))]
+const SIZEOF_LONG: usize = 4;
+#[cfg(all(not(libc_const_size_of), target_pointer_width = "64"))]
+const SIZEOF_LONG: usize = 8;
+#[cfg(libc_const_size_of)]
+const SIZEOF_LONG: usize = ::mem::size_of::<::c_long>();
+
#[deprecated(
since = "0.2.64",
note = "Can vary at runtime. Use sysconf(3) instead"
@@ -1216,8 +1224,7 @@ pub const ONLRET: ::tcflag_t = 0x40;
pub const CMGROUP_MAX: usize = 16;
// https://github.com/freebsd/freebsd/blob/master/sys/net/bpf.h
-// sizeof(long)
-pub const BPF_ALIGNMENT: ::c_int = 8;
+pub const BPF_ALIGNMENT: usize = SIZEOF_LONG;
// Values for rtprio struct (prio field) and syscall (function argument)
pub const RTP_PRIO_MIN: ::c_ushort = 0;