#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)]
#[derive(Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
#[repr(i32)]
pub enum MachineCheckExceptionKillPolicy
{
Early = PR_MCE_KILL_EARLY,
Late = PR_MCE_KILL_LATE,
Default = PR_MCE_KILL_DEFAULT,
}
impl Default for MachineCheckExceptionKillPolicy
{
#[inline(always)]
fn default() -> Self
{
MachineCheckExceptionKillPolicy::Default
}
}
impl MachineCheckExceptionKillPolicy
{
pub fn for_current_process() -> io::Result<Self>
{
use self::MachineCheckExceptionKillPolicy::*;
process_control_wrapper1
(
PR_MCE_KILL_GET,
|non_negative_result| match non_negative_result
{
PR_MCE_KILL_EARLY => Ok(Early),
PR_MCE_KILL_LATE => Ok(Late),
PR_MCE_KILL_DEFAULT => Ok(Default),
_ => Err(io_error_invalid_data("Unknown value for `prctl(PR_MCE_KILL_GET)`")),
},
error_number_to_io_error,
)
}
pub fn clear_for_current_thread() -> io::Result<()>
{
process_control_wrapper2
(PR_MCE_KILL,PR_MCE_KILL_CLEAR as usize,result_must_be_zero,error_number_to_io_error)
}
pub fn set_for_current_thread(self) -> io::Result<()>
{
process_control_wrapper3(PR_MCE_KILL,PR_MCE_KILL_SET as usize,self as i32 as usize,result_must_be_zero,error_number_to_io_error)
}
}