Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ authors = [
"Daniel Xu <[email protected]>",
]
license = "BSD-2-Clause"
edition = "2018"
edition = "2021"
rust-version = "1.82" # first stable release to support "unsafe extern"
build = "build.rs"
links = "bpf"
exclude = [
Expand Down
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ fn generate_bindings(src_dir: path::PathBuf) {
&path::PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR should always be set"));

bindgen::Builder::default()
.rust_target(env!("CARGO_PKG_RUST_VERSION").parse().expect("valid"))
.derive_default(true)
.explicit_padding(true)
.default_enum_style(bindgen::EnumVariation::Consts)
Expand Down
4 changes: 2 additions & 2 deletions rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DOCKER="docker"
set -eu -o pipefail

${DOCKER} build --platform linux/amd64 -t libbpf-sys-builder - <<'EOF'
FROM ubuntu:jammy AS libbpf-sys-builder
FROM ubuntu:latest AS libbpf-sys-builder

ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8
Expand All @@ -26,7 +26,7 @@ RUN \

ENTRYPOINT \
source $HOME/.cargo/env; \
cargo build --features bindgen-source --release --verbose;
cargo check --features bindgen-source --verbose;
EOF

${DOCKER} run --platform linux/amd64 --rm -v "$(pwd):/usr/local/src/libbpf-sys" libbpf-sys-builder
16 changes: 10 additions & 6 deletions src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ where
index % 8
};
let mask = 1 << bit_index;
if val { byte | mask } else { byte & !mask }
Copy link
Member

@alexforster alexforster Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bindgen also can't seem to decide if it wants this on one line or split across multiple. It flattened this a few commits ago, only to again explode it in this commit. Not a blocker to merge this, but odd.

if val {
byte | mask
} else {
byte & !mask
}
}
#[inline]
pub fn set_bit(&mut self, index: usize, val: bool) {
Expand Down Expand Up @@ -7422,7 +7426,7 @@ unsafe extern "C" {
}
unsafe extern "C" {
pub fn btf__add_ptr(btf: *mut btf, ref_type_id: ::std::os::raw::c_int)
-> ::std::os::raw::c_int;
-> ::std::os::raw::c_int;
}
unsafe extern "C" {
pub fn btf__add_array(
Expand Down Expand Up @@ -8426,7 +8430,7 @@ unsafe extern "C" {
}
unsafe extern "C" {
pub fn bpf_map__reuse_fd(map: *mut bpf_map, fd: ::std::os::raw::c_int)
-> ::std::os::raw::c_int;
-> ::std::os::raw::c_int;
}
unsafe extern "C" {
pub fn bpf_map__name(map: *const bpf_map) -> *const ::std::os::raw::c_char;
Expand All @@ -8442,7 +8446,7 @@ unsafe extern "C" {
}
unsafe extern "C" {
pub fn bpf_map__set_max_entries(map: *mut bpf_map, max_entries: __u32)
-> ::std::os::raw::c_int;
-> ::std::os::raw::c_int;
}
unsafe extern "C" {
pub fn bpf_map__map_flags(map: *const bpf_map) -> __u32;
Expand Down Expand Up @@ -8681,7 +8685,7 @@ unsafe extern "C" {
}
unsafe extern "C" {
pub fn bpf_tc_attach(hook: *const bpf_tc_hook, opts: *mut bpf_tc_opts)
-> ::std::os::raw::c_int;
-> ::std::os::raw::c_int;
}
unsafe extern "C" {
pub fn bpf_tc_detach(
Expand Down Expand Up @@ -8890,7 +8894,7 @@ unsafe extern "C" {
}
unsafe extern "C" {
pub fn perf_buffer__buffer_fd(pb: *const perf_buffer, buf_idx: size_t)
-> ::std::os::raw::c_int;
-> ::std::os::raw::c_int;
}
unsafe extern "C" {
pub fn perf_buffer__buffer(
Expand Down