diff --git a/CHANGELOG.md b/CHANGELOG.md index 23c4ffcc8..1b4051de1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Blocks of changes will separated by version increments. ## 0.4.2 - 2019-05-16 +- [#457](https://github.com/wasmerio/wasmer/pull/457) Implement file metadata for WASI, fix bugs in WASI clock code for Unix platforms - [#416](https://github.com/wasmerio/wasmer/pull/416) Remote code loading framework - [#449](https://github.com/wasmerio/wasmer/pull/449) Fix bugs: opening host files in filestat and opening with write permissions unconditionally in path_open - [#442](https://github.com/wasmerio/wasmer/pull/442) Misc. WASI FS fixes and implement readdir diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index 6d0c2e148..429ec1da8 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -188,7 +188,10 @@ pub fn clock_time_get( precision: __wasi_timestamp_t, time: WasmPtr<__wasi_timestamp_t>, ) -> __wasi_errno_t { - debug!("wasi::clock_time_get"); + debug!( + "wasi::clock_time_get clock_id: {}, precision: {}", + clock_id, precision + ); let memory = ctx.memory(0); let out_addr = wasi_try!(time.deref(memory)); diff --git a/lib/wasi/src/syscalls/types.rs b/lib/wasi/src/syscalls/types.rs index d484db08b..7971fb503 100644 --- a/lib/wasi/src/syscalls/types.rs +++ b/lib/wasi/src/syscalls/types.rs @@ -24,9 +24,9 @@ pub struct __wasi_ciovec_t { unsafe impl ValueType for __wasi_ciovec_t {} pub type __wasi_clockid_t = u32; -pub const __WASI_CLOCK_MONOTONIC: u32 = 0; -pub const __WASI_CLOCK_PROCESS_CPUTIME_ID: u32 = 1; -pub const __WASI_CLOCK_REALTIME: u32 = 2; +pub const __WASI_CLOCK_REALTIME: u32 = 0; +pub const __WASI_CLOCK_MONOTONIC: u32 = 1; +pub const __WASI_CLOCK_PROCESS_CPUTIME_ID: u32 = 2; pub const __WASI_CLOCK_THREAD_CPUTIME_ID: u32 = 3; pub type __wasi_device_t = u64; diff --git a/lib/wasi/src/syscalls/unix/mod.rs b/lib/wasi/src/syscalls/unix/mod.rs index 4c9cfada3..43a79319f 100644 --- a/lib/wasi/src/syscalls/unix/mod.rs +++ b/lib/wasi/src/syscalls/unix/mod.rs @@ -23,7 +23,8 @@ pub fn platform_clock_res_get( (clock_getres(unix_clock_id, &mut timespec_out), timespec_out) }; - resolution.set(timespec_out.tv_nsec as __wasi_timestamp_t); + let t_out = (timespec_out.tv_sec * 1_000_000_000).wrapping_add(timespec_out.tv_nsec); + resolution.set(t_out as __wasi_timestamp_t); // TODO: map output of clock_getres to __wasi_errno_t __WASI_ESUCCESS @@ -50,9 +51,8 @@ pub fn platform_clock_time_get( ) }; - // TODO: adjust output by precision... - - time.set(timespec_out.tv_nsec as __wasi_timestamp_t); + let t_out = (timespec_out.tv_sec * 1_000_000_000).wrapping_add(timespec_out.tv_nsec); + time.set(t_out as __wasi_timestamp_t); // TODO: map output of clock_gettime to __wasi_errno_t __WASI_ESUCCESS