Operating system abstractions for ZZ
Add this to your zz.toml file:
[dependencies]
os = "*"
[repos]
os = "git://github.com/zzmodules/os"using osReturns the detected architecture for the operating system.
if os::arch() == os::arch::arm { }
else if os::arch() == os::arch::arm64 { }
else if os::arch() == os::arch::ia32 { }
else if os::arch() == os::arch::mips { }
else if os::arch() == os::arch::ppc { }
else if os::arch() == os::arch::ppc64 { }
else if os::arch() == os::arch::x32 { }
else if os::arch() == os::arch::x64 { }
else { err::panic("unknown architecture"); }Returns the detected operating system specific "end-of-line" marker.
let eol = os::eol();Returns the detected operating system type.
if os::type() == os::type::apple { }
else if os::type() == os::type::linux { }
else if os::type() == os::type::posix { }
else if os::type() == os::type::unix { }
else if os::type() == os::type::windows { }
else { err::panic("unknown operating system"); }The following preprocessor values are available for operating system and architecture detection in macro conditional statements:
os::detect::amdos::detect::amd64os::detect::appleos::detect::armos::detect::arm64os::detect::i386os::detect::linuxos::detect::mipsos::detect::posixos::detect::ppcos::detect::ppc64os::detect::unixos::detect::windows
fn platform_specific() -> int
if #(os::detect::apple) {
return 1;
} else if #(os::detect::linux) {
return 2;
} else if #(os::detect::unix) {
return 3;
} else if #(os::detect::posix) {
return 4;
} else if #(os::detect::windows) {
return 5;
} else {
// unknown operating system
return 0;
}MIT