The snapshot 1 spec says fd_write
has 2 parameters: (fd $fd, iovs $ciovec_array)
and 2 results: ($error $errno, $nwritten, $size)
. However, when looking at this tutorial, the fd_write
is called with 4 parameters and has 1 return value (the number of bytes written). I'm a bit confused by what is going on. Does someone have some insight?
The tutorial uses wasi_unstable
, not wasi_snapshot_preview1
.
I changed the import value to wasi_snapshot_preview1
and the tutorial code still worked.
The witx description has multiple results. Since MVP-level wasm doesn't support multiple return values, when witx is translated into Rust or C bindings, result values after the first one are translated into pointer parameters to store the output in.
And, the signature for fd_write
includes an array (the iovec array). When translated into a C interface, this is exposed as two parameters, a pointer and a length.
At the wasm level, arrays appear as two parameters as well.
Last updated: Nov 22 2024 at 16:03 UTC