mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-25 14:41:32 +00:00
fix WASI clock bugs
This commit is contained in:
@ -10,6 +10,7 @@ Blocks of changes will separated by version increments.
|
|||||||
|
|
||||||
## 0.4.2 - 2019-05-16
|
## 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
|
- [#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
|
- [#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
|
- [#442](https://github.com/wasmerio/wasmer/pull/442) Misc. WASI FS fixes and implement readdir
|
||||||
|
@ -188,7 +188,10 @@ pub fn clock_time_get(
|
|||||||
precision: __wasi_timestamp_t,
|
precision: __wasi_timestamp_t,
|
||||||
time: WasmPtr<__wasi_timestamp_t>,
|
time: WasmPtr<__wasi_timestamp_t>,
|
||||||
) -> __wasi_errno_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 memory = ctx.memory(0);
|
||||||
|
|
||||||
let out_addr = wasi_try!(time.deref(memory));
|
let out_addr = wasi_try!(time.deref(memory));
|
||||||
|
@ -24,9 +24,9 @@ pub struct __wasi_ciovec_t {
|
|||||||
unsafe impl ValueType for __wasi_ciovec_t {}
|
unsafe impl ValueType for __wasi_ciovec_t {}
|
||||||
|
|
||||||
pub type __wasi_clockid_t = u32;
|
pub type __wasi_clockid_t = u32;
|
||||||
pub const __WASI_CLOCK_MONOTONIC: u32 = 0;
|
pub const __WASI_CLOCK_REALTIME: u32 = 0;
|
||||||
pub const __WASI_CLOCK_PROCESS_CPUTIME_ID: u32 = 1;
|
pub const __WASI_CLOCK_MONOTONIC: u32 = 1;
|
||||||
pub const __WASI_CLOCK_REALTIME: u32 = 2;
|
pub const __WASI_CLOCK_PROCESS_CPUTIME_ID: u32 = 2;
|
||||||
pub const __WASI_CLOCK_THREAD_CPUTIME_ID: u32 = 3;
|
pub const __WASI_CLOCK_THREAD_CPUTIME_ID: u32 = 3;
|
||||||
|
|
||||||
pub type __wasi_device_t = u64;
|
pub type __wasi_device_t = u64;
|
||||||
|
@ -23,7 +23,8 @@ pub fn platform_clock_res_get(
|
|||||||
(clock_getres(unix_clock_id, &mut timespec_out), timespec_out)
|
(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
|
// TODO: map output of clock_getres to __wasi_errno_t
|
||||||
__WASI_ESUCCESS
|
__WASI_ESUCCESS
|
||||||
@ -50,9 +51,8 @@ pub fn platform_clock_time_get(
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: adjust output by precision...
|
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);
|
||||||
time.set(timespec_out.tv_nsec as __wasi_timestamp_t);
|
|
||||||
|
|
||||||
// TODO: map output of clock_gettime to __wasi_errno_t
|
// TODO: map output of clock_gettime to __wasi_errno_t
|
||||||
__WASI_ESUCCESS
|
__WASI_ESUCCESS
|
||||||
|
Reference in New Issue
Block a user