Skip to content

Commit

Permalink
Rename loader:kwasm to loader:kernel for consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
losfair committed May 15, 2019
1 parent 13b4fe3 commit 408f89c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ rustc_version = "0.2.3"

[features]
default = ["fast-tests", "wasi"]
"loader:kwasm" = ["wasmer-kernel-loader"]
"loader:kernel" = ["wasmer-kernel-loader"]
debug = ["wasmer-runtime-core/debug"]
extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"]
# This feature will allow cargo test to run much faster
Expand Down
12 changes: 6 additions & 6 deletions src/bin/kwasmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use wasmer_runtime_core::{
backend::{CompilerConfig, MemoryBoundCheckMode},
loader::Instance as LoadedInstance,
};
#[cfg(feature = "loader:kwasm")]
#[cfg(feature = "loader:kernel")]
use wasmer_singlepass_backend::SinglePassCompiler;

use std::io::prelude::*;
#[cfg(feature = "loader:kwasm")]
#[cfg(feature = "loader:kernel")]
use std::os::unix::net::{UnixListener, UnixStream};

use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
Expand All @@ -36,7 +36,7 @@ const CMD_RUN_CODE: u32 = 0x901;
const CMD_READ_MEMORY: u32 = 0x902;
const CMD_WRITE_MEMORY: u32 = 0x903;

#[cfg(feature = "loader:kwasm")]
#[cfg(feature = "loader:kernel")]
fn handle_client(mut stream: UnixStream) {
let binary_size = stream.read_u32::<LittleEndian>().unwrap();
if binary_size > 1048576 * 16 {
Expand Down Expand Up @@ -128,7 +128,7 @@ fn handle_client(mut stream: UnixStream) {
}
}

#[cfg(feature = "loader:kwasm")]
#[cfg(feature = "loader:kernel")]
fn run_listen(opts: Listen) {
let listener = UnixListener::bind(&opts.socket).unwrap();
for stream in listener.incoming() {
Expand All @@ -150,7 +150,7 @@ fn run_listen(opts: Listen) {
}
}

#[cfg(feature = "loader:kwasm")]
#[cfg(feature = "loader:kernel")]
fn main() {
let options = CLIOptions::from_args();
match options {
Expand All @@ -160,7 +160,7 @@ fn main() {
}
}

#[cfg(not(feature = "loader:kwasm"))]
#[cfg(not(feature = "loader:kernel"))]
fn main() {
panic!("Kwasm loader is not enabled during compilation.");
}
12 changes: 6 additions & 6 deletions src/bin/wasmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ struct Run {
#[derive(Debug, Copy, Clone)]
enum LoaderName {
Local,
#[cfg(feature = "loader:kwasm")]
#[cfg(feature = "loader:kernel")]
Kernel,
}

impl LoaderName {
pub fn variants() -> &'static [&'static str] {
&[
"local",
#[cfg(feature = "loader:kwasm")]
#[cfg(feature = "loader:kernel")]
"kernel",
]
}
Expand All @@ -135,7 +135,7 @@ impl FromStr for LoaderName {
fn from_str(s: &str) -> Result<LoaderName, String> {
match s.to_lowercase().as_str() {
"local" => Ok(LoaderName::Local),
#[cfg(feature = "loader:kwasm")]
#[cfg(feature = "loader:kernel")]
"kernel" => Ok(LoaderName::Kernel),
_ => Err(format!("The loader {} doesn't exist", s)),
}
Expand Down Expand Up @@ -296,14 +296,14 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
Backend::LLVM => return Err("the llvm backend is not enabled".to_string()),
};

#[cfg(feature = "loader:kwasm")]
#[cfg(feature = "loader:kernel")]
let is_kernel_loader = if let Some(LoaderName::Kernel) = options.loader {
true
} else {
false
};

#[cfg(not(feature = "loader:kwasm"))]
#[cfg(not(feature = "loader:kernel"))]
let is_kernel_loader = false;

let module = if is_kernel_loader {
Expand Down Expand Up @@ -386,7 +386,7 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
let index = instance.resolve_func("_start").unwrap();
let mut ins: Box<LoadedInstance<Error = String>> = match loader {
LoaderName::Local => Box::new(instance.load(LocalLoader).unwrap()),
#[cfg(feature = "loader:kwasm")]
#[cfg(feature = "loader:kernel")]
LoaderName::Kernel => {
Box::new(instance.load(::wasmer_kernel_loader::KernelLoader).unwrap())
}
Expand Down

0 comments on commit 408f89c

Please sign in to comment.