#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
#[repr(i32)]
pub enum ExtendedProtection
{
Inaccessible = PROT_NONE,
Read = PROT_READ,
ReadWrite = PROT_READ | PROT_WRITE,
ReadExecutable = PROT_READ | PROT_EXEC,
ReadWriteExecutable = PROT_READ | PROT_WRITE | PROT_EXEC,
GrowsUp = PROT_GROWSUP,
GrowsDown = PROT_GROWSDOWN,
#[cfg(target_arch = "powerpc64")] StrongAccessOrdering = Self::PROT_SAO,
}
impl From<Protection> for ExtendedProtection
{
#[inline(always)]
fn from(protection: Protection) -> Self
{
unsafe { transmute(protection) }
}
}
impl Into<Option<Protection>> for ExtendedProtection
{
#[inline(always)]
fn into(self) -> Option<Protection>
{
use self::ExtendedProtection::*;
match self
{
Inaccessible => Some(Protection::Inaccessible),
Read => Some(Protection::Read),
ReadWrite => Some(Protection::ReadWrite),
ReadExecutable => Some(Protection::ReadExecutable),
ReadWriteExecutable => Some(Protection::ReadWriteExecutable),
GrowsUp | GrowsDown => None,
#[cfg(target_arch = "powerpc64")] StrongAccessOrdering => None,
}
}
}
impl Default for ExtendedProtection
{
#[inline(always)]
fn default() -> Self
{
ExtendedProtection::ReadWrite
}
}
impl ExtendedProtection
{
#[cfg(target_arch = "powerpc64")]
const PROT_SAO: i32 = 0x10;
}