From 736bddfe17564aac055b1128896e914ba4a3c55c Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Tue, 21 May 2019 10:35:51 -0700 Subject: [PATCH] debug log error in windows clock, conditionally pull in winapi --- lib/wasi/src/lib.rs | 2 ++ lib/wasi/src/syscalls/windows.rs | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index 8621dc55e..efbb19457 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -2,6 +2,8 @@ #[macro_use] extern crate log; +#[cfg(target = windows)] +extern crate winapi; #[macro_use] mod macros; diff --git a/lib/wasi/src/syscalls/windows.rs b/lib/wasi/src/syscalls/windows.rs index e86caa2e8..a6627be94 100644 --- a/lib/wasi/src/syscalls/windows.rs +++ b/lib/wasi/src/syscalls/windows.rs @@ -5,7 +5,7 @@ pub fn platform_clock_res_get( clock_id: __wasi_clockid_t, resolution: &Cell<__wasi_timestamp_t>, ) -> __wasi_errno_t { - let resolution = match clock_id { + let resolution_val = match clock_id { // resolution of monotonic clock at 10ms, from: // https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-gettickcount64 __WASI_CLOCK_MONOTONIC => 10_000_000, @@ -18,7 +18,7 @@ pub fn platform_clock_res_get( return __WASI_EINVAL; } }; - resolution.set(resolution); + resolution.set(resolution_val); __WASI_ESUCCESS } @@ -35,7 +35,10 @@ pub fn platform_clock_time_get( __WASI_CLOCK_REALTIME => { let duration = wasi_try!(std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) - .ok_or(__WASI_EIO)); + .map_err(|e| { + debug!("Error in wasi::platform_clock_time_get: {:?}", e); + __WASI_EIO + })); duration.as_nanos() as u64 } __WASI_CLOCK_PROCESS_CPUTIME_ID => {