-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change runExports so that wasi imports can be used. Improve fd_write so that emscipten compiled programs can be used. Also add example programs. Also update build file to use not use incorrect flags on windows. Signed-off-by: Adam Laszlo Kulcsar <kuladam@inf.u-szeged.hu>
- Loading branch information
1 parent
a899ce5
commit 16d95a3
Showing
12 changed files
with
118 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <stdio.h> | ||
#include <stdint.h> | ||
|
||
/* Emscripten compile command: | ||
`emcc hello_world.c --no-entry -sEXPORTED_FUNCTIONS=_start -s EXPORTED_RUNTIME_METHODS=ccall,cwrap -o hello_world.wasm` | ||
Run in walrus with `walrus --run-export _start hello_world.wasm` | ||
*/ | ||
|
||
int main() | ||
{ | ||
fprintf(stdout, "Hello World!\n"); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(module | ||
(import "wasi_snapshot_preview1" "fd_write" (func $wasi_fd_write (param i32 i32 i32 i32) (result i32))) | ||
(memory 1) | ||
|
||
(export "memory" (memory 0)) | ||
(export "hello_world" (func $hello_world)) | ||
(data (i32.const 0) "Hello World!\n") | ||
|
||
(func $hello_world | ||
(i32.store (i32.const 100) (i32.const 0)) | ||
(i32.store (i32.const 112) (i32.const 13)) | ||
(i32.store (i32.const 200) (i32.const 0)) | ||
(call $wasi_fd_write | ||
(i32.const 1) ;;file descriptor | ||
(i32.const 100) ;;offset of str offset | ||
(i32.const 2) ;;iovec length | ||
(i32.const 200) ;;result offset | ||
) | ||
drop | ||
) | ||
) | ||
|
||
(assert_return (invoke "hello_world")) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "stdlib.h" | ||
|
||
int main() | ||
{ | ||
exit(0); | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(module | ||
(import "wasi_snapshot_preview1" "proc_exit" (func $wasi_proc_exit (param i32))) | ||
|
||
|
||
(func (export "proc_exit") | ||
i32.const 0 | ||
call $wasi_proc_exit | ||
) | ||
) | ||
|
||
(assert_return (invoke "proc_exit")) |