debug log error in windows clock, conditionally pull in winapi

This commit is contained in:
Mark McCaskey 2019-05-21 10:35:51 -07:00
parent 08b4b639f4
commit 736bddfe17
2 changed files with 8 additions and 3 deletions

View File

@ -2,6 +2,8 @@
#[macro_use]
extern crate log;
#[cfg(target = windows)]
extern crate winapi;
#[macro_use]
mod macros;

View File

@ -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 => {