From c2a715ca54cc5371e04aa468f0468bbb480b142d Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 7 Jan 2021 14:43:56 -0800 Subject: [PATCH] wiggle traps --- crates/wasi-c2/src/snapshots/preview_1.rs | 4 ++-- crates/wasi-c2/wasmtime/src/lib.rs | 19 ------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/crates/wasi-c2/src/snapshots/preview_1.rs b/crates/wasi-c2/src/snapshots/preview_1.rs index 48e7876f0a..b724e325a4 100644 --- a/crates/wasi-c2/src/snapshots/preview_1.rs +++ b/crates/wasi-c2/src/snapshots/preview_1.rs @@ -30,7 +30,7 @@ impl types::GuestErrorConversion for WasiCtx { } impl types::UserErrorConversion for WasiCtx { - fn errno_from_error(&self, e: Error) -> Result { + fn errno_from_error(&self, e: Error) -> Result { debug!("Error: {:?}", e); Ok(e.into()) } @@ -885,7 +885,7 @@ impl<'a> wasi_snapshot_preview1::WasiSnapshotPreview1 for WasiCtx { unimplemented!() } - fn proc_exit(&self, _rval: types::Exitcode) -> Result<(), ()> { + fn proc_exit(&self, _rval: types::Exitcode) -> wiggle::Trap { unimplemented!() } diff --git a/crates/wasi-c2/wasmtime/src/lib.rs b/crates/wasi-c2/wasmtime/src/lib.rs index 762e848d23..02fdd558ec 100644 --- a/crates/wasi-c2/wasmtime/src/lib.rs +++ b/crates/wasi-c2/wasmtime/src/lib.rs @@ -1,5 +1,4 @@ pub use wasi_c2::WasiCtx; -use wasmtime::Trap; // Defines a `struct Wasi` with member fields and appropriate APIs for dealing // with all the various WASI exports. @@ -22,24 +21,6 @@ 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.", - // Don't use the wiggle generated code to implement proc_exit, we need - // to hook directly into the runtime there: - function_override: { - proc_exit => wasi_proc_exit - } }, }, - // Error to return when caller module is missing memory export: - missing_memory: { wasi_c2::snapshots::preview_1::types::Errno::Inval }, }); - -fn wasi_proc_exit(status: i32) -> Result<(), Trap> { - if status >= 0 && status < 126 { - Err(Trap::i32_exit(status)) - } else { - Err(Trap::new(format!( - "exit with invalid exit status outside of [0..126): {}", - status, - ))) - } -}