Skip to content

Instantly share code, notes, and snippets.

@Grissess
Created March 11, 2016 00:05
Show Gist options
  • Save Grissess/06a6108fa03f49757a6d to your computer and use it in GitHub Desktop.
Save Grissess/06a6108fa03f49757a6d to your computer and use it in GitHub Desktop.
pub enum ABI {
SysV,
HP_UX,
NetBSD,
Linux,
Solaris,
AIX,
IRIS,
FreeBSD,
OpenBSD,
OpenVMS,
Unknown
}
pub impl ABI {
fn from_u8(i: u8) -> ABI {
match i {
0x00 => ABI::SysV,
0x01 => ABI::HP_UX,
0x02 => ABI::NetBSD,
0x03 => ABI::Linux,
0x06 => ABI::Solaris,
0x07 => ABI::AIX,
0x08 => ABI::IRIS,
0x09 => ABI::FreeBSD,
0x0C => ABI::OpenBSD,
0x0d => ABI::OpenVMS,
_ => ABI::Unknown,
}
}
fn to_u8(self) -> u8 {
match self {
ABI::SysV => 0x00,
ABI::HP_UX => 0x01,
ABI::NetBSD => 0x02,
ABI::Linux => 0x03,
ABI::Solaris => 0x06,
ABI::AIX => 0x07,
ABI::IRIS => 0x08,
ABI::FreeBSD => 0x09,
ABI::OpenBSD => 0x0C,
ABI::OpenVMS => 0x0D,
ABI::Unknown => 0xFF, // FIXME?
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment