Skip to content

Instantly share code, notes, and snippets.

View ac000's full-sized avatar

Andrew Clayton ac000

View GitHub Profile
@ac000
ac000 / demo-unit.c
Last active June 28, 2023 14:40
WASM module in C demonstrating using linear memory to share structures for sending and receiving HTTP requests/responses
/*
* WIP/PROTOTYPE: Caveat emptor. If it breaks, you get to keep all the pieces.
*
* Compile with:
*
* clang -Wall -Wextra -fno-strict-aliasing --target=wasm32-wasi --sysroot=../wasi-sysroot -Wl,--no-entry,--export=__heap_base,--export=__data_end,--export=malloc,--export=free,--stack-first,-z,stack-size=$((8*1024*1024)),--initial-memory=$(((4096*1024*1024)-65536)) -mexec-model=reactor -o demo-unit.wasm demo-unit.c
*
* Download the wasi-sysroot tarball from https://github.com/WebAssembly/wasi-sdk/releases
*/
@ac000
ac000 / luw-echo-request.rs
Last active August 24, 2023 19:27
Rust echo-request WebAssembly demo application before and after Rust bindings (luw_) wrapper (uwr_)
/* SPDX-License-Identifier: Apache-2.0 */
/*
* Copyright (C) Andrew Clayton
* Copyright (C) Timo Stark
* Copyright (C) F5, Inc.
*/
// Include RAW FFI Bindings.
// @todo: Replace this with the new native Rust API
@ac000
ac000 / 000-wasi-http.txt
Last active December 1, 2023 22:17
libunit-wasm vs wasi-http
This will compare the libunit-wasm luw-echo-request module with the same
implemented using wasi-http and built as a component.
You will notice we don't get all the same information with wasi-http.
I also hasten to add that I have somewhat sanitised the wasi-http API (which of
course is an autogenerated monstrosity) by removing `_0_2_0_rc_2023_11_10` and
`_0_2_0_RC_2023_11_10` from all the `wasi_` and `WASI_` function/type names.
I have also removed _all_ the error checking from the below pasted wasi-http