/// Defines our panic handler when compiling for eBPF.
///
/// eBPF programs are not allowed to panic, meaning this handler won't actually ever be called.
/// Because we compile with `no_std`, we need to define one.
#[cfg(target_arch = "bpf")]
#[panic_handler]
fnpanic(_info: &core::panic::PanicInfo)-> !{
loop{}
}
#[cfg(not(target_arch = "bpf"))]
#[cfg(not(target_arch = "bpf"))]
fnmain(){
fnmain(){
panic!(r#"eBPF kernels are not designed to be executed in user-space. This main function is only a placeholder to allow the code to compile on the host system (i.e. on any system that is not `target_arch = "bpf"`). This works in tandem with the `no_main` attribute which is only applied when compiling for `target_arch = "bpf"`."#)
panic!(r#"eBPF kernels are not designed to be executed in user-space. This main function is only a placeholder to allow the code to compile on the host system (i.e. on any system that is not `target_arch = "bpf"`). This works in tandem with the `no_main` attribute which is only applied when compiling for `target_arch = "bpf"`."#)
@ -153,6 +143,18 @@ macro_rules! prelude {
};
};
}
}
/// Defines our panic handler when compiling for eBPF.
///
/// eBPF programs are not allowed to panic, meaning this handler won't actually ever be called.
/// Because we compile with `no_std`, we need to define one.
///
/// Including the panic handler within `aya-ebpf` means every eBPF will automatically have this panic handler defined.