add structure for cross-platform wasi syscall implementations

This commit is contained in:
Mark McCaskey 2019-03-28 17:09:39 -07:00
parent 72ec4ab9e5
commit bd09343fca
5 changed files with 81 additions and 7 deletions

View File

@ -1,6 +1,19 @@
pub mod types;
#[cfg(any(target_os = "linux", target_os = "macos"))]
pub mod unix;
#[cfg(any(target_os = "windows"))]
pub mod windows;
use crate::state::WasiState;
use types::*;
use wasmer_runtime_core::{memory::Memory, vm::Ctx};
#[cfg(any(target_os = "linux", target_os = "macos"))]
pub use unix::*;
#[cfg(any(target_os = "windows"))]
pub use windows::*;
#[allow(clippy::mut_from_ref)]
fn get_wasi_state(ctx: &Ctx) -> &mut WasiState {
unsafe { &mut *(ctx.data as *mut WasiState) }
@ -59,13 +72,6 @@ pub fn args_sizes_get(ctx: &mut Ctx, argc_out: u32, argv_buf_size_out: u32) {
memory.view::<u32>()[(argv_buf_size_out / 4) as usize].set(total_arg_size as u32);
}
pub fn clock_res_get(ctx: &mut Ctx) {
unimplemented!()
}
pub fn clock_time_get(ctx: &mut Ctx) {
unimplemented!()
}
/// ### `environ_get()`
/// Read environment variable data.
/// The sizes of the buffers should match that returned by [`environ_sizes_get()`](#environ_sizes_get).

View File

@ -0,0 +1,19 @@
use crate::syscalls::types::*;
use wasmer_runtime_core::{memory::Memory, vm::Ctx};
pub fn clock_res_get(
ctx: &mut Ctx,
clock_id: __wasi_clockid_t,
resolution: WasmPtr<__wasi_timestamp_t>,
) -> __wasi_errno_t {
__WASI_EINVAL
}
pub fn clock_time_get(
ctx: &mut Ctx,
clock_id: __wasi_clockid_t,
precision: __wasi_timestamp_t,
time: WasmPtr<__wasi_timestamp_t>,
) -> __wasi_errno_t {
unimplemented!()
}

View File

@ -0,0 +1,19 @@
use crate::syscalls::types::*;
use wasmer_runtime_core::{memory::Memory, vm::Ctx};
pub fn clock_res_get(
ctx: &mut Ctx,
clock_id: __wasi_clockid_t,
resolution: WasmPtr<__wasi_timestamp_t>,
) -> __wasi_errno_t {
__WASI_EINVAL
}
pub fn clock_time_get(
ctx: &mut Ctx,
clock_id: __wasi_clockid_t,
precision: __wasi_timestamp_t,
time: WasmPtr<__wasi_timestamp_t>,
) -> __wasi_errno_t {
unimplemented!()
}

View File

@ -0,0 +1,11 @@
#[cfg(target_os = "linux")]
pub mod linux;
#[cfg(target_os = "macos")]
pub mod macos;
#[cfg(target_os = "linux")]
pub use linux::*;
#[cfg(target_os = "macos")]
pub use macos::*;

View File

@ -0,0 +1,19 @@
use crate::syscalls::types::*;
use wasmer_runtime_core::{memory::Memory, vm::Ctx};
pub fn clock_res_get(
ctx: &mut Ctx,
clock_id: __wasi_clockid_t,
resolution: WasmPtr<__wasi_timestamp_t>,
) -> __wasi_errno_t {
__WASI_EINVAL
}
pub fn clock_time_get(
ctx: &mut Ctx,
clock_id: __wasi_clockid_t,
precision: __wasi_timestamp_t,
time: WasmPtr<__wasi_timestamp_t>,
) -> __wasi_errno_t {
unimplemented!()
}