#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
#[derive(Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
#[repr(i32)]
pub enum TimestampCounterSetting
{
Permit = PR_TSC_ENABLE,
DenyAndSendASegmentationFaultSignal = PR_TSC_SIGSEGV,
}
impl TimestampCounterSetting
{
#[inline(always)]
pub fn set(self) -> Result<(), Errno>
{
let value: i32 = self as i32;
process_control_wrapper2(PR_SET_TSC,&value as *const i32 as usize,result_must_be_zero,Err)
}
pub fn current() -> io::Result<Self>
{
let mut value: i32 = unsafe_uninitialized();
process_control_wrapper2
(
PR_GET_TSC,
&mut value as *mut i32 as usize,
|non_negative_result| if likely!(non_negative_result == 0)
{
use self::TimestampCounterSetting::*;
match value
{
PR_TSC_ENABLE => Ok(Permit),
PR_TSC_SIGSEGV => Ok(DenyAndSendASegmentationFaultSignal),
_ => Err(io_error_invalid_data("Unknown value"))
}
}
else
{
unreachable_code(format_args!("Positive result"))
},
error_number_to_io_error,
)
}
}