mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 22:25:40 +00:00
add structure for cross-platform wasi syscall implementations
This commit is contained in:
parent
72ec4ab9e5
commit
bd09343fca
@ -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 crate::state::WasiState;
|
||||||
|
use types::*;
|
||||||
use wasmer_runtime_core::{memory::Memory, vm::Ctx};
|
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)]
|
#[allow(clippy::mut_from_ref)]
|
||||||
fn get_wasi_state(ctx: &Ctx) -> &mut WasiState {
|
fn get_wasi_state(ctx: &Ctx) -> &mut WasiState {
|
||||||
unsafe { &mut *(ctx.data as *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);
|
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()`
|
/// ### `environ_get()`
|
||||||
/// Read environment variable data.
|
/// Read environment variable data.
|
||||||
/// The sizes of the buffers should match that returned by [`environ_sizes_get()`](#environ_sizes_get).
|
/// The sizes of the buffers should match that returned by [`environ_sizes_get()`](#environ_sizes_get).
|
||||||
|
19
lib/wasi/src/syscalls/unix/linux.rs
Normal file
19
lib/wasi/src/syscalls/unix/linux.rs
Normal 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!()
|
||||||
|
}
|
19
lib/wasi/src/syscalls/unix/macos.rs
Normal file
19
lib/wasi/src/syscalls/unix/macos.rs
Normal 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!()
|
||||||
|
}
|
11
lib/wasi/src/syscalls/unix/mod.rs
Normal file
11
lib/wasi/src/syscalls/unix/mod.rs
Normal 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::*;
|
19
lib/wasi/src/syscalls/windows.rs
Normal file
19
lib/wasi/src/syscalls/windows.rs
Normal 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!()
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user