diff --git a/Cargo.toml b/Cargo.toml index 2b03001..4775ad3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,8 @@ authors = [ "Daniel Xu ", ] 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 = [ diff --git a/build.rs b/build.rs index 75b35bf..e365d8a 100644 --- a/build.rs +++ b/build.rs @@ -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) diff --git a/rebuild.sh b/rebuild.sh index 83421d8..d4218dc 100755 --- a/rebuild.sh +++ b/rebuild.sh @@ -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 @@ -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 diff --git a/src/bindings.rs b/src/bindings.rs index d1c35e8..504e5ac 100644 --- a/src/bindings.rs +++ b/src/bindings.rs @@ -49,7 +49,11 @@ where index % 8 }; let mask = 1 << bit_index; - if val { byte | mask } else { byte & !mask } + if val { + byte | mask + } else { + byte & !mask + } } #[inline] pub fn set_bit(&mut self, index: usize, val: bool) { @@ -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( @@ -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; @@ -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; @@ -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( @@ -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(