From 85d9ca9ad2879d6575caedc2d304a9d5e38de6c3 Mon Sep 17 00:00:00 2001 From: Lachlan Sneff Date: Mon, 22 Apr 2019 10:35:55 -0700 Subject: [PATCH 1/7] Add NativeWasmType trait and modify WasmExternType --- lib/runtime-core/src/typed_func.rs | 46 ++++----- lib/runtime-core/src/types.rs | 150 +++++++++++++++++++---------- 2 files changed, 116 insertions(+), 80 deletions(-) diff --git a/lib/runtime-core/src/typed_func.rs b/lib/runtime-core/src/typed_func.rs index 59c610773..5f14a8fa1 100644 --- a/lib/runtime-core/src/typed_func.rs +++ b/lib/runtime-core/src/typed_func.rs @@ -2,7 +2,7 @@ use crate::{ error::RuntimeError, export::{Context, Export, FuncPointer}, import::IsExport, - types::{FuncSig, Type, WasmExternType}, + types::{FuncSig, NativeWasmType, Type, WasmExternType}, vm::{self, Ctx}, }; use std::{ @@ -135,10 +135,10 @@ where impl TrapEarly for Result where Rets: WasmTypeList, - E: Any, + E: Into> + 'static, { fn report(self) -> Result> { - self.map_err(|err| Box::new(err) as Box) + self.map_err(|err| err.into()) } } @@ -213,22 +213,24 @@ impl WasmTypeList for (A,) { type CStruct = S1; type RetArray = [u64; 1]; fn from_ret_array(array: Self::RetArray) -> Self { - (WasmExternType::from_bits(array[0]),) + (WasmExternType::from_native(NativeWasmType::from_bits( + array[0], + )),) } fn empty_ret_array() -> Self::RetArray { [0u64] } fn from_c_struct(c_struct: Self::CStruct) -> Self { let S1(a) = c_struct; - (a,) + (WasmExternType::from_native(a),) } fn into_c_struct(self) -> Self::CStruct { #[allow(unused_parens, non_snake_case)] let (a,) = self; - S1(a) + S1(WasmExternType::to_native(a)) } fn types() -> &'static [Type] { - &[A::TYPE] + &[A::Native::TYPE] } #[allow(non_snake_case)] unsafe fn call( @@ -237,11 +239,8 @@ impl WasmTypeList for (A,) { wasm: Wasm, ctx: *mut Ctx, ) -> Result { - // type Trampoline = extern "C" fn(*mut Ctx, *const c_void, *const u64, *mut u64); - // type Invoke = extern "C" fn(Trampoline, *mut Ctx, *const c_void, *const u64, *mut u64, &mut WasmTrapInfo) -> bool; - let (a,) = self; - let args = [a.to_bits()]; + let args = [a.to_native().to_bits()]; let mut rets = Rets::empty_ret_array(); let mut trap = WasmTrapInfo::Unknown; @@ -277,7 +276,7 @@ where macro_rules! impl_traits { ( [$repr:ident] $struct_name:ident, $( $x:ident ),* ) => { #[repr($repr)] - pub struct $struct_name <$( $x ),*> ( $( $x ),* ); + pub struct $struct_name <$( $x: WasmExternType ),*> ( $( <$x as WasmExternType>::Native ),* ); impl< $( $x: WasmExternType, )* > WasmTypeList for ( $( $x ),* ) { type CStruct = $struct_name<$( $x ),*>; @@ -285,7 +284,7 @@ macro_rules! impl_traits { fn from_ret_array(array: Self::RetArray) -> Self { #[allow(non_snake_case)] let [ $( $x ),* ] = array; - ( $( WasmExternType::from_bits($x) ),* ) + ( $( WasmExternType::from_native(NativeWasmType::from_bits($x)) ),* ) } fn empty_ret_array() -> Self::RetArray { [0; count_idents!( $( $x ),* )] @@ -293,24 +292,21 @@ macro_rules! impl_traits { fn from_c_struct(c_struct: Self::CStruct) -> Self { #[allow(non_snake_case)] let $struct_name ( $( $x ),* ) = c_struct; - ( $( $x ),* ) + ( $( WasmExternType::from_native($x) ),* ) } fn into_c_struct(self) -> Self::CStruct { #[allow(unused_parens, non_snake_case)] let ( $( $x ),* ) = self; - $struct_name ( $( $x ),* ) + $struct_name ( $( WasmExternType::to_native($x) ),* ) } fn types() -> &'static [Type] { - &[$( $x::TYPE, )*] + &[$( $x::Native::TYPE, )*] } #[allow(non_snake_case)] unsafe fn call(self, f: NonNull, wasm: Wasm, ctx: *mut Ctx) -> Result { - // type Trampoline = extern "C" fn(*mut Ctx, *const c_void, *const u64, *mut u64); - // type Invoke = extern "C" fn(Trampoline, *mut Ctx, *const c_void, *const u64, *mut u64, &mut WasmTrapInfo) -> bool; - #[allow(unused_parens)] let ( $( $x ),* ) = self; - let args = [ $( $x.to_bits() ),* ]; + let args = [ $( $x.to_native().to_bits() ),* ]; let mut rets = Rets::empty_ret_array(); let mut trap = WasmTrapInfo::Unknown; @@ -319,12 +315,6 @@ macro_rules! impl_traits { } else { Err(trap) } - - // let f: extern fn(*mut Ctx $( ,$x )*) -> Rets::CStruct = mem::transmute(f); - // #[allow(unused_parens)] - // let ( $( $x ),* ) = self; - // let c_struct = f(ctx $( ,$x )*); - // Rets::from_c_struct(c_struct) } } @@ -335,11 +325,11 @@ macro_rules! impl_traits { /// This is required for the llvm backend to be able to unwind through this function. #[cfg_attr(nightly, unwind(allowed))] - extern fn wrap<$( $x: WasmExternType, )* Rets: WasmTypeList, Trap: TrapEarly, FN: Fn( &mut Ctx $( ,$x )* ) -> Trap>( ctx: &mut Ctx $( ,$x: $x )* ) -> Rets::CStruct { + extern fn wrap<$( $x: WasmExternType, )* Rets: WasmTypeList, Trap: TrapEarly, FN: Fn( &mut Ctx $( ,$x )* ) -> Trap>( ctx: &mut Ctx $( ,$x: <$x as WasmExternType>::Native )* ) -> Rets::CStruct { let f: FN = unsafe { mem::transmute_copy(&()) }; let err = match panic::catch_unwind(panic::AssertUnwindSafe(|| { - let res = f( ctx $( ,$x )* ).report(); + let res = f( ctx $( ,WasmExternType::from_native($x) )* ).report(); res })) { Ok(Ok(returns)) => return returns.into_c_struct(), diff --git a/lib/runtime-core/src/types.rs b/lib/runtime-core/src/types.rs index 79ef5da7f..bf5df2183 100644 --- a/lib/runtime-core/src/types.rs +++ b/lib/runtime-core/src/types.rs @@ -71,103 +71,149 @@ impl From for Value { } } -pub unsafe trait WasmExternType: Copy + Clone +pub unsafe trait NativeWasmType: Copy + Into where Self: Sized, { const TYPE: Type; + fn from_bits(bits: u64) -> Self; fn to_bits(self) -> u64; - fn from_bits(n: u64) -> Self; +} + +unsafe impl NativeWasmType for i32 { + const TYPE: Type = Type::I32; + fn from_bits(bits: u64) -> Self { + bits as _ + } + fn to_bits(self) -> u64 { + self as _ + } +} +unsafe impl NativeWasmType for i64 { + const TYPE: Type = Type::I64; + fn from_bits(bits: u64) -> Self { + bits as _ + } + fn to_bits(self) -> u64 { + self as _ + } +} +unsafe impl NativeWasmType for f32 { + const TYPE: Type = Type::F32; + fn from_bits(bits: u64) -> Self { + bits as _ + } + fn to_bits(self) -> u64 { + self as _ + } +} +unsafe impl NativeWasmType for f64 { + const TYPE: Type = Type::F64; + fn from_bits(bits: u64) -> Self { + bits as _ + } + fn to_bits(self) -> u64 { + self as _ + } +} + +pub unsafe trait WasmExternType: Copy +where + Self: Sized, +{ + type Native: NativeWasmType; + fn from_native(native: Self::Native) -> Self; + fn to_native(self) -> Self::Native; } unsafe impl WasmExternType for i8 { - const TYPE: Type = Type::I32; - fn to_bits(self) -> u64 { - self as u64 + type Native = i32; + fn from_native(native: Self::Native) -> Self { + native as _ } - fn from_bits(n: u64) -> Self { - n as _ + fn to_native(self) -> Self::Native { + self as _ } } unsafe impl WasmExternType for u8 { - const TYPE: Type = Type::I32; - fn to_bits(self) -> u64 { - self as u64 + type Native = i32; + fn from_native(native: Self::Native) -> Self { + native as _ } - fn from_bits(n: u64) -> Self { - n as _ + fn to_native(self) -> Self::Native { + self as _ } } unsafe impl WasmExternType for i16 { - const TYPE: Type = Type::I32; - fn to_bits(self) -> u64 { - self as u64 + type Native = i32; + fn from_native(native: Self::Native) -> Self { + native as _ } - fn from_bits(n: u64) -> Self { - n as _ + fn to_native(self) -> Self::Native { + self as _ } } unsafe impl WasmExternType for u16 { - const TYPE: Type = Type::I32; - fn to_bits(self) -> u64 { - self as u64 + type Native = i32; + fn from_native(native: Self::Native) -> Self { + native as _ } - fn from_bits(n: u64) -> Self { - n as _ + fn to_native(self) -> Self::Native { + self as _ } } unsafe impl WasmExternType for i32 { - const TYPE: Type = Type::I32; - fn to_bits(self) -> u64 { - self as u64 + type Native = i32; + fn from_native(native: Self::Native) -> Self { + native } - fn from_bits(n: u64) -> Self { - n as _ + fn to_native(self) -> Self::Native { + self } } unsafe impl WasmExternType for u32 { - const TYPE: Type = Type::I32; - fn to_bits(self) -> u64 { - self as u64 + type Native = i32; + fn from_native(native: Self::Native) -> Self { + native as _ } - fn from_bits(n: u64) -> Self { - n as _ + fn to_native(self) -> Self::Native { + self as _ } } unsafe impl WasmExternType for i64 { - const TYPE: Type = Type::I64; - fn to_bits(self) -> u64 { - self as u64 + type Native = i64; + fn from_native(native: Self::Native) -> Self { + native } - fn from_bits(n: u64) -> Self { - n as _ + fn to_native(self) -> Self::Native { + self } } unsafe impl WasmExternType for u64 { - const TYPE: Type = Type::I64; - fn to_bits(self) -> u64 { - self + type Native = i64; + fn from_native(native: Self::Native) -> Self { + native as _ } - fn from_bits(n: u64) -> Self { - n + fn to_native(self) -> Self::Native { + self as _ } } unsafe impl WasmExternType for f32 { - const TYPE: Type = Type::F32; - fn to_bits(self) -> u64 { - self.to_bits() as u64 + type Native = f32; + fn from_native(native: Self::Native) -> Self { + native } - fn from_bits(n: u64) -> Self { - f32::from_bits(n as u32) + fn to_native(self) -> Self::Native { + self } } unsafe impl WasmExternType for f64 { - const TYPE: Type = Type::F64; - fn to_bits(self) -> u64 { - self.to_bits() + type Native = f64; + fn from_native(native: Self::Native) -> Self { + native } - fn from_bits(n: u64) -> Self { - f64::from_bits(n) + fn to_native(self) -> Self::Native { + self } } From 74b6ba4eaf307091e34c957ede66b1579e180378 Mon Sep 17 00:00:00 2001 From: Lachlan Sneff Date: Mon, 22 Apr 2019 11:42:52 -0700 Subject: [PATCH 2/7] Return type normalization, and change return errors from imported functions --- lib/clif-backend/src/signal/unix.rs | 2 +- lib/emscripten/src/varargs.rs | 13 +-- lib/runtime-core/src/error.rs | 10 +- lib/runtime-core/src/typed_func.rs | 22 ++-- lib/wasi/src/lib.rs | 6 ++ lib/wasi/src/ptr.rs | 10 +- lib/wasi/src/syscalls/mod.rs | 5 +- lib/wasi/src/syscalls/types.rs | 156 ++++++++++++++-------------- 8 files changed, 115 insertions(+), 109 deletions(-) diff --git a/lib/clif-backend/src/signal/unix.rs b/lib/clif-backend/src/signal/unix.rs index feaf4e2e2..3e57a1588 100644 --- a/lib/clif-backend/src/signal/unix.rs +++ b/lib/clif-backend/src/signal/unix.rs @@ -76,7 +76,7 @@ pub fn call_protected(handler_data: &HandlerData, f: impl FnOnce() -> T) -> R *jmp_buf = prev_jmp_buf; if let Some(data) = super::TRAP_EARLY_DATA.with(|cell| cell.replace(None)) { - Err(RuntimeError::Panic { data }) + Err(RuntimeError::Error { data }) } else { let (faulting_addr, inst_ptr) = CAUGHT_ADDRESSES.with(|cell| cell.get()); diff --git a/lib/emscripten/src/varargs.rs b/lib/emscripten/src/varargs.rs index 3775d102c..a6a1fe46b 100644 --- a/lib/emscripten/src/varargs.rs +++ b/lib/emscripten/src/varargs.rs @@ -1,8 +1,5 @@ use std::mem; -use wasmer_runtime_core::{ - types::{Type, WasmExternType}, - vm::Ctx, -}; +use wasmer_runtime_core::{types::WasmExternType, vm::Ctx}; #[repr(transparent)] #[derive(Copy, Clone)] @@ -19,12 +16,12 @@ impl VarArgs { } unsafe impl WasmExternType for VarArgs { - const TYPE: Type = Type::I32; + type Native = i32; - fn to_bits(self) -> u64 { - self.pointer as u64 + fn to_native(self) -> Self::Native { + self.pointer as _ } - fn from_bits(n: u64) -> Self { + fn from_native(n: Self::Native) -> Self { Self { pointer: n as u32 } } } diff --git a/lib/runtime-core/src/error.rs b/lib/runtime-core/src/error.rs index 090214834..84ea04bc2 100644 --- a/lib/runtime-core/src/error.rs +++ b/lib/runtime-core/src/error.rs @@ -1,4 +1,4 @@ -use crate::types::{FuncSig, GlobalDescriptor, MemoryDescriptor, TableDescriptor, Type, Value}; +use crate::types::{FuncSig, GlobalDescriptor, MemoryDescriptor, TableDescriptor, Type}; use core::borrow::Borrow; use std::any::Any; @@ -121,8 +121,7 @@ impl std::error::Error for LinkError {} /// Comparing two `RuntimeError`s always evaluates to false. pub enum RuntimeError { Trap { msg: Box }, - Exception { data: Box<[Value]> }, - Panic { data: Box }, + Error { data: Box }, } impl PartialEq for RuntimeError { @@ -137,10 +136,7 @@ impl std::fmt::Display for RuntimeError { RuntimeError::Trap { ref msg } => { write!(f, "WebAssembly trap occured during runtime: {}", msg) } - RuntimeError::Exception { ref data } => { - write!(f, "Uncaught WebAssembly exception: {:?}", data) - } - RuntimeError::Panic { data } => { + RuntimeError::Error { data } => { let msg = if let Some(s) = data.downcast_ref::() { s } else if let Some(s) = data.downcast_ref::<&str>() { diff --git a/lib/runtime-core/src/typed_func.rs b/lib/runtime-core/src/typed_func.rs index 5f14a8fa1..ef1b3c077 100644 --- a/lib/runtime-core/src/typed_func.rs +++ b/lib/runtime-core/src/typed_func.rs @@ -7,6 +7,7 @@ use crate::{ }; use std::{ any::Any, + convert::Infallible, ffi::c_void, fmt, marker::PhantomData, @@ -120,14 +121,16 @@ pub trait TrapEarly where Rets: WasmTypeList, { - fn report(self) -> Result>; + type Error: 'static; + fn report(self) -> Result; } impl TrapEarly for Rets where Rets: WasmTypeList, { - fn report(self) -> Result> { + type Error = Infallible; + fn report(self) -> Result { Ok(self) } } @@ -135,10 +138,11 @@ where impl TrapEarly for Result where Rets: WasmTypeList, - E: Into> + 'static, + E: 'static, { - fn report(self) -> Result> { - self.map_err(|err| err.into()) + type Error = E; + fn report(self) -> Result { + self } } @@ -329,11 +333,13 @@ macro_rules! impl_traits { let f: FN = unsafe { mem::transmute_copy(&()) }; let err = match panic::catch_unwind(panic::AssertUnwindSafe(|| { - let res = f( ctx $( ,WasmExternType::from_native($x) )* ).report(); - res + f( ctx $( ,WasmExternType::from_native($x) )* ).report() })) { Ok(Ok(returns)) => return returns.into_c_struct(), - Ok(Err(err)) => err, + Ok(Err(err)) => { + let b: Box<_> = err.into(); + b as Box + }, Err(err) => err, }; diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index c08428dbe..82de5ad1f 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -17,6 +17,12 @@ pub use self::utils::is_wasi_module; use wasmer_runtime_core::{func, import::ImportObject, imports}; +/// This is returned in the Box RuntimeError::Error variant. +/// Use `downcast` or `downcast_ref` to retrieve the `ExitCode`. +pub struct ExitCode { + pub code: syscalls::types::__wasi_exitcode_t, +} + pub fn generate_import_object( args: Vec>, envs: Vec>, diff --git a/lib/wasi/src/ptr.rs b/lib/wasi/src/ptr.rs index 85a582df0..55a16d40c 100644 --- a/lib/wasi/src/ptr.rs +++ b/lib/wasi/src/ptr.rs @@ -2,7 +2,7 @@ use crate::syscalls::types::{__wasi_errno_t, __WASI_EFAULT}; use std::{cell::Cell, fmt, marker::PhantomData, mem}; use wasmer_runtime_core::{ memory::Memory, - types::{Type, ValueType, WasmExternType}, + types::{ValueType, WasmExternType}, }; pub struct Array; @@ -73,12 +73,12 @@ impl WasmPtr { } unsafe impl WasmExternType for WasmPtr { - const TYPE: Type = Type::I32; + type Native = i32; - fn to_bits(self) -> u64 { - self.offset as u64 + fn to_native(self) -> Self::Native { + self.offset as i32 } - fn from_bits(n: u64) -> Self { + fn from_native(n: Self::Native) -> Self { Self { offset: n as u32, _phantom: PhantomData, diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index a436444fb..ba9d66b5d 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -9,6 +9,7 @@ use self::types::*; use crate::{ ptr::{Array, WasmPtr}, state::{Fd, InodeVal, Kind, WasiFile, WasiState, MAX_SYMLINKS}, + ExitCode, }; use rand::{thread_rng, Rng}; use std::cell::Cell; @@ -1430,9 +1431,9 @@ pub fn poll_oneoff( debug!("wasi::poll_oneoff"); unimplemented!() } -pub fn proc_exit(ctx: &mut Ctx, rval: __wasi_exitcode_t) -> Result<(), &'static str> { +pub fn proc_exit(ctx: &mut Ctx, code: __wasi_exitcode_t) -> Result<(), ExitCode> { debug!("wasi::proc_exit, {}", rval); - Err("Instance exited") + Err(ExitCode { code }) } pub fn proc_raise(ctx: &mut Ctx, sig: __wasi_signal_t) -> __wasi_errno_t { debug!("wasi::proc_raise"); diff --git a/lib/wasi/src/syscalls/types.rs b/lib/wasi/src/syscalls/types.rs index c030df312..c239031a4 100644 --- a/lib/wasi/src/syscalls/types.rs +++ b/lib/wasi/src/syscalls/types.rs @@ -43,84 +43,84 @@ pub struct __wasi_dirent_t { pub d_type: __wasi_filetype_t, } -pub type __wasi_errno_t = u32; -pub const __WASI_ESUCCESS: u32 = 0; -pub const __WASI_E2BIG: u32 = 1; -pub const __WASI_EACCES: u32 = 2; -pub const __WASI_EADDRINUSE: u32 = 3; -pub const __WASI_EADDRNOTAVAIL: u32 = 4; -pub const __WASI_EAFNOSUPPORT: u32 = 5; -pub const __WASI_EAGAIN: u32 = 6; -pub const __WASI_EALREADY: u32 = 7; -pub const __WASI_EBADF: u32 = 8; -pub const __WASI_EBADMSG: u32 = 9; -pub const __WASI_EBUSY: u32 = 10; -pub const __WASI_ECANCELED: u32 = 11; -pub const __WASI_ECHILD: u32 = 12; -pub const __WASI_ECONNABORTED: u32 = 13; -pub const __WASI_ECONNREFUSED: u32 = 14; -pub const __WASI_ECONNRESET: u32 = 15; -pub const __WASI_EDEADLK: u32 = 16; -pub const __WASI_EDESTADDRREQ: u32 = 17; -pub const __WASI_EDOM: u32 = 18; -pub const __WASI_EDQUOT: u32 = 19; -pub const __WASI_EEXIST: u32 = 20; -pub const __WASI_EFAULT: u32 = 21; -pub const __WASI_EFBIG: u32 = 22; -pub const __WASI_EHOSTUNREACH: u32 = 23; -pub const __WASI_EIDRM: u32 = 24; -pub const __WASI_EILSEQ: u32 = 25; -pub const __WASI_EINPROGRESS: u32 = 26; -pub const __WASI_EINTR: u32 = 27; -pub const __WASI_EINVAL: u32 = 28; -pub const __WASI_EIO: u32 = 29; -pub const __WASI_EISCONN: u32 = 30; -pub const __WASI_EISDIR: u32 = 31; -pub const __WASI_ELOOP: u32 = 32; -pub const __WASI_EMFILE: u32 = 33; -pub const __WASI_EMLINK: u32 = 34; -pub const __WASI_EMSGSIZE: u32 = 35; -pub const __WASI_EMULTIHOP: u32 = 36; -pub const __WASI_ENAMETOOLONG: u32 = 37; -pub const __WASI_ENETDOWN: u32 = 38; -pub const __WASI_ENETRESET: u32 = 39; -pub const __WASI_ENETUNREACH: u32 = 40; -pub const __WASI_ENFILE: u32 = 41; -pub const __WASI_ENOBUFS: u32 = 42; -pub const __WASI_ENODEV: u32 = 43; -pub const __WASI_ENOENT: u32 = 44; -pub const __WASI_ENOEXEC: u32 = 45; -pub const __WASI_ENOLCK: u32 = 46; -pub const __WASI_ENOLINK: u32 = 47; -pub const __WASI_ENOMEM: u32 = 48; -pub const __WASI_ENOMSG: u32 = 49; -pub const __WASI_ENOPROTOOPT: u32 = 50; -pub const __WASI_ENOSPC: u32 = 51; -pub const __WASI_ENOSYS: u32 = 52; -pub const __WASI_ENOTCONN: u32 = 53; -pub const __WASI_ENOTDIR: u32 = 54; -pub const __WASI_ENOTEMPTY: u32 = 55; -pub const __WASI_ENOTRECOVERABLE: u32 = 56; -pub const __WASI_ENOTSOCK: u32 = 57; -pub const __WASI_ENOTSUP: u32 = 58; -pub const __WASI_ENOTTY: u32 = 59; -pub const __WASI_ENXIO: u32 = 60; -pub const __WASI_EOVERFLOW: u32 = 61; -pub const __WASI_EOWNERDEAD: u32 = 62; -pub const __WASI_EPERM: u32 = 63; -pub const __WASI_EPIPE: u32 = 64; -pub const __WASI_EPROTO: u32 = 65; -pub const __WASI_EPROTONOSUPPORT: u32 = 66; -pub const __WASI_EPROTOTYPE: u32 = 67; -pub const __WASI_ERANGE: u32 = 68; -pub const __WASI_EROFS: u32 = 69; -pub const __WASI_ESPIPE: u32 = 70; -pub const __WASI_ESRCH: u32 = 71; -pub const __WASI_ESTALE: u32 = 72; -pub const __WASI_ETIMEDOUT: u32 = 73; -pub const __WASI_ETXTBSY: u32 = 74; -pub const __WASI_EXDEV: u32 = 75; -pub const __WASI_ENOTCAPABLE: u32 = 76; +pub type __wasi_errno_t = u16; +pub const __WASI_ESUCCESS: u16 = 0; +pub const __WASI_E2BIG: u16 = 1; +pub const __WASI_EACCES: u16 = 2; +pub const __WASI_EADDRINUSE: u16 = 3; +pub const __WASI_EADDRNOTAVAIL: u16 = 4; +pub const __WASI_EAFNOSUPPORT: u16 = 5; +pub const __WASI_EAGAIN: u16 = 6; +pub const __WASI_EALREADY: u16 = 7; +pub const __WASI_EBADF: u16 = 8; +pub const __WASI_EBADMSG: u16 = 9; +pub const __WASI_EBUSY: u16 = 10; +pub const __WASI_ECANCELED: u16 = 11; +pub const __WASI_ECHILD: u16 = 12; +pub const __WASI_ECONNABORTED: u16 = 13; +pub const __WASI_ECONNREFUSED: u16 = 14; +pub const __WASI_ECONNRESET: u16 = 15; +pub const __WASI_EDEADLK: u16 = 16; +pub const __WASI_EDESTADDRREQ: u16 = 17; +pub const __WASI_EDOM: u16 = 18; +pub const __WASI_EDQUOT: u16 = 19; +pub const __WASI_EEXIST: u16 = 20; +pub const __WASI_EFAULT: u16 = 21; +pub const __WASI_EFBIG: u16 = 22; +pub const __WASI_EHOSTUNREACH: u16 = 23; +pub const __WASI_EIDRM: u16 = 24; +pub const __WASI_EILSEQ: u16 = 25; +pub const __WASI_EINPROGRESS: u16 = 26; +pub const __WASI_EINTR: u16 = 27; +pub const __WASI_EINVAL: u16 = 28; +pub const __WASI_EIO: u16 = 29; +pub const __WASI_EISCONN: u16 = 30; +pub const __WASI_EISDIR: u16 = 31; +pub const __WASI_ELOOP: u16 = 32; +pub const __WASI_EMFILE: u16 = 33; +pub const __WASI_EMLINK: u16 = 34; +pub const __WASI_EMSGSIZE: u16 = 35; +pub const __WASI_EMULTIHOP: u16 = 36; +pub const __WASI_ENAMETOOLONG: u16 = 37; +pub const __WASI_ENETDOWN: u16 = 38; +pub const __WASI_ENETRESET: u16 = 39; +pub const __WASI_ENETUNREACH: u16 = 40; +pub const __WASI_ENFILE: u16 = 41; +pub const __WASI_ENOBUFS: u16 = 42; +pub const __WASI_ENODEV: u16 = 43; +pub const __WASI_ENOENT: u16 = 44; +pub const __WASI_ENOEXEC: u16 = 45; +pub const __WASI_ENOLCK: u16 = 46; +pub const __WASI_ENOLINK: u16 = 47; +pub const __WASI_ENOMEM: u16 = 48; +pub const __WASI_ENOMSG: u16 = 49; +pub const __WASI_ENOPROTOOPT: u16 = 50; +pub const __WASI_ENOSPC: u16 = 51; +pub const __WASI_ENOSYS: u16 = 52; +pub const __WASI_ENOTCONN: u16 = 53; +pub const __WASI_ENOTDIR: u16 = 54; +pub const __WASI_ENOTEMPTY: u16 = 55; +pub const __WASI_ENOTRECOVERABLE: u16 = 56; +pub const __WASI_ENOTSOCK: u16 = 57; +pub const __WASI_ENOTSUP: u16 = 58; +pub const __WASI_ENOTTY: u16 = 59; +pub const __WASI_ENXIO: u16 = 60; +pub const __WASI_EOVERFLOW: u16 = 61; +pub const __WASI_EOWNERDEAD: u16 = 62; +pub const __WASI_EPERM: u16 = 63; +pub const __WASI_EPIPE: u16 = 64; +pub const __WASI_EPROTO: u16 = 65; +pub const __WASI_EPROTONOSUPPORT: u16 = 66; +pub const __WASI_EPROTOTYPE: u16 = 67; +pub const __WASI_ERANGE: u16 = 68; +pub const __WASI_EROFS: u16 = 69; +pub const __WASI_ESPIPE: u16 = 70; +pub const __WASI_ESRCH: u16 = 71; +pub const __WASI_ESTALE: u16 = 72; +pub const __WASI_ETIMEDOUT: u16 = 73; +pub const __WASI_ETXTBSY: u16 = 74; +pub const __WASI_EXDEV: u16 = 75; +pub const __WASI_ENOTCAPABLE: u16 = 76; #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[repr(C)] From 39ebca366cd5ce93a3904e6eeb426b303a9d37a2 Mon Sep 17 00:00:00 2001 From: Lachlan Sneff Date: Mon, 22 Apr 2019 11:44:31 -0700 Subject: [PATCH 3/7] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9284916aa..4a96a0999 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All PRs to the Wasmer repository must add to this file. Blocks of changes will separated by version increments. ## **[Unreleased]** +- [#379](https://github.com/wasmerio/wasmer/pull/379) Fix small return types from imported functions. - [#371](https://github.com/wasmerio/wasmer/pull/371) Add more Debug impl for WASI types - [#368](https://github.com/wasmerio/wasmer/pull/368) Fix issue with write buffering - [#343](https://github.com/wasmerio/wasmer/pull/343) Implement preopened files for WASI and fix aligment issue when accessing WASI memory From ecdcab5de9c2f0a9140604458e33e99c0370a3b6 Mon Sep 17 00:00:00 2001 From: Lachlan Sneff Date: Mon, 22 Apr 2019 11:47:47 -0700 Subject: [PATCH 4/7] Update singlepass to renamed enum discrimant --- lib/singlepass-backend/src/protect_unix.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/singlepass-backend/src/protect_unix.rs b/lib/singlepass-backend/src/protect_unix.rs index 918df5346..30019db13 100644 --- a/lib/singlepass-backend/src/protect_unix.rs +++ b/lib/singlepass-backend/src/protect_unix.rs @@ -76,7 +76,7 @@ pub fn call_protected(f: impl FnOnce() -> T) -> RuntimeResult { *jmp_buf = prev_jmp_buf; if let Some(data) = TRAP_EARLY_DATA.with(|cell| cell.replace(None)) { - Err(RuntimeError::Panic { data }) + Err(RuntimeError::Error { data }) } else { let (faulting_addr, _inst_ptr) = CAUGHT_ADDRESSES.with(|cell| cell.get()); From 7940aa7e426f2b7728c31ddb54cb8c94916df32b Mon Sep 17 00:00:00 2001 From: Lachlan Sneff Date: Mon, 22 Apr 2019 11:57:50 -0700 Subject: [PATCH 5/7] Fix renamed variable --- lib/wasi/src/syscalls/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index ba9d66b5d..ddbb0e517 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -1432,7 +1432,7 @@ pub fn poll_oneoff( unimplemented!() } pub fn proc_exit(ctx: &mut Ctx, code: __wasi_exitcode_t) -> Result<(), ExitCode> { - debug!("wasi::proc_exit, {}", rval); + debug!("wasi::proc_exit, {}", code); Err(ExitCode { code }) } pub fn proc_raise(ctx: &mut Ctx, sig: __wasi_signal_t) -> __wasi_errno_t { From 878a0e6687067ed26987c3d15d379ae495c9d43d Mon Sep 17 00:00:00 2001 From: Syrus Date: Mon, 22 Apr 2019 12:09:30 -0700 Subject: [PATCH 6/7] =?UTF-8?q?Partial=20Revert=20of=20types=20=E2=80=9CRe?= =?UTF-8?q?turn=20type=20normalization,=20and=20change=20return=20errors?= =?UTF-8?q?=20from=20imported=20functions"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 74b6ba4eaf307091e34c957ede66b1579e180378. # Conflicts: # lib/wasi/src/syscalls/mod.rs --- lib/wasi/src/syscalls/types.rs | 156 ++++++++++++++++----------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/lib/wasi/src/syscalls/types.rs b/lib/wasi/src/syscalls/types.rs index c239031a4..c030df312 100644 --- a/lib/wasi/src/syscalls/types.rs +++ b/lib/wasi/src/syscalls/types.rs @@ -43,84 +43,84 @@ pub struct __wasi_dirent_t { pub d_type: __wasi_filetype_t, } -pub type __wasi_errno_t = u16; -pub const __WASI_ESUCCESS: u16 = 0; -pub const __WASI_E2BIG: u16 = 1; -pub const __WASI_EACCES: u16 = 2; -pub const __WASI_EADDRINUSE: u16 = 3; -pub const __WASI_EADDRNOTAVAIL: u16 = 4; -pub const __WASI_EAFNOSUPPORT: u16 = 5; -pub const __WASI_EAGAIN: u16 = 6; -pub const __WASI_EALREADY: u16 = 7; -pub const __WASI_EBADF: u16 = 8; -pub const __WASI_EBADMSG: u16 = 9; -pub const __WASI_EBUSY: u16 = 10; -pub const __WASI_ECANCELED: u16 = 11; -pub const __WASI_ECHILD: u16 = 12; -pub const __WASI_ECONNABORTED: u16 = 13; -pub const __WASI_ECONNREFUSED: u16 = 14; -pub const __WASI_ECONNRESET: u16 = 15; -pub const __WASI_EDEADLK: u16 = 16; -pub const __WASI_EDESTADDRREQ: u16 = 17; -pub const __WASI_EDOM: u16 = 18; -pub const __WASI_EDQUOT: u16 = 19; -pub const __WASI_EEXIST: u16 = 20; -pub const __WASI_EFAULT: u16 = 21; -pub const __WASI_EFBIG: u16 = 22; -pub const __WASI_EHOSTUNREACH: u16 = 23; -pub const __WASI_EIDRM: u16 = 24; -pub const __WASI_EILSEQ: u16 = 25; -pub const __WASI_EINPROGRESS: u16 = 26; -pub const __WASI_EINTR: u16 = 27; -pub const __WASI_EINVAL: u16 = 28; -pub const __WASI_EIO: u16 = 29; -pub const __WASI_EISCONN: u16 = 30; -pub const __WASI_EISDIR: u16 = 31; -pub const __WASI_ELOOP: u16 = 32; -pub const __WASI_EMFILE: u16 = 33; -pub const __WASI_EMLINK: u16 = 34; -pub const __WASI_EMSGSIZE: u16 = 35; -pub const __WASI_EMULTIHOP: u16 = 36; -pub const __WASI_ENAMETOOLONG: u16 = 37; -pub const __WASI_ENETDOWN: u16 = 38; -pub const __WASI_ENETRESET: u16 = 39; -pub const __WASI_ENETUNREACH: u16 = 40; -pub const __WASI_ENFILE: u16 = 41; -pub const __WASI_ENOBUFS: u16 = 42; -pub const __WASI_ENODEV: u16 = 43; -pub const __WASI_ENOENT: u16 = 44; -pub const __WASI_ENOEXEC: u16 = 45; -pub const __WASI_ENOLCK: u16 = 46; -pub const __WASI_ENOLINK: u16 = 47; -pub const __WASI_ENOMEM: u16 = 48; -pub const __WASI_ENOMSG: u16 = 49; -pub const __WASI_ENOPROTOOPT: u16 = 50; -pub const __WASI_ENOSPC: u16 = 51; -pub const __WASI_ENOSYS: u16 = 52; -pub const __WASI_ENOTCONN: u16 = 53; -pub const __WASI_ENOTDIR: u16 = 54; -pub const __WASI_ENOTEMPTY: u16 = 55; -pub const __WASI_ENOTRECOVERABLE: u16 = 56; -pub const __WASI_ENOTSOCK: u16 = 57; -pub const __WASI_ENOTSUP: u16 = 58; -pub const __WASI_ENOTTY: u16 = 59; -pub const __WASI_ENXIO: u16 = 60; -pub const __WASI_EOVERFLOW: u16 = 61; -pub const __WASI_EOWNERDEAD: u16 = 62; -pub const __WASI_EPERM: u16 = 63; -pub const __WASI_EPIPE: u16 = 64; -pub const __WASI_EPROTO: u16 = 65; -pub const __WASI_EPROTONOSUPPORT: u16 = 66; -pub const __WASI_EPROTOTYPE: u16 = 67; -pub const __WASI_ERANGE: u16 = 68; -pub const __WASI_EROFS: u16 = 69; -pub const __WASI_ESPIPE: u16 = 70; -pub const __WASI_ESRCH: u16 = 71; -pub const __WASI_ESTALE: u16 = 72; -pub const __WASI_ETIMEDOUT: u16 = 73; -pub const __WASI_ETXTBSY: u16 = 74; -pub const __WASI_EXDEV: u16 = 75; -pub const __WASI_ENOTCAPABLE: u16 = 76; +pub type __wasi_errno_t = u32; +pub const __WASI_ESUCCESS: u32 = 0; +pub const __WASI_E2BIG: u32 = 1; +pub const __WASI_EACCES: u32 = 2; +pub const __WASI_EADDRINUSE: u32 = 3; +pub const __WASI_EADDRNOTAVAIL: u32 = 4; +pub const __WASI_EAFNOSUPPORT: u32 = 5; +pub const __WASI_EAGAIN: u32 = 6; +pub const __WASI_EALREADY: u32 = 7; +pub const __WASI_EBADF: u32 = 8; +pub const __WASI_EBADMSG: u32 = 9; +pub const __WASI_EBUSY: u32 = 10; +pub const __WASI_ECANCELED: u32 = 11; +pub const __WASI_ECHILD: u32 = 12; +pub const __WASI_ECONNABORTED: u32 = 13; +pub const __WASI_ECONNREFUSED: u32 = 14; +pub const __WASI_ECONNRESET: u32 = 15; +pub const __WASI_EDEADLK: u32 = 16; +pub const __WASI_EDESTADDRREQ: u32 = 17; +pub const __WASI_EDOM: u32 = 18; +pub const __WASI_EDQUOT: u32 = 19; +pub const __WASI_EEXIST: u32 = 20; +pub const __WASI_EFAULT: u32 = 21; +pub const __WASI_EFBIG: u32 = 22; +pub const __WASI_EHOSTUNREACH: u32 = 23; +pub const __WASI_EIDRM: u32 = 24; +pub const __WASI_EILSEQ: u32 = 25; +pub const __WASI_EINPROGRESS: u32 = 26; +pub const __WASI_EINTR: u32 = 27; +pub const __WASI_EINVAL: u32 = 28; +pub const __WASI_EIO: u32 = 29; +pub const __WASI_EISCONN: u32 = 30; +pub const __WASI_EISDIR: u32 = 31; +pub const __WASI_ELOOP: u32 = 32; +pub const __WASI_EMFILE: u32 = 33; +pub const __WASI_EMLINK: u32 = 34; +pub const __WASI_EMSGSIZE: u32 = 35; +pub const __WASI_EMULTIHOP: u32 = 36; +pub const __WASI_ENAMETOOLONG: u32 = 37; +pub const __WASI_ENETDOWN: u32 = 38; +pub const __WASI_ENETRESET: u32 = 39; +pub const __WASI_ENETUNREACH: u32 = 40; +pub const __WASI_ENFILE: u32 = 41; +pub const __WASI_ENOBUFS: u32 = 42; +pub const __WASI_ENODEV: u32 = 43; +pub const __WASI_ENOENT: u32 = 44; +pub const __WASI_ENOEXEC: u32 = 45; +pub const __WASI_ENOLCK: u32 = 46; +pub const __WASI_ENOLINK: u32 = 47; +pub const __WASI_ENOMEM: u32 = 48; +pub const __WASI_ENOMSG: u32 = 49; +pub const __WASI_ENOPROTOOPT: u32 = 50; +pub const __WASI_ENOSPC: u32 = 51; +pub const __WASI_ENOSYS: u32 = 52; +pub const __WASI_ENOTCONN: u32 = 53; +pub const __WASI_ENOTDIR: u32 = 54; +pub const __WASI_ENOTEMPTY: u32 = 55; +pub const __WASI_ENOTRECOVERABLE: u32 = 56; +pub const __WASI_ENOTSOCK: u32 = 57; +pub const __WASI_ENOTSUP: u32 = 58; +pub const __WASI_ENOTTY: u32 = 59; +pub const __WASI_ENXIO: u32 = 60; +pub const __WASI_EOVERFLOW: u32 = 61; +pub const __WASI_EOWNERDEAD: u32 = 62; +pub const __WASI_EPERM: u32 = 63; +pub const __WASI_EPIPE: u32 = 64; +pub const __WASI_EPROTO: u32 = 65; +pub const __WASI_EPROTONOSUPPORT: u32 = 66; +pub const __WASI_EPROTOTYPE: u32 = 67; +pub const __WASI_ERANGE: u32 = 68; +pub const __WASI_EROFS: u32 = 69; +pub const __WASI_ESPIPE: u32 = 70; +pub const __WASI_ESRCH: u32 = 71; +pub const __WASI_ESTALE: u32 = 72; +pub const __WASI_ETIMEDOUT: u32 = 73; +pub const __WASI_ETXTBSY: u32 = 74; +pub const __WASI_EXDEV: u32 = 75; +pub const __WASI_ENOTCAPABLE: u32 = 76; #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[repr(C)] From 3729c4a8b8248b95f60815322cdd006c528220ca Mon Sep 17 00:00:00 2001 From: Syrus Date: Mon, 22 Apr 2019 12:10:39 -0700 Subject: [PATCH 7/7] Revert "Merge #370" This reverts commit 48a8391f5d199dfaf88fac7cc4eefa194a88c572, reversing changes made to 363b46eca7f43ddaf35ee43e4816bc8c1db9b233. --- lib/wasi/src/syscalls/types.rs | 208 ++++++++++++++++----------------- 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/lib/wasi/src/syscalls/types.rs b/lib/wasi/src/syscalls/types.rs index c030df312..636e1858e 100644 --- a/lib/wasi/src/syscalls/types.rs +++ b/lib/wasi/src/syscalls/types.rs @@ -43,84 +43,84 @@ pub struct __wasi_dirent_t { pub d_type: __wasi_filetype_t, } -pub type __wasi_errno_t = u32; -pub const __WASI_ESUCCESS: u32 = 0; -pub const __WASI_E2BIG: u32 = 1; -pub const __WASI_EACCES: u32 = 2; -pub const __WASI_EADDRINUSE: u32 = 3; -pub const __WASI_EADDRNOTAVAIL: u32 = 4; -pub const __WASI_EAFNOSUPPORT: u32 = 5; -pub const __WASI_EAGAIN: u32 = 6; -pub const __WASI_EALREADY: u32 = 7; -pub const __WASI_EBADF: u32 = 8; -pub const __WASI_EBADMSG: u32 = 9; -pub const __WASI_EBUSY: u32 = 10; -pub const __WASI_ECANCELED: u32 = 11; -pub const __WASI_ECHILD: u32 = 12; -pub const __WASI_ECONNABORTED: u32 = 13; -pub const __WASI_ECONNREFUSED: u32 = 14; -pub const __WASI_ECONNRESET: u32 = 15; -pub const __WASI_EDEADLK: u32 = 16; -pub const __WASI_EDESTADDRREQ: u32 = 17; -pub const __WASI_EDOM: u32 = 18; -pub const __WASI_EDQUOT: u32 = 19; -pub const __WASI_EEXIST: u32 = 20; -pub const __WASI_EFAULT: u32 = 21; -pub const __WASI_EFBIG: u32 = 22; -pub const __WASI_EHOSTUNREACH: u32 = 23; -pub const __WASI_EIDRM: u32 = 24; -pub const __WASI_EILSEQ: u32 = 25; -pub const __WASI_EINPROGRESS: u32 = 26; -pub const __WASI_EINTR: u32 = 27; -pub const __WASI_EINVAL: u32 = 28; -pub const __WASI_EIO: u32 = 29; -pub const __WASI_EISCONN: u32 = 30; -pub const __WASI_EISDIR: u32 = 31; -pub const __WASI_ELOOP: u32 = 32; -pub const __WASI_EMFILE: u32 = 33; -pub const __WASI_EMLINK: u32 = 34; -pub const __WASI_EMSGSIZE: u32 = 35; -pub const __WASI_EMULTIHOP: u32 = 36; -pub const __WASI_ENAMETOOLONG: u32 = 37; -pub const __WASI_ENETDOWN: u32 = 38; -pub const __WASI_ENETRESET: u32 = 39; -pub const __WASI_ENETUNREACH: u32 = 40; -pub const __WASI_ENFILE: u32 = 41; -pub const __WASI_ENOBUFS: u32 = 42; -pub const __WASI_ENODEV: u32 = 43; -pub const __WASI_ENOENT: u32 = 44; -pub const __WASI_ENOEXEC: u32 = 45; -pub const __WASI_ENOLCK: u32 = 46; -pub const __WASI_ENOLINK: u32 = 47; -pub const __WASI_ENOMEM: u32 = 48; -pub const __WASI_ENOMSG: u32 = 49; -pub const __WASI_ENOPROTOOPT: u32 = 50; -pub const __WASI_ENOSPC: u32 = 51; -pub const __WASI_ENOSYS: u32 = 52; -pub const __WASI_ENOTCONN: u32 = 53; -pub const __WASI_ENOTDIR: u32 = 54; -pub const __WASI_ENOTEMPTY: u32 = 55; -pub const __WASI_ENOTRECOVERABLE: u32 = 56; -pub const __WASI_ENOTSOCK: u32 = 57; -pub const __WASI_ENOTSUP: u32 = 58; -pub const __WASI_ENOTTY: u32 = 59; -pub const __WASI_ENXIO: u32 = 60; -pub const __WASI_EOVERFLOW: u32 = 61; -pub const __WASI_EOWNERDEAD: u32 = 62; -pub const __WASI_EPERM: u32 = 63; -pub const __WASI_EPIPE: u32 = 64; -pub const __WASI_EPROTO: u32 = 65; -pub const __WASI_EPROTONOSUPPORT: u32 = 66; -pub const __WASI_EPROTOTYPE: u32 = 67; -pub const __WASI_ERANGE: u32 = 68; -pub const __WASI_EROFS: u32 = 69; -pub const __WASI_ESPIPE: u32 = 70; -pub const __WASI_ESRCH: u32 = 71; -pub const __WASI_ESTALE: u32 = 72; -pub const __WASI_ETIMEDOUT: u32 = 73; -pub const __WASI_ETXTBSY: u32 = 74; -pub const __WASI_EXDEV: u32 = 75; -pub const __WASI_ENOTCAPABLE: u32 = 76; +pub type __wasi_errno_t = u16; +pub const __WASI_ESUCCESS: u16 = 0; +pub const __WASI_E2BIG: u16 = 1; +pub const __WASI_EACCES: u16 = 2; +pub const __WASI_EADDRINUSE: u16 = 3; +pub const __WASI_EADDRNOTAVAIL: u16 = 4; +pub const __WASI_EAFNOSUPPORT: u16 = 5; +pub const __WASI_EAGAIN: u16 = 6; +pub const __WASI_EALREADY: u16 = 7; +pub const __WASI_EBADF: u16 = 8; +pub const __WASI_EBADMSG: u16 = 9; +pub const __WASI_EBUSY: u16 = 10; +pub const __WASI_ECANCELED: u16 = 11; +pub const __WASI_ECHILD: u16 = 12; +pub const __WASI_ECONNABORTED: u16 = 13; +pub const __WASI_ECONNREFUSED: u16 = 14; +pub const __WASI_ECONNRESET: u16 = 15; +pub const __WASI_EDEADLK: u16 = 16; +pub const __WASI_EDESTADDRREQ: u16 = 17; +pub const __WASI_EDOM: u16 = 18; +pub const __WASI_EDQUOT: u16 = 19; +pub const __WASI_EEXIST: u16 = 20; +pub const __WASI_EFAULT: u16 = 21; +pub const __WASI_EFBIG: u16 = 22; +pub const __WASI_EHOSTUNREACH: u16 = 23; +pub const __WASI_EIDRM: u16 = 24; +pub const __WASI_EILSEQ: u16 = 25; +pub const __WASI_EINPROGRESS: u16 = 26; +pub const __WASI_EINTR: u16 = 27; +pub const __WASI_EINVAL: u16 = 28; +pub const __WASI_EIO: u16 = 29; +pub const __WASI_EISCONN: u16 = 30; +pub const __WASI_EISDIR: u16 = 31; +pub const __WASI_ELOOP: u16 = 32; +pub const __WASI_EMFILE: u16 = 33; +pub const __WASI_EMLINK: u16 = 34; +pub const __WASI_EMSGSIZE: u16 = 35; +pub const __WASI_EMULTIHOP: u16 = 36; +pub const __WASI_ENAMETOOLONG: u16 = 37; +pub const __WASI_ENETDOWN: u16 = 38; +pub const __WASI_ENETRESET: u16 = 39; +pub const __WASI_ENETUNREACH: u16 = 40; +pub const __WASI_ENFILE: u16 = 41; +pub const __WASI_ENOBUFS: u16 = 42; +pub const __WASI_ENODEV: u16 = 43; +pub const __WASI_ENOENT: u16 = 44; +pub const __WASI_ENOEXEC: u16 = 45; +pub const __WASI_ENOLCK: u16 = 46; +pub const __WASI_ENOLINK: u16 = 47; +pub const __WASI_ENOMEM: u16 = 48; +pub const __WASI_ENOMSG: u16 = 49; +pub const __WASI_ENOPROTOOPT: u16 = 50; +pub const __WASI_ENOSPC: u16 = 51; +pub const __WASI_ENOSYS: u16 = 52; +pub const __WASI_ENOTCONN: u16 = 53; +pub const __WASI_ENOTDIR: u16 = 54; +pub const __WASI_ENOTEMPTY: u16 = 55; +pub const __WASI_ENOTRECOVERABLE: u16 = 56; +pub const __WASI_ENOTSOCK: u16 = 57; +pub const __WASI_ENOTSUP: u16 = 58; +pub const __WASI_ENOTTY: u16 = 59; +pub const __WASI_ENXIO: u16 = 60; +pub const __WASI_EOVERFLOW: u16 = 61; +pub const __WASI_EOWNERDEAD: u16 = 62; +pub const __WASI_EPERM: u16 = 63; +pub const __WASI_EPIPE: u16 = 64; +pub const __WASI_EPROTO: u16 = 65; +pub const __WASI_EPROTONOSUPPORT: u16 = 66; +pub const __WASI_EPROTOTYPE: u16 = 67; +pub const __WASI_ERANGE: u16 = 68; +pub const __WASI_EROFS: u16 = 69; +pub const __WASI_ESPIPE: u16 = 70; +pub const __WASI_ESRCH: u16 = 71; +pub const __WASI_ESTALE: u16 = 72; +pub const __WASI_ETIMEDOUT: u16 = 73; +pub const __WASI_ETXTBSY: u16 = 74; +pub const __WASI_EXDEV: u16 = 75; +pub const __WASI_ENOTCAPABLE: u16 = 76; #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[repr(C)] @@ -174,8 +174,8 @@ impl __wasi_event_t { } } -pub type __wasi_eventrwflags_t = u32; -pub const __WASI_EVENT_FD_READWRITE_HANGUP: u32 = 1 << 0; +pub type __wasi_eventrwflags_t = u16; +pub const __WASI_EVENT_FD_READWRITE_HANGUP: u16 = 1 << 0; pub type __wasi_eventtype_t = u8; pub const __WASI_EVENTTYPE_CLOCK: u8 = 0; @@ -189,12 +189,12 @@ pub const __WASI_STDIN_FILENO: u32 = 0; pub const __WASI_STDOUT_FILENO: u32 = 1; pub const __WASI_STDERR_FILENO: u32 = 2; -pub type __wasi_fdflags_t = u32; -pub const __WASI_FDFLAG_APPEND: u32 = 1 << 0; -pub const __WASI_FDFLAG_DSYNC: u32 = 1 << 1; -pub const __WASI_FDFLAG_NONBLOCK: u32 = 1 << 2; -pub const __WASI_FDFLAG_RSYNC: u32 = 1 << 3; -pub const __WASI_FDFLAG_SYNC: u32 = 1 << 4; +pub type __wasi_fdflags_t = u16; +pub const __WASI_FDFLAG_APPEND: u16 = 1 << 0; +pub const __WASI_FDFLAG_DSYNC: u16 = 1 << 1; +pub const __WASI_FDFLAG_NONBLOCK: u16 = 1 << 2; +pub const __WASI_FDFLAG_RSYNC: u16 = 1 << 3; +pub const __WASI_FDFLAG_SYNC: u16 = 1 << 4; pub type __wasi_preopentype_t = u8; pub const __WASI_PREOPENTYPE_DIR: u8 = 0; @@ -296,11 +296,11 @@ pub const __WASI_FILETYPE_SOCKET_DGRAM: u8 = 5; pub const __WASI_FILETYPE_SOCKET_STREAM: u8 = 6; pub const __WASI_FILETYPE_SYMBOLIC_LINK: u8 = 7; -pub type __wasi_fstflags_t = u32; -pub const __WASI_FILESTAT_SET_ATIM: u32 = 1 << 0; -pub const __WASI_FILESTAT_SET_ATIM_NOW: u32 = 1 << 1; -pub const __WASI_FILESTAT_SET_MTIM: u32 = 1 << 2; -pub const __WASI_FILESTAT_SET_MTIM_NOW: u32 = 1 << 3; +pub type __wasi_fstflags_t = u16; +pub const __WASI_FILESTAT_SET_ATIM: u16 = 1 << 0; +pub const __WASI_FILESTAT_SET_ATIM_NOW: u16 = 1 << 1; +pub const __WASI_FILESTAT_SET_MTIM: u16 = 1 << 2; +pub const __WASI_FILESTAT_SET_MTIM_NOW: u16 = 1 << 3; pub type __wasi_inode_t = u64; @@ -318,15 +318,15 @@ pub type __wasi_linkcount_t = u32; pub type __wasi_lookupflags_t = u32; pub const __WASI_LOOKUP_SYMLINK_FOLLOW: u32 = 1 << 0; -pub type __wasi_oflags_t = u32; -pub const __WASI_O_CREAT: u32 = 1 << 0; -pub const __WASI_O_DIRECTORY: u32 = 1 << 1; -pub const __WASI_O_EXCL: u32 = 1 << 2; -pub const __WASI_O_TRUNC: u32 = 1 << 3; +pub type __wasi_oflags_t = u16; +pub const __WASI_O_CREAT: u16 = 1 << 0; +pub const __WASI_O_DIRECTORY: u16 = 1 << 1; +pub const __WASI_O_EXCL: u16 = 1 << 2; +pub const __WASI_O_TRUNC: u16 = 1 << 3; -pub type __wasi_riflags_t = u32; -pub const __WASI_SOCK_RECV_PEEK: u32 = 1 << 0; -pub const __WASI_SOCK_RECV_WAITALL: u32 = 1 << 1; +pub type __wasi_riflags_t = u16; +pub const __WASI_SOCK_RECV_PEEK: u16 = 1 << 0; +pub const __WASI_SOCK_RECV_WAITALL: u16 = 1 << 1; pub type __wasi_rights_t = u64; pub const __WASI_RIGHT_FD_DATASYNC: u64 = 1 << 0; @@ -359,14 +359,14 @@ pub const __WASI_RIGHT_PATH_REMOVE_DIRECTORY: u64 = 1 << 26; pub const __WASI_RIGHT_POLL_FD_READWRITE: u64 = 1 << 27; pub const __WASI_RIGHT_SOCK_SHUTDOWN: u64 = 1 << 28; -pub type __wasi_roflags_t = u32; -pub const __WASI_SOCK_RECV_DATA_TRUNCATED: u32 = 1 << 0; +pub type __wasi_roflags_t = u16; +pub const __WASI_SOCK_RECV_DATA_TRUNCATED: u16 = 1 << 0; pub type __wasi_sdflags_t = u8; pub const __WASI_SHUT_RD: u8 = 1 << 0; pub const __WASI_SHUT_WR: u8 = 1 << 1; -pub type __wasi_siflags_t = u32; +pub type __wasi_siflags_t = u16; pub type __wasi_signal_t = u8; pub const __WASI_SIGABRT: u8 = 0; @@ -396,8 +396,8 @@ pub const __WASI_SIGVTALRM: u8 = 23; pub const __WASI_SIGXCPU: u8 = 24; pub const __WASI_SIGXFSZ: u8 = 25; -pub type __wasi_subclockflags_t = u32; -pub const __WASI_SUBSCRIPTION_CLOCK_ABSTIME: u32 = 1 << 0; +pub type __wasi_subclockflags_t = u16; +pub const __WASI_SUBSCRIPTION_CLOCK_ABSTIME: u16 = 1 << 0; #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[repr(C)]