mooigraph a2732f9b6a next c wasm test added 3 gadi atpakaļ
..
0m.sh 1aae1c0179 c-to-wasm running in browser docs 3 gadi atpakaļ
README.md a2732f9b6a next c wasm test added 3 gadi atpakaļ
add.c 51d9fcd232 running wasm in test00 3 gadi atpakaļ
add.html 51d9fcd232 running wasm in test00 3 gadi atpakaļ
add.wasm 51d9fcd232 running wasm in test00 3 gadi atpakaļ
add2.html 51d9fcd232 running wasm in test00 3 gadi atpakaļ
lenstr.c 1aae1c0179 c-to-wasm running in browser docs 3 gadi atpakaļ
lenstr.wasm 1aae1c0179 c-to-wasm running in browser docs 3 gadi atpakaļ
lenstr3.html 1aae1c0179 c-to-wasm running in browser docs 3 gadi atpakaļ

README.md

wasmtest00

test compiling c to wasm without c-lib or emscripten using clang-7 and ./0m shell script

add.wasm adds two int numbers and prints result on console log

lenstr.wasm print length of string on console log

because lenstr.wasm uses wasm memory add linker flag -Wl,--import-memory to clang

It needs lld package installed and python webserver but not thttpd

python -m SimpleHTTPDServer

Then browse to localhost:8000

Using firefox developers console to see output from console.log()

From wasi-libc on github git clone https://github.com/CraneStation/wasi-libc.git

This is how wasm in c allocates memory in PAGESIZE sizes at once

uintptr_t old = __builtin_wasm_memory_grow(0, (uintptr_t)increment / PAGESIZE);

and this is wasm pagesize definition:

The page size in WebAssembly is fixed at 64 KiB. If this ever changes, it's expected that applications will need to opt in, so we can change this.

#define PAGESIZE (0x10000)

end.