Skip to content

Repository files navigation

os

Operating system abstractions for ZZ

Installation

Add this to your zz.toml file:

[dependencies]
os = "*"
[repos]
os = "git://github.com/zzmodules/os"

Usage

using os

API

os::arch() -> Arch

Returns the detected architecture for the operating system.

ifos::arch() == os::arch::arm { }
elseifos::arch() == os::arch::arm64 { }
elseifos::arch() == os::arch::ia32 { }
elseifos::arch() == os::arch::mips { }
elseifos::arch() == os::arch::ppc { }
elseifos::arch() == os::arch::ppc64 { }
elseifos::arch() == os::arch::x32 { }
elseifos::arch() == os::arch::x64 { }
else { err::panic("unknown architecture"); }

os::eol() -> char *

Returns the detected operating system specific "end-of-line" marker.

let eol = os::eol();

os::type() -> Type

Returns the detected operating system type.

ifos::type() == os::type::apple { }
elseifos::type() == os::type::linux { }
elseifos::type() == os::type::posix { }
elseifos::type() == os::type::unix { }
elseifos::type() == os::type::windows { }
else { err::panic("unknown operating system"); }

os::detect

The following preprocessor values are available for operating system and architecture detection in macro conditional statements:

  • os::detect::amd
  • os::detect::amd64
  • os::detect::apple
  • os::detect::arm
  • os::detect::arm64
  • os::detect::i386
  • os::detect::linux
  • os::detect::mips
  • os::detect::posix
  • os::detect::ppc
  • os::detect::ppc64
  • os::detect::unix
  • os::detect::windows
fn platform_specific() -> int
if #(os::detect::apple) {
return1;
} elseif #(os::detect::linux) {
return2;
} elseif #(os::detect::unix) {
return3;
} elseif #(os::detect::posix) {
return4;
} elseif #(os::detect::windows) {
return5;
} else {
// unknown operating systemreturn0;
}

License

MIT

About

Operating system abstractions for ZZ

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages