Skip to content

Implementation for the wasi_clock_time/res#2637

Merged
wenyongh merged 1 commit intobytecodealliance:dev/wasi-libc-windowsfrom
fadumina1:dev/wasi-libc-windows
Oct 22, 2023
Merged

Implementation for the wasi_clock_time/res#2637
wenyongh merged 1 commit intobytecodealliance:dev/wasi-libc-windowsfrom
fadumina1:dev/wasi-libc-windows

Conversation

@fadumina1
Copy link
Contributor

No description provided.

@fadumina1 fadumina1 force-pushed the dev/wasi-libc-windows branch 3 times, most recently from beb4921 to dbd8f53 Compare October 17, 2023 09:19

/* Get current resolution of clock id */
int
os_clock_res_get(bh_clock_id_t clock_id, uint64 *resolution);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually wondering if we should move those two declarations to platform_api_extension.h file.

@fadumina1 fadumina1 force-pushed the dev/wasi-libc-windows branch from dbd8f53 to ffaf3d6 Compare October 17, 2023 12:54
}

__wasi_errno_t
wasmtime_ssp_clock_time_get(__wasi_clockid_t clock_id,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I think the PR is in a good state to merge now and we can simplify the code later once #2585 is merged.

@fadumina1 fadumina1 force-pushed the dev/wasi-libc-windows branch 2 times, most recently from d1b4d12 to cc86166 Compare October 18, 2023 10:27
@loganek
Copy link
Contributor

loganek commented Oct 18, 2023

@wenyongh would you be able to have a look at this PR?

#include "bh_time.h"

uint64
convert_timespec_to_nanoseconds(const struct timespec *ts)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about renaming to bh_timespec_to_nanoseconds? Adding bh_ prefix is because that APIs in core/shared/utils usually start with it.

@fadumina1 fadumina1 force-pushed the dev/wasi-libc-windows branch 6 times, most recently from 105abc9 to bf15d84 Compare October 19, 2023 10:27
@fadumina1 fadumina1 force-pushed the dev/wasi-libc-windows branch 2 times, most recently from 33b4b61 to e1aacc0 Compare October 19, 2023 10:59
Comment on lines +3639 to +3663
{
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be placeholder

*/
bool
wasi_clockid_to_clockid(__wasi_clockid_t in, clockid_t* out)
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had better remove unused line?

@fadumina1 fadumina1 force-pushed the dev/wasi-libc-windows branch from e1aacc0 to 0408808 Compare October 19, 2023 11:11
@fadumina1 fadumina1 force-pushed the dev/wasi-libc-windows branch from 04820c0 to 884de74 Compare October 20, 2023 14:20
@fadumina1 fadumina1 force-pushed the dev/wasi-libc-windows branch from 884de74 to 330fda5 Compare October 20, 2023 15:21
Copy link
Contributor

@zoraaver zoraaver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@wenyongh wenyongh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@loganek loganek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

@wenyongh wenyongh merged commit a874bf0 into bytecodealliance:dev/wasi-libc-windows Oct 22, 2023
zoraaver added a commit to zoraaver/wasm-micro-runtime that referenced this pull request Oct 24, 2023
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.
zoraaver added a commit to zoraaver/wasm-micro-runtime that referenced this pull request Oct 24, 2023
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.
zoraaver added a commit to zoraaver/wasm-micro-runtime that referenced this pull request Oct 24, 2023
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.
zoraaver added a commit to zoraaver/wasm-micro-runtime that referenced this pull request Oct 24, 2023
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.
zoraaver added a commit to zoraaver/wasm-micro-runtime that referenced this pull request Oct 24, 2023
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.
zoraaver added a commit to zoraaver/wasm-micro-runtime that referenced this pull request Oct 25, 2023
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.
zoraaver added a commit to zoraaver/wasm-micro-runtime that referenced this pull request Oct 25, 2023
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.
wenyongh pushed a commit that referenced this pull request Oct 25, 2023
Refactoring the clock functions to use WASI types so we can simplify the
code and remove some unnecessary boilerplate. See
#2637 (comment)
for details.
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
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.
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants