Add support for wasi_snapshot_preview1. (#592)
* Add support for wasi_snapshot_preview1. This adds support for the new ABI, while preserving compatibility support for the old ABI. * Fix compilation on platforms where nlink_t isn't 64-bit. * rustfmt * Fix Windows build errors.
This commit is contained in:
@@ -2,8 +2,24 @@ macro_rules! hostcalls {
|
||||
($(pub unsafe fn $name:ident($($arg:ident: $ty:ty,)*) -> $ret:ty;)*) => ($(
|
||||
#[wasi_common_cbindgen::wasi_common_cbindgen]
|
||||
pub unsafe fn $name($($arg: $ty,)*) -> $ret {
|
||||
let ret = match crate::hostcalls_impl::$name($($arg,)*) {
|
||||
Ok(()) => crate::wasi::__WASI_ESUCCESS,
|
||||
let ret = match hostcalls_impl::$name($($arg,)*) {
|
||||
Ok(()) => wasi::__WASI_ERRNO_SUCCESS,
|
||||
Err(e) => e.as_wasi_errno(),
|
||||
};
|
||||
|
||||
ret
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
// Like `hostcalls`, but uses `wasi_common_cbindgen_old`, which means
|
||||
// it doesn't declare a non-mangled function name.
|
||||
macro_rules! hostcalls_old {
|
||||
($(pub unsafe fn $name:ident($($arg:ident: $ty:ty,)*) -> $ret:ty;)*) => ($(
|
||||
#[wasi_common_cbindgen::wasi_common_cbindgen_old]
|
||||
pub unsafe fn $name($($arg: $ty,)*) -> $ret {
|
||||
let ret = match hostcalls_impl::$name($($arg,)*) {
|
||||
Ok(()) => wasi::__WASI_ERRNO_SUCCESS,
|
||||
Err(e) => e.as_wasi_errno(),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user