Auto-generate the hostcalls module of wasi-common (#846)
* Auto-generate shims for old `wasi_unstable` module This commit is effectively just doing what #707 already did, but applying it to the `snapshot_0` module as well. The end result is the same, where we cut down on all the boilerplate in `snapshot_0` and bring it in line with the main `wasi_snapshot_preview1` implementation. The goal here is to make it easier to change the two in tandem since they're both doing the same thing. * Migrate `wasi_common::hostcalls` to a macro This commit migrates the `hostcalls` module to being auto-generated by a macro rather than duplicating a handwritten signature for each wasi syscall. * Auto-generate snapshot_0's `hostcalls` module Similar to the previous commit, but for `snapshot_0` * Delete the `wasi-common-cbindgen` crate This is no longer needed with the hostcalls macro now, we can easily fold the definition of the cbindgen macro into the same crate. * Rustfmt * Fix windows build errors * Rustfmt * Remove now no-longer-necessary code * rustfmt
This commit is contained in:
@@ -326,3 +326,18 @@ pub(crate) struct FdEventData<'a> {
|
||||
pub(crate) r#type: wasi::__wasi_eventtype_t,
|
||||
pub(crate) userdata: wasi::__wasi_userdata_t,
|
||||
}
|
||||
|
||||
pub(crate) fn proc_exit(_wasi_ctx: &WasiCtx, _memory: &mut [u8], rval: wasi::__wasi_exitcode_t) {
|
||||
trace!("proc_exit(rval={:?})", rval);
|
||||
// TODO: Rather than call std::process::exit here, we should trigger a
|
||||
// stack unwind similar to a trap.
|
||||
std::process::exit(rval as i32);
|
||||
}
|
||||
|
||||
pub(crate) fn proc_raise(
|
||||
_wasi_ctx: &WasiCtx,
|
||||
_memory: &mut [u8],
|
||||
_sig: wasi::__wasi_signal_t,
|
||||
) -> Result<()> {
|
||||
unimplemented!("proc_raise")
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
mod fs;
|
||||
mod fs_helpers;
|
||||
mod misc;
|
||||
mod sock;
|
||||
|
||||
pub(crate) use self::fs::*;
|
||||
pub(crate) use self::fs_helpers::PathGet;
|
||||
pub(crate) use self::misc::*;
|
||||
pub(crate) use self::sock::*;
|
||||
|
||||
36
crates/wasi-common/src/hostcalls_impl/sock.rs
Normal file
36
crates/wasi-common/src/hostcalls_impl/sock.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use crate::ctx::WasiCtx;
|
||||
use crate::{wasi, wasi32, Result};
|
||||
|
||||
pub fn sock_recv(
|
||||
_wasi_ctx: &WasiCtx,
|
||||
_memory: &mut [u8],
|
||||
_sock: wasi::__wasi_fd_t,
|
||||
_ri_data: wasi32::uintptr_t,
|
||||
_ri_data_len: wasi32::size_t,
|
||||
_ri_flags: wasi::__wasi_riflags_t,
|
||||
_ro_datalen: wasi32::uintptr_t,
|
||||
_ro_flags: wasi32::uintptr_t,
|
||||
) -> Result<()> {
|
||||
unimplemented!("sock_recv")
|
||||
}
|
||||
|
||||
pub fn sock_send(
|
||||
_wasi_ctx: &WasiCtx,
|
||||
_memory: &mut [u8],
|
||||
_sock: wasi::__wasi_fd_t,
|
||||
_si_data: wasi32::uintptr_t,
|
||||
_si_data_len: wasi32::size_t,
|
||||
_si_flags: wasi::__wasi_siflags_t,
|
||||
_so_datalen: wasi32::uintptr_t,
|
||||
) -> Result<()> {
|
||||
unimplemented!("sock_send")
|
||||
}
|
||||
|
||||
pub fn sock_shutdown(
|
||||
_wasi_ctx: &WasiCtx,
|
||||
_memory: &mut [u8],
|
||||
_sock: wasi::__wasi_fd_t,
|
||||
_how: wasi::__wasi_sdflags_t,
|
||||
) -> Result<()> {
|
||||
unimplemented!("sock_shutdown")
|
||||
}
|
||||
Reference in New Issue
Block a user