aya-obj,aya-ebpf-*: hook up loongarch64

This causes rustfmt to format those files.

Squish some other conditional compilation to get rustfmt sorting.
reviewable/pr1203/r1
Tamir Duberstein 1 week ago
parent 9916092f5c
commit 6252b4c972

@ -47,11 +47,7 @@ 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) {

@ -1,10 +1,17 @@
//! eBPF bindings generated by rust-bindgen
mod btf_internal_bindings;
// don't re-export __u8 __u16 etc which are already exported by the
// linux_bindings_* module
pub use btf_internal_bindings::{bpf_core_relo, bpf_core_relo_kind, btf_ext_header};
#[cfg(target_arch = "aarch64")]
mod linux_bindings_aarch64;
#[cfg(target_arch = "arm")]
mod linux_bindings_armv7;
#[cfg(target_arch = "loongarch64")]
mod linux_bindings_loongarch64;
#[cfg(target_arch = "mips")]
mod linux_bindings_mips;
#[cfg(target_arch = "powerpc64")]
@ -16,13 +23,12 @@ mod linux_bindings_s390x;
#[cfg(target_arch = "x86_64")]
mod linux_bindings_x86_64;
// don't re-export __u8 __u16 etc which are already exported by the
// linux_bindings_* module
pub use btf_internal_bindings::{bpf_core_relo, bpf_core_relo_kind, btf_ext_header};
#[cfg(target_arch = "aarch64")]
pub use linux_bindings_aarch64::*;
#[cfg(target_arch = "arm")]
pub use linux_bindings_armv7::*;
#[cfg(target_arch = "loongarch64")]
pub use linux_bindings_loongarch64::*;
#[cfg(target_arch = "mips")]
pub use linux_bindings_mips::*;
#[cfg(target_arch = "powerpc64")]

@ -12,7 +12,18 @@ fn main() {
}
println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
}
println!(
"cargo::rustc-check-cfg=cfg(bpf_target_arch, values(\"x86_64\",\"arm\",\"aarch64\",\"riscv64\",\"powerpc64\",\"s390x\",\"mips\"))"
);
print!("cargo::rustc-check-cfg=cfg(bpf_target_arch, values(");
for arch in [
"aarch64",
"arm",
"loongarch64",
"mips",
"powerpc64",
"riscv64",
"s390x",
"x86_64",
] {
print!("\"{arch}\",");
}
println!("))");
}

@ -1,2 +0,0 @@
pub mod bindings;
pub mod helpers;

@ -1,2 +0,0 @@
pub mod bindings;
pub mod helpers;

