#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
#[repr(u8)]
pub enum JustInTimeCompilationChoice
{
#[allow(missing_docs)]
Interpreted = 0,
#[allow(missing_docs)]
Enabled = 1,
#[allow(missing_docs)]
EnabledWithDebugLogging = 2,
}
impl Default for JustInTimeCompilationChoice
{
fn default() -> Self
{
JustInTimeCompilationChoice::Interpreted
}
}
impl ParseNumber for JustInTimeCompilationChoice
{
#[inline(always)]
fn parse_number(bytes: &[u8], radix: Radix, parse_byte: impl Fn(Radix, u8) -> Result<u8, ParseNumberError>) -> Result<Self, ParseNumberError>
{
let raw_value = u8::parse_number(bytes, radix, parse_byte)?;
if unlikely!(raw_value > 2)
{
Err(ParseNumberError::TooLarge)
}
else
{
Ok(unsafe { transmute(raw_value) })
}
}
}
impl JustInTimeCompilationChoice
{
#[inline(always)]
pub fn value(proc_path: &ProcPath) -> io::Result<Self>
{
Self::sys_net_core_bpf_jit_enable_file_path(proc_path).read_value()
}
#[inline(always)]
pub fn set_value(self, proc_path: &ProcPath) -> io::Result<()>
{
assert_effective_user_id_is_root("write to /proc/sys/net/core/bpf_jit_enable");
let file_path = Self::sys_net_core_bpf_jit_enable_file_path(proc_path);
if file_path.exists()
{
file_path.write_value(UnpaddedDecimalInteger(self as u8))
}
else
{
Ok(())
}
}
#[inline(always)]
fn sys_net_core_bpf_jit_enable_file_path(proc_path: &ProcPath) -> PathBuf
{
proc_path.sys_net_core_file_path("bpf_jit_enable")
}
}