Implementation for the wasi_clock_time/res#2637
Implementation for the wasi_clock_time/res#2637wenyongh merged 1 commit intobytecodealliance:dev/wasi-libc-windowsfrom
Conversation
core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c
Outdated
Show resolved
Hide resolved
beb4921 to
dbd8f53
Compare
|
|
||
| /* Get current resolution of clock id */ | ||
| int | ||
| os_clock_res_get(bh_clock_id_t clock_id, uint64 *resolution); |
There was a problem hiding this comment.
we already have the declaration in platform_common.h so the declaration should probably be removed from this file.
| * @return BHT_OK if success; otherwise, BHT_ERROR | ||
| */ | ||
| int | ||
| os_clock_res_get(bh_clock_id_t clock_id, uint64 *resolution); |
There was a problem hiding this comment.
I'm actually wondering if we should move those two declarations to platform_api_extension.h file.
dbd8f53 to
ffaf3d6
Compare
| } | ||
|
|
||
| __wasi_errno_t | ||
| wasmtime_ssp_clock_time_get(__wasi_clockid_t clock_id, |
There was a problem hiding this comment.
Sorry for the late comment, did we consider implementing these functions (wasmtime_ssp_clock_time_get and wasmtime_ssp_clock_res_get) directly in each platform? Unlike the filesystem or socket functions, they don't contain any logic to lookup a fd object from the fd table so it seems they are very small wrapper around the platform implementation anyway.
Also, since os_clock_time_get and os_clock_res_get are only used in the WASI libc implementation, we could probably define the signature for these functions in terms of WASI types (__wasi_clockid_t etc.) to avoid some boilerplate. What do you think?
There was a problem hiding this comment.
I think that's not been done mainly due to the circular dependency as discussed in #2585 (comment)
I think we can merge this as it is now, but once your change @zoraaver is merged, we'll make an update to this code and simplify it if possible. How does it sound to you?
There was a problem hiding this comment.
Agree, I think the PR is in a good state to merge now and we can simplify the code later once #2585 is merged.
d1b4d12 to
cc86166
Compare
|
@wenyongh would you be able to have a look at this PR? |
core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c
Outdated
Show resolved
Hide resolved
core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c
Outdated
Show resolved
Hide resolved
core/shared/utils/bh_time.c
Outdated
| #include "bh_time.h" | ||
|
|
||
| uint64 | ||
| convert_timespec_to_nanoseconds(const struct timespec *ts) |
There was a problem hiding this comment.
How about renaming to bh_timespec_to_nanoseconds? Adding bh_ prefix is because that APIs in core/shared/utils usually start with it.
105abc9 to
bf15d84
Compare
33b4b61 to
e1aacc0
Compare
| { | ||
| } |
There was a problem hiding this comment.
Should not change the code here. It will lead to CI code guideline check failure.
| } | ||
| #ifndef BH_PLATFORM_WINDOWS | ||
| /* | ||
| * wasi_clockid_to_clockid is a plceholder in this file so that poll_oneoff complies, |
| */ | ||
| bool | ||
| wasi_clockid_to_clockid(__wasi_clockid_t in, clockid_t* out) | ||
| { |
There was a problem hiding this comment.
Invalid coding style, could you use clang-format-12 to format the code?
https://github.com/bytecodealliance/wasm-micro-runtime/actions/runs/6573605221/job/17856981299
| *out_counter = counter.QuadPart; | ||
| return BHT_OK; | ||
| } | ||
|
|
There was a problem hiding this comment.
Had better remove unused line?
e1aacc0 to
0408808
Compare
core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c
Outdated
Show resolved
Hide resolved
db4fa6c to
04820c0
Compare
core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c
Outdated
Show resolved
Hide resolved
core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c
Outdated
Show resolved
Hide resolved
04820c0 to
884de74
Compare
884de74 to
330fda5
Compare
Refactoring the clock functions to use WASI types so we can simplify the code and remove some unnecessary boilerplate. See bytecodealliance#2637 (comment) for details.
Refactoring the clock functions to use WASI types so we can simplify the code and remove some unnecessary boilerplate. See bytecodealliance#2637 (comment) for details.
Refactoring the clock functions to use WASI types so we can simplify the code and remove some unnecessary boilerplate. See bytecodealliance#2637 (comment) for details.
Refactoring the clock functions to use WASI types so we can simplify the code and remove some unnecessary boilerplate. See bytecodealliance#2637 (comment) for details.
Refactoring the clock functions to use WASI types so we can simplify the code and remove some unnecessary boilerplate. See bytecodealliance#2637 (comment) for details.
Refactoring the clock functions to use WASI types so we can simplify the code and remove some unnecessary boilerplate. See bytecodealliance#2637 (comment) for details.
Refactoring the clock functions to use WASI types so we can simplify the code and remove some unnecessary boilerplate. See bytecodealliance#2637 (comment) for details.
Refactoring the clock functions to use WASI types so we can simplify the code and remove some unnecessary boilerplate. See #2637 (comment) for details.
Add os_clock_res_get and os_clock_time_get in platform_api_extension.h, and implement them in posix like platforms and windows platform.
Refactoring the clock functions to use WASI types so we can simplify the code and remove some unnecessary boilerplate. See bytecodealliance#2637 (comment) for details.
No description provided.