1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use wasmtime::Trap;
pub mod old;
pub use wasi_common::{WasiCtx, WasiCtxBuilder};
wasmtime_wiggle::wasmtime_integration!({
target: wasi_common::wasi,
witx: ["phases/snapshot/witx/wasi_snapshot_preview1.witx"],
ctx: WasiCtx,
modules: { wasi_snapshot_preview1 =>
{ name: Wasi,
docs: "An instantiated instance of the wasi exports.
This represents a wasi module which can be used to instantiate other wasm
modules. This structure exports all that various fields of the wasi instance
as fields which can be used to implement your own instantiation logic, if
necessary. Additionally [`Wasi::get_export`] can be used to do name-based
resolution.",
function_override: {
proc_exit => wasi_proc_exit
}
},
},
missing_memory: { wasi_common::wasi::Errno::Inval },
});
pub fn is_wasi_module(name: &str) -> bool {
name.starts_with("wasi")
}
fn wasi_proc_exit(status: i32) -> Result<(), Trap> {
if status >= 0 && status < 126 {
Err(Trap::i32_exit(status))
} else {
Err(Trap::new(
"exit with invalid exit status outside of [0..126)",
))
}
}