Skip to content

Commit

Permalink
add support of the unikernel RustyHermit (#88)
Browse files Browse the repository at this point in the history
- use the crate hermit-abi as interface to the kernel
  • Loading branch information
stlankes authored and seanmonstar committed Oct 30, 2019
1 parent c3d2021 commit a8973cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ readme = "README.md"
[dependencies]
libc = "0.2.26"

[target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies]
hermit-abi = "0.1.3"

[dev-dependencies]
doc-comment = "0.3"
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#[cfg(not(windows))]
extern crate libc;

#[cfg(target_os = "hermit")]
extern crate hermit_abi;

#[cfg(test)]
#[macro_use]
extern crate doc_comment;
Expand Down Expand Up @@ -443,6 +446,11 @@ fn get_num_cpus() -> usize {
}
}

#[cfg(target_os = "hermit")]
fn get_num_cpus() -> usize {
unsafe { hermit_abi::get_processor_count() }
}

#[cfg(not(any(
target_os = "nacl",
target_os = "macos",
Expand All @@ -457,6 +465,7 @@ fn get_num_cpus() -> usize {
target_os = "dragonfly",
target_os = "netbsd",
target_os = "haiku",
target_os = "hermit",
windows,
)))]
fn get_num_cpus() -> usize {
Expand Down

0 comments on commit a8973cb

Please sign in to comment.