Skip to content

Commit 90a7000

Browse files
d-e-s-odanielocfb
authored andcommitted
Fix (some?) 32 bit builds
Some 32 bit builds are broken, due to unnecessary specific casts, which lead to integer mismatches. Fix them (and a few more...). Fixes: #500
1 parent 2ef81f9 commit 90a7000

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

libbpf-rs/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Unreleased
2+
----------
3+
- Fixed build failures on 32 bit x86 and aarch32
4+
5+
16
0.21.0
27
------
38
- Added `TcHook::get_handle` and `TcHook::get_priority` methods for restoring

libbpf-rs/src/map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ impl MapHandle {
683683
};
684684

685685
let opts = libbpf_sys::bpf_map_batch_opts {
686-
sz: mem::size_of::<libbpf_sys::bpf_map_batch_opts>() as u64,
686+
sz: mem::size_of::<libbpf_sys::bpf_map_batch_opts>() as _,
687687
elem_flags: elem_flags.bits,
688688
flags: flags.bits,
689689
};

libbpf-rs/src/program.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl From<UsdtOpts> for libbpf_sys::bpf_usdt_opts {
5959
_non_exhaustive,
6060
} = opts;
6161
libbpf_sys::bpf_usdt_opts {
62-
sz: mem::size_of::<Self>() as u64,
62+
sz: mem::size_of::<Self>() as _,
6363
usdt_cookie: cookie,
6464
}
6565
}
@@ -82,7 +82,7 @@ impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
8282
} = opts;
8383

8484
libbpf_sys::bpf_tracepoint_opts {
85-
sz: mem::size_of::<Self>() as u64,
85+
sz: mem::size_of::<Self>() as _,
8686
bpf_cookie: cookie,
8787
}
8888
}
@@ -818,11 +818,11 @@ impl Program {
818818
pub fn attach_iter(&mut self, map_fd: BorrowedFd<'_>) -> Result<Link> {
819819
util::create_bpf_entity_checked(|| unsafe {
820820
let mut linkinfo = libbpf_sys::bpf_iter_link_info::default();
821-
linkinfo.map.map_fd = map_fd.as_raw_fd() as u32;
821+
linkinfo.map.map_fd = map_fd.as_raw_fd() as _;
822822
let attach_opt = libbpf_sys::bpf_iter_attach_opts {
823823
link_info: &mut linkinfo as *mut libbpf_sys::bpf_iter_link_info,
824-
link_info_len: std::mem::size_of::<libbpf_sys::bpf_iter_link_info>() as u32,
825-
sz: std::mem::size_of::<libbpf_sys::bpf_iter_attach_opts>() as u64,
824+
link_info_len: std::mem::size_of::<libbpf_sys::bpf_iter_link_info>() as _,
825+
sz: std::mem::size_of::<libbpf_sys::bpf_iter_attach_opts>() as _,
826826
..Default::default()
827827
};
828828

0 commit comments

Comments
 (0)