Implement WASI C API.

This commit implements an initial WASI C API that can be used to instantiate
and configure a WASI instance from C.

This also implements a `WasiBuilder` for the C# API enabling .NET hosts to bind
to Wasmtime's WASI implementation.
This commit is contained in:
Peter Huene
2020-02-07 11:24:26 -08:00
parent f8abe1169c
commit ae0b4090ce
28 changed files with 1303 additions and 268 deletions

View File

@@ -15,6 +15,12 @@ use wasmtime::{
Table, TableType, Trap, Val, ValType,
};
mod ext;
mod wasi;
pub use crate::ext::*;
pub use crate::wasi::*;
macro_rules! declare_vec {
($name:ident, $elem_ty:path) => {
#[repr(C)]
@@ -1025,7 +1031,7 @@ pub unsafe extern "C" fn wasm_trap_new(
if message[message.len() - 1] != 0 {
panic!("wasm_trap_new message stringz expected");
}
let message = String::from_utf8_lossy(message);
let message = String::from_utf8_lossy(&message[..message.len() - 1]);
let trap = Box::new(wasm_trap_t {
trap: HostRef::new(Trap::new(message)),
});
@@ -1777,7 +1783,3 @@ pub unsafe extern "C" fn wasm_valtype_vec_copy(
let slice = slice::from_raw_parts((*src).data, (*src).size);
(*out).set_from_slice(slice);
}
mod ext;
pub use crate::ext::*;