Skip to content

Commit

Permalink
Separate directories in wasi-wrapper by language
Browse files Browse the repository at this point in the history
  • Loading branch information
fgh1999 committed Jun 18, 2024
1 parent 0bbaa5b commit 91302d7
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ ELF file generated by Wasker is OS-independent: WASI calls from Wasm application

Please write your own WASI wrapper for your favorite OS to be linked with Wasker output.

Here, we'll show a [tiny example](./examples/wasi-wrapper/wasi-wrapper-linux.c) of running Wasker output on Linux.
Here, we'll show a [tiny example](./examples/wasi-wrapper/c/wasi-wrapper-linux.c) of running Wasker output on Linux.

Link Wasker output and WASI wapper for Linux
```
gcc -no-pie ./examples/wasi-wrapper/wasi-wrapper-linux.c ./wasm.o -o hello
gcc -no-pie ./examples/wasi-wrapper/c/wasi-wrapper-linux.c ./wasm.o -o hello
```

Run!!
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# An Example of Running Wasker Output Based on Rust Std

Similar to the [Linux WASI wrapper](../wasi-wrapper-linux.c),
Similar to the [Linux WASI wrapper](../c/wasi-wrapper-linux.c),
4 mock WASI interfaces are implemented in order to support [the rust example](../../rust/README.md).

## Prerequisite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn main() {
path_to_str(&target_path),
])
.status()
.expect("failed to execute process");
.expect("failed to convert obj into lib");

println!("cargo:rustc-link-arg=-no-pie");
println!("cargo:rustc-link-search=native={}", path_to_str(wasm_path));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ extern "C" {

fn main() {
unsafe {
// Entrypoint of ELF generated by Wasker
wasker_main();
}
println!("wasker_main from the compiled target WASM done!");
println!("wasker_main from the compiled target WASM done.");
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// Linear Memory
//! Linear Memory
use std::sync::Mutex;

const LINEAR_MEMORY_BLOCK_SIZE: i32 = 64 * 1024;
Expand All @@ -13,7 +13,7 @@ pub unsafe fn get_memory_base() -> *mut u8 {
}

unsafe fn alloc_memory() -> *mut u8 {
use std::alloc::{alloc, Layout}; // delloc
use std::alloc::{alloc, Layout};
unsafe {
LINEAR_MEMORY_BASE = alloc(
Layout::from_size_align(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// WASI Implementation based on Rust Std Lib
//! WASI Implementation based on Rust Std Lib
use crate::memory::get_memory_base;
use wasi::{Errno, ERRNO_SUCCESS};

Expand Down

0 comments on commit 91302d7

Please sign in to comment.