Skip to content

Commit ed1256a

Browse files
committed
Fix BPF_ALIGNMENT for 32bit FreeBSD
1 parent ec101fa commit ed1256a

File tree

1 file changed

+9
-2
lines changed
  • src/unix/bsd/freebsdlike

1 file changed

+9
-2
lines changed

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,14 @@ cfg_if! {
359359
}
360360
}
361361

362+
// Non-public helper constant
363+
#[cfg(all(not(libc_const_size_of), target_pointer_width = "32"))]
364+
const SIZEOF_LONG: usize = 4;
365+
#[cfg(all(not(libc_const_size_of), target_pointer_width = "64"))]
366+
const SIZEOF_LONG: usize = 8;
367+
#[cfg(libc_const_size_of)]
368+
const SIZEOF_LONG: usize = ::mem::size_of::<::c_long>();
369+
362370
#[deprecated(
363371
since = "0.2.64",
364372
note = "Can vary at runtime. Use sysconf(3) instead"
@@ -1216,8 +1224,7 @@ pub const ONLRET: ::tcflag_t = 0x40;
12161224
pub const CMGROUP_MAX: usize = 16;
12171225

12181226
// https://github.com/freebsd/freebsd/blob/master/sys/net/bpf.h
1219-
// sizeof(long)
1220-
pub const BPF_ALIGNMENT: ::c_int = 8;
1227+
pub const BPF_ALIGNMENT: usize = SIZEOF_LONG;
12211228

12221229
// Values for rtprio struct (prio field) and syscall (function argument)
12231230
pub const RTP_PRIO_MIN: ::c_ushort = 0;

0 commit comments

Comments
 (0)