add support of the unikernel RustyHermit

- use the crate hermit-abi as interface to the kernel
This commit is contained in:
Stefan Lankes
2020-01-04 09:09:15 +01:00
parent 87d6e72b2d
commit ea0a7b2789
2 changed files with 16 additions and 0 deletions
+3
View File
@@ -17,6 +17,9 @@ travis-ci = { repository = "softprops/atty" }
[target.'cfg(unix)'.dependencies]
libc = { version = "0.2", default-features = false }
[target.'cfg(target_os = "hermit")'.dependencies]
hermit-abi = "0.1.6"
[target.'cfg(windows)'.dependencies.winapi]
version = "0.3"
features = ["consoleapi", "processenv", "minwinbase", "minwindef", "winbase"]
+13
View File
@@ -48,6 +48,19 @@ pub fn is(stream: Stream) -> bool {
unsafe { libc::isatty(fd) != 0 }
}
/// returns true if this is a tty
#[cfg(target_os = "hermit")]
pub fn is(stream: Stream) -> bool {
extern crate hermit_abi;
let fd = match stream {
Stream::Stdout => hermit_abi::STDOUT_FILENO,
Stream::Stderr => hermit_abi::STDERR_FILENO,
Stream::Stdin => hermit_abi::STDIN_FILENO,
};
hermit_abi::isatty(fd)
}
/// returns true if this is a tty
#[cfg(windows)]
pub fn is(stream: Stream) -> bool {