Skip to content
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

Restore Support For All Wasi Clock Types #3386

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions lib/wasi/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,15 @@ pub fn args_sizes_get<M: MemorySize>(
/// The resolution of the clock in nanoseconds
pub fn clock_res_get<M: MemorySize>(
mut ctx: FunctionEnvMut<'_, WasiEnv>,
clock_id: Clockid,
clock_id: Snapshot0Clockid,
resolution: WasmPtr<Timestamp, M>,
) -> Errno {
trace!("wasi::clock_res_get");
let env = ctx.data();
let memory = env.memory_view(&ctx);

let out_addr = resolution.deref(&memory);
let t_out = wasi_try!(platform_clock_res_get(
Snapshot0Clockid::from(clock_id),
out_addr
));
let t_out = wasi_try!(platform_clock_res_get(clock_id, out_addr));
wasi_try_mem!(resolution.write(&memory, t_out as Timestamp));
Errno::Success
}
Expand All @@ -398,7 +395,7 @@ pub fn clock_res_get<M: MemorySize>(
/// The value of the clock in nanoseconds
pub fn clock_time_get<M: MemorySize>(
ctx: FunctionEnvMut<'_, WasiEnv>,
clock_id: Clockid,
clock_id: Snapshot0Clockid,
precision: Timestamp,
time: WasmPtr<Timestamp, M>,
) -> Errno {
Expand All @@ -409,10 +406,7 @@ pub fn clock_time_get<M: MemorySize>(
let env = ctx.data();
let memory = env.memory_view(&ctx);

let t_out = wasi_try!(platform_clock_time_get(
Snapshot0Clockid::from(clock_id),
precision
));
let t_out = wasi_try!(platform_clock_time_get(clock_id, precision));
wasi_try_mem!(time.write(&memory, t_out as Timestamp));

let result = Errno::Success;
Expand Down
6 changes: 3 additions & 3 deletions lib/wasi/src/syscalls/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::{WasiEnv, WasiError, WasiState, WasiThread};
use wasmer::{Memory, Memory32, MemorySize, StoreMut, WasmPtr, WasmSlice};
use wasmer_wasi_types::{
wasi::{Errno, Event, Fd as WasiFd, Filesize, Fstflags, Fstflags, Timestamp, Whence, Clockid},
wasi::{Errno, Event, Fd as WasiFd, Filesize, Fstflags, Fstflags, Timestamp, Whence, Snapshot0Clockid},
types::*,
};

Expand All @@ -27,15 +27,15 @@ pub(crate) fn args_sizes_get(

pub(crate) fn clock_res_get(
ctx: FunctionEnvMut<WasiEnv>,
clock_id: Clockid,
clock_id: Snapshot0Clockid,
resolution: WasmPtr<Timestamp, MemoryType>,
) -> Errno {
super::clock_res_get::<MemoryType>(ctx, clock_id, resolution)
}

pub(crate) fn clock_time_get(
ctx: FunctionEnvMut<WasiEnv>,
clock_id: Clockid,
clock_id: Snapshot0Clockid,
precision: Timestamp,
time: WasmPtr<Timestamp, MemoryType>,
) -> Errno {
Expand Down
8 changes: 4 additions & 4 deletions lib/wasi/src/syscalls/wasix32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use wasmer_wasi_types::types::*;
use wasmer_wasi_types::wasi::{
Addressfamily, Advice, Bid, BusDataFormat, BusErrno, BusHandles, Cid, Clockid, Dircookie,
Errno, Event, EventFdFlags, Fd, Fdflags, Fdstat, Filesize, Filestat, Fstflags, Pid, Prestat,
Rights, Sockoption, Sockstatus, Socktype, Streamsecurity, Subscription, Tid, Timestamp, Tty,
Whence,
Rights, Snapshot0Clockid, Sockoption, Sockstatus, Socktype, Streamsecurity, Subscription, Tid,
Timestamp, Tty, Whence,
};

type MemoryType = Memory32;
Expand All @@ -30,15 +30,15 @@ pub(crate) fn args_sizes_get(

pub(crate) fn clock_res_get(
ctx: FunctionEnvMut<WasiEnv>,
clock_id: Clockid,
clock_id: Snapshot0Clockid,
resolution: WasmPtr<Timestamp, MemoryType>,
) -> Errno {
super::clock_res_get::<MemoryType>(ctx, clock_id, resolution)
}

pub(crate) fn clock_time_get(
ctx: FunctionEnvMut<WasiEnv>,
clock_id: Clockid,
clock_id: Snapshot0Clockid,
precision: Timestamp,
time: WasmPtr<Timestamp, MemoryType>,
) -> Errno {
Expand Down
8 changes: 4 additions & 4 deletions lib/wasi/src/syscalls/wasix64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use wasmer_wasi_types::types::*;
use wasmer_wasi_types::wasi::{
Addressfamily, Advice, Bid, BusDataFormat, BusErrno, BusHandles, Cid, Clockid, Dircookie,
Errno, Event, EventFdFlags, Fd, Fdflags, Fdstat, Filesize, Filestat, Fstflags, Pid, Prestat,
Rights, Sockoption, Sockstatus, Socktype, Streamsecurity, Subscription, Tid, Timestamp, Tty,
Whence,
Rights, Snapshot0Clockid, Sockoption, Sockstatus, Socktype, Streamsecurity, Subscription, Tid,
Timestamp, Tty, Whence,
};

type MemoryType = Memory64;
Expand All @@ -30,15 +30,15 @@ pub(crate) fn args_sizes_get(

pub(crate) fn clock_res_get(
ctx: FunctionEnvMut<WasiEnv>,
clock_id: Clockid,
clock_id: Snapshot0Clockid,
resolution: WasmPtr<Timestamp, MemoryType>,
) -> Errno {
super::clock_res_get::<MemoryType>(ctx, clock_id, resolution)
}

pub(crate) fn clock_time_get(
ctx: FunctionEnvMut<WasiEnv>,
clock_id: Clockid,
clock_id: Snapshot0Clockid,
precision: Timestamp,
time: WasmPtr<Timestamp, MemoryType>,
) -> Errno {
Expand Down