-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Rust impl of wasmtime_ssp_sched_yield #127
Conversation
wasmtime-wasi/src/host.rs
Outdated
)] | ||
#[cfg_attr(target_os = "haiku", link_name = "_errnop")] | ||
fn errno_location() -> *mut libc::c_int; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't decide between using nix
crate or linking to errno
ourselves, but in the end, decided to borrow the functionality for *nix directly from Rust's libstd
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the errno crate for cross-platform access to errno (wasmtime uses this in a few other places already).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, nice! I'll investigate today and make amends.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, we're now using the errno crate.
wasmtime-wasi/src/host.rs
Outdated
// #endif | ||
// #if EWOULDBLOCK != EAGAIN | ||
// [EWOULDBLOCK] = __WASI_EAGAIN | ||
// #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to handle these two cases here. Suggestions more than welcome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this:
#[allow(unreachable_patterns)]
match errno {
...
libc::EAGAIN | libc::EWOULDBLOCK => __WASI_EAGAIN,
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it the way you suggested. I think it looks great now. Have a look and lemme know what you reckon!
Also, add Rust implementation of errno and convert_errno.
wasmtime-wasi/src/host.rs
Outdated
)] | ||
#[cfg_attr(target_os = "haiku", link_name = "_errnop")] | ||
fn errno_location() -> *mut libc::c_int; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use the errno crate for cross-platform access to errno (wasmtime uses this in a few other places already).
pub const __WASI_ETIMEDOUT: __wasi_errno_t = 73; | ||
pub const __WASI_ETXTBSY: __wasi_errno_t = 74; | ||
pub const __WASI_EXDEV: __wasi_errno_t = 75; | ||
pub const __WASI_ENOTCAPABLE: __wasi_errno_t = 76; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I convinced myself that it's ok to put these here, because eventually, wasmtime_ssp.h and the bindgen-generated wasmtime_ssp.rs will go away and we'll need these :-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! :-)
wasmtime-wasi/src/host.rs
Outdated
pub const __WASI_EXDEV: __wasi_errno_t = 75; | ||
pub const __WASI_ENOTCAPABLE: __wasi_errno_t = 76; | ||
|
||
/// Convert POSIX error to CloudABI error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should now say "... to WASI error".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed!
libc::ENOSYS => host::__WASI_ENOSYS, | ||
// TODO: verify if this is correct | ||
#[cfg(target_os = "freebsd")] | ||
libc::ENOTCAPABLE => host::__WASI_ENOTCAPABLE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is correct, at least at present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
They are now blacklisted in the bindgen.
Great! |
…ocessor processor: update zk processor
This turns the `wasmtime_fibre` into a module called `fibre` in the `runtime` crate. As a result, the `wasmtime_fibre` crate is removed from the workspace. This is helpful for specializing the fibre implementation further for our purposes in the future. Arguably, we could actually make `fibre` a submodule of the existing `continuation` module in `runtime` (i.e., instead of putting it at `wasmtime_runtime::fibre`, put it at `wasmtime_runtime::continuation::fibre`), but I decided against changing the directory structure further for now. The only noteworthy changes outside of moving the files are: 1. The types `SwitchDirection` and `SwitchDirectionEnum`, previously in the `wasmtime_fibre` crate, are now in the `continuations` crate. We need access to these in cranelift. 2. Instead of adding a lot of /// TODO comments I bailed out of mandatory doc comments (as imposed by the `runtime` crate) on pub definitions in the new `fibre` module.
Generate `MovWide` spec. Updates avanhatt#36 avanhatt#35
Verify `load_i64` expansions involving `MovWide` instructions. We added `MovWide` ASLp specs in bytecodealliance#127. This PR provides additional specs to utilize them. Updates avanhatt#49 avanhatt#34
Also, add Rust implementation of
errno
andconvert_errno
.This PR addresses #120.
Caveats:
errno
andconvert_errno
are currently implemented only for *nix OSes (the implementation borrowed from Rust'slibstd
; please have a look in the comments below)missing handling ofEOPNOTSUPP
andEWOULDBLOCK
All comments and suggestions are more than welcome!
EDIT: to address bindgen issues reported by @heyitsanthony in #126, this PR also manually defines
host::__wasi_errno_t
errors, and blacklists them in bindgen.