bpf: add memset impl that doesn't trip the verifier

Add a verifier proof memset implementation. This is a quick hack until
we fix compiler-builtins for the bpf target.
pull/66/head
Alessandro Decina 3 years ago
parent 64e3fb4cc8
commit 32350f81b7

@ -10,7 +10,7 @@ pub mod programs;
pub use aya_bpf_cty as cty;
use core::ffi::c_void;
use cty::{c_char, c_long};
use cty::{c_char, c_int, c_long};
use helpers::{bpf_get_current_comm, bpf_get_current_pid_tgid};
pub use aya_bpf_macros as macros;
@ -33,3 +33,11 @@ pub trait BpfContext {
(bpf_get_current_pid_tgid() >> 32) as u32
}
}
#[no_mangle]
pub unsafe extern "C" fn memset(s: *mut u8, c: c_int, n: usize) {
let base = s as usize;
for i in 0..n {
*((base + i) as *mut u8) = c as u8;
}
}

Loading…
Cancel
Save