wasmer_wasix/syscalls/wasi/
clock_res_get.rs

1use super::*;
2use crate::syscalls::*;
3
4/// ### `clock_res_get()`
5/// Get the resolution of the specified clock
6/// Input:
7/// - `Clockid clock_id`
8///     The ID of the clock to get the resolution of
9/// Output:
10/// - `Timestamp *resolution`
11///     The resolution of the clock in nanoseconds
12#[instrument(level = "trace", skip_all, ret)]
13pub fn clock_res_get<M: MemorySize>(
14    mut ctx: FunctionEnvMut<'_, WasiEnv>,
15    clock_id: Snapshot0Clockid,
16    resolution: WasmPtr<Timestamp, M>,
17) -> Errno {
18    let env = ctx.data();
19    let memory = unsafe { env.memory_view(&ctx) };
20
21    let out_addr = resolution.deref(&memory);
22    let t_out = wasi_try!(platform_clock_res_get(clock_id, out_addr));
23    wasi_try_mem!(resolution.write(&memory, t_out as Timestamp));
24    Errno::Success
25}