-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] Port SE-0329 Clock APIs to WASI #58514
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[stdlib] Port SE-0329 Clock APIs to WASI #58514
Conversation
WASI doesn't have "suspending-time" concept, so use `CLOCK_MONOTONIC` for both "continuous" and "suspending" clocks. WASI's "monotonic" doesn't guarantee any underlying system call implementation, but most of major implementations use `CLOCK_MONOTONIC` for all underlying platforms. This partially buildfixes this platform. See also: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#variant-cases
cc: @phausler |
@swift-ci Please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised that WASI does not have a suspending clock and only has a continuous source of time. 'cause on Linux CLOCK_MONOTONIC
is the suspending clock.
Since this is the case would it make sense to make the suspending clock API only available on platforms that have it? I was under the presumption that behavior was available on all major OS platforms.
@phausler Thank you for taking a look :)
To be precise, WASI has neither a "continuous" nor "suspending" clock. The continuousness of WASI's
Since we can't guarantee continuousness, the behavior of clocks are differ from their semantics. So if we are very sensitive about that, we shouldn't provide continuous or suspending clocks. However, if we make all clocks unavailable, we can't use the Clock API on those platforms at all. So could we keep this rough implementation for now, then introduce a third clock |
Is this PR ready to merge? |
I think it's ok to merge |
Which PRs should we land next? It seems we have a backlog of WASM-related PRs to work through. |
WASI doesn't have "suspending-time" concept yet, so use
CLOCK_MONOTONIC
for both "continuous" and "suspending" clocks. WASI's "monotonic"
doesn't guarantee any underlying system call implementation, but most
of major implementations use
CLOCK_MONOTONIC
for all underlyingplatforms.
This partially buildfixes this platform.
See also: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#variant-cases