@ -1,40 +1,60 @@
#![expect(
clippy::all,
dead_code,
non_camel_case_types,
non_snake_case,
non_upper_case_globals,
unsafe_op_in_unsafe_fn
)]
#![deny(warnings)]
#![no_std]
#[cfg(bpf_target_arch = "x86_64")]
mod x86_64;
#[cfg(bpf_target_arch = "arm")]
mod armv7;
#[cfg(bpf_target_arch = "aarch64")]
mod aarch64;
#[cfg(bpf_target_arch = "riscv64")]
mod riscv64;
mod aarch64 {
pub mod bindings;
pub mod helpers;
}
#[cfg(bpf_target_arch = "arm")]
mod armv7 {
pub mod bindings;
pub mod helpers;
}
#[cfg(bpf_target_arch = "loongarch64")]
mod loongarch64 {
pub mod bindings;
pub mod helpers;
}
#[cfg(bpf_target_arch = "mips")]
mod mips {
pub mod bindings;
pub mod helpers;
}
#[cfg(bpf_target_arch = "powerpc64")]
mod powerpc64;
mod powerpc64 {
pub mod bindings;
pub mod helpers;
}
#[cfg(bpf_target_arch = "riscv64")]
mod riscv64 {
pub mod bindings;
pub mod helpers;
}
#[cfg(bpf_target_arch = "s390x")]
mod s390x;
#[cfg(bpf_target_arch = "mips")]
mod mips;
mod s390x {
pub mod bindings;
pub mod helpers;
}
#[cfg(bpf_target_arch = "x86_64")]
mod x86_64 {
pub mod bindings;
pub mod helpers;
}
mod generated {
#[cfg(bpf_target_arch = "aarch64")]
pub use super::aarch64::*;
#[cfg(bpf_target_arch = "arm")]
pub use super::armv7::*;
#[cfg(bpf_target_arch = "loongarch64")]
pub use super::loongarch64::*;
#[cfg(bpf_target_arch = "mips")]
pub use super::mips::*;
#[cfg(bpf_target_arch = "powerpc64")]
@ -46,6 +66,7 @@ mod generated {
#[cfg(bpf_target_arch = "x86_64")]
pub use super::x86_64::*;
}
pub use generated::helpers;
pub mod bindings {
@ -61,7 +82,7 @@ pub mod bindings {
pub const TC_ACT_REDIRECT: i32 = crate::generated::bindings::TC_ACT_REDIRECT as i32;
pub const TC_ACT_TRAP: i32 = crate::generated::bindings::TC_ACT_TRAP as i32;
pub const TC_ACT_VALUE_MAX: i32 = crate::generated::bindings::TC_ACT_VALUE_MAX as i32;
pub const TC_ACT_EXT_VAL_MASK: i32 = 268435455;
pub const TC_ACT_EXT_VAL_MASK: i32 = crate::generated::bindings::TC_ACT_EXT_VAL_MASK as i32;
#[repr(C)]
#[derive(Debug, Copy, Clone)]

@ -45,11 +45,7 @@ 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) {

@ -1,2 +0,0 @@
pub mod bindings;
pub mod helpers;

@ -1,2 +0,0 @@
pub mod bindings;
pub mod helpers;

@ -1,2 +0,0 @@
pub mod bindings;
pub mod helpers;

@ -1,2 +0,0 @@
pub mod bindings;
pub mod helpers;

@ -1,2 +0,0 @@
pub mod bindings;
pub mod helpers;

@ -12,8 +12,20 @@ fn main() {
}
println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
}
println!(
"cargo::rustc-check-cfg=cfg(bpf_target_arch, values(\"x86_64\",\"arm\",\"aarch64\",\"riscv64\",\"powerpc64\",\"s390x\",\"mips\"))"
);
print!("cargo::rustc-check-cfg=cfg(bpf_target_arch, values(");
for arch in [
"aarch64",
"arm",
"loongarch64",
"mips",
"powerpc64",
"riscv64",
"s390x",
"x86_64",
] {
print!("\"{arch}\",");
}
println!("))");
println!("cargo::rustc-check-cfg=cfg(target_arch, values(\"asmjs\",\"nvptx\",\"xtensa\"))");
}

@ -6,7 +6,6 @@
//! versions but that may change in any new patch release.
#![no_std]
#![expect(non_camel_case_types)]
#![deny(warnings)]
// AD = Architecture dependent
pub use ad::*;
@ -18,25 +17,17 @@ mod ad {
pub type c_int = i32;
pub type c_uint = u32;
#[cfg(bpf_target_arch = "arm")]
#[cfg(any(
bpf_target_arch = "aarch64",
bpf_target_arch = "arm",
bpf_target_arch = "powerpc64",
bpf_target_arch = "riscv64",
bpf_target_arch = "s390x",
bpf_target_arch = "mips",
))]
pub type c_char = super::c_uchar;
#[cfg(bpf_target_arch = "aarch64")]
pub type c_char = super::c_uchar;
#[cfg(bpf_target_arch = "powerpc64")]
pub type c_char = super::c_uchar;
#[cfg(bpf_target_arch = "riscv64")]
pub type c_char = super::c_uchar;
#[cfg(bpf_target_arch = "s390x")]
pub type c_char = super::c_uchar;
#[cfg(bpf_target_arch = "mips")]
pub type c_char = super::c_uchar;
#[cfg(bpf_target_arch = "x86_64")]
#[cfg(any(bpf_target_arch = "loongarch64", bpf_target_arch = "x86_64"))]
pub type c_char = super::c_schar;
}
@ -60,14 +51,15 @@ mod ad {
}
#[cfg(any(
target_arch = "loongarch64",
target_arch = "mips",
target_arch = "mips64",
target_arch = "nvptx",
target_arch = "nvptx64",
target_arch = "sparc64",
target_arch = "x86",
target_arch = "x86_64",
target_arch = "nvptx",
target_arch = "nvptx64",
target_arch = "xtensa"
target_arch = "xtensa",
))]
mod ad {
pub type c_char = super::c_schar;

@ -13,9 +13,21 @@ fn main() {
}
println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
}
println!(
"cargo::rustc-check-cfg=cfg(bpf_target_arch, values(\"x86_64\",\"arm\",\"aarch64\",\"riscv64\",\"powerpc64\",\"s390x\",\"mips\"))"
);
print!("cargo::rustc-check-cfg=cfg(bpf_target_arch, values(");
for arch in [
"aarch64",
"arm",
"loongarch64",
"mips",
"powerpc64",
"riscv64",
"s390x",
"x86_64",
] {
print!("\"{arch}\",");
}
println!("))");
println!("cargo::rustc-check-cfg=cfg(unstable)");
}

@ -1,14 +1,16 @@
#[cfg(any(
bpf_target_arch = "x86_64",
bpf_target_arch = "arm",
bpf_target_arch = "powerpc64",
bpf_target_arch = "mips",
bpf_target_arch = "powerpc64",
bpf_target_arch = "x86_64",
))]
use crate::bindings::pt_regs;
// aarch64 uses user_pt_regs instead of pt_regs
#[cfg(any(bpf_target_arch = "aarch64", bpf_target_arch = "s390x"))]
#[cfg(any(
bpf_target_arch = "aarch64",
bpf_target_arch = "loongarch64",
bpf_target_arch = "s390x",
))]
use crate::bindings::user_pt_regs as pt_regs;
// riscv64 uses user_regs_struct instead of pt_regs
#[cfg(bpf_target_arch = "riscv64")]
use crate::bindings::user_regs_struct as pt_regs;
use crate::{bindings::bpf_raw_tracepoint_args, cty::c_void, helpers::bpf_probe_read};

@ -11,7 +11,6 @@
#![cfg_attr(unstable, expect(incomplete_features), feature(generic_const_exprs))]
#![cfg_attr(unstable, feature(never_type))]
#![cfg_attr(target_arch = "bpf", feature(asm_experimental_arch))]
#![deny(warnings)]
#![warn(clippy::cast_lossless, clippy::cast_sign_loss)]
#![no_std]

Loading…
Cancel
Save