You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aya/test/integration-common/src/lib.rs

54 lines
1.3 KiB
Rust

#![no_std]
pub mod bpf_probe_read {
pub const RESULT_BUF_LEN: usize = 1024;
#[derive(Copy, Clone)]
#[repr(C)]
pub struct TestResult {
pub buf: [u8; RESULT_BUF_LEN],
pub len: Option<Result<usize, i64>>,
}
#[cfg(feature = "user")]
unsafe impl aya::Pod for TestResult {}
}
pub mod ring_buf {
// This structure's definition is duplicated in the probe.
#[repr(C)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Default)]
pub struct Registers {
pub dropped: u64,
pub rejected: u64,
}
impl core::ops::Add for Registers {
type Output = Self;
fn add(self, rhs: Self) -> Self::Output {
Self {
dropped: self.dropped + rhs.dropped,
rejected: self.rejected + rhs.rejected,
}
}
}
impl<'a> core::iter::Sum<&'a Registers> for Registers {
fn sum<I: Iterator<Item = &'a Registers>>(iter: I) -> Self {
iter.fold(Default::default(), |a, b| a + *b)
}
}
#[cfg(feature = "user")]
unsafe impl aya::Pod for Registers {}
}
pub mod strncmp {
#[derive(Copy, Clone)]
#[repr(C)]
pub struct TestResult(pub core::cmp::Ordering);
#[cfg(feature = "user")]
unsafe impl aya::Pod for TestResult {}
}