Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit e6a5b5e

Browse files
authored
Merge pull request #70 from badeend/sync-wasmtime-changes
Sync changes from wasmtime repo
2 parents e8e1b4c + df2e6d3 commit e6a5b5e

17 files changed

+1070
-661
lines changed

imports.md

Lines changed: 518 additions & 315 deletions
Large diffs are not rendered by default.

wit/deps.lock

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
[clocks]
2+
url = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz"
3+
sha256 = "89da8eca4cd195516574c89c5b3c24a7b5af3ff2565c16753d20d3bdbc5fc60f"
4+
sha512 = "244079b3f592d58478a97adbd0bee8d49ae9dd1a3e435651ee40997b50da9fe62cfaba7e3ec7f7406d7d0288d278a43a3a0bc5150226ba40ce0f8ac6d33f7ddb"
5+
16
[io]
27
url = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz"
3-
sha256 = "fb76f4449eea54d06b56fc6a7ca988da51bd84a54d2021cf18da67b5e2c7ebcf"
4-
sha512 = "c005e2a91522958a9537827a49ae344e1cb39d66e85492901a86bcc7e322ba8d0a7f1a02c9b9f840c123b4ad97e297355fac98d4822536d1426d1096dd1d73ac"
8+
sha256 = "f2e6127b235c37c06be675a904d6acf08db953ea688d78c42892c6ad3bd194e4"
9+
sha512 = "32feefbc115c34bf6968cb6e9dc15e755698ee90648e5a5d84448917c36a318bd61b401195eb64330e2475e1d098bfb8dee1440d594a68e0797748762bd84ae5"

wit/deps.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
clocks = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz"
12
io = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package wasi:clocks@0.2.0-rc-2023-11-10;
2+
/// WASI Monotonic Clock is a clock API intended to let users measure elapsed
3+
/// time.
4+
///
5+
/// It is intended to be portable at least between Unix-family platforms and
6+
/// Windows.
7+
///
8+
/// A monotonic clock is a clock which has an unspecified initial value, and
9+
/// successive reads of the clock will produce non-decreasing values.
10+
///
11+
/// It is intended for measuring elapsed time.
12+
interface monotonic-clock {
13+
use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable};
14+
15+
/// An instant in time, in nanoseconds. An instant is relative to an
16+
/// unspecified initial value, and can only be compared to instances from
17+
/// the same monotonic-clock.
18+
type instant = u64;
19+
20+
/// A duration of time, in nanoseconds.
21+
type duration = u64;
22+
23+
/// Read the current value of the clock.
24+
///
25+
/// The clock is monotonic, therefore calling this function repeatedly will
26+
/// produce a sequence of non-decreasing values.
27+
now: func() -> instant;
28+
29+
/// Query the resolution of the clock. Returns the duration of time
30+
/// corresponding to a clock tick.
31+
resolution: func() -> duration;
32+
33+
/// Create a `pollable` which will resolve once the specified instant
34+
/// occured.
35+
subscribe-instant: func(
36+
when: instant,
37+
) -> pollable;
38+
39+
/// Create a `pollable` which will resolve once the given duration has
40+
/// elapsed, starting at the time at which this function was called.
41+
/// occured.
42+
subscribe-duration: func(
43+
when: duration,
44+
) -> pollable;
45+
}

wit/deps/clocks/wall-clock.wit

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package wasi:clocks@0.2.0-rc-2023-11-10;
2+
/// WASI Wall Clock is a clock API intended to let users query the current
3+
/// time. The name "wall" makes an analogy to a "clock on the wall", which
4+
/// is not necessarily monotonic as it may be reset.
5+
///
6+
/// It is intended to be portable at least between Unix-family platforms and
7+
/// Windows.
8+
///
9+
/// A wall clock is a clock which measures the date and time according to
10+
/// some external reference.
11+
///
12+
/// External references may be reset, so this clock is not necessarily
13+
/// monotonic, making it unsuitable for measuring elapsed time.
14+
///
15+
/// It is intended for reporting the current date and time for humans.
16+
interface wall-clock {
17+
/// A time and date in seconds plus nanoseconds.
18+
record datetime {
19+
seconds: u64,
20+
nanoseconds: u32,
21+
}
22+
23+
/// Read the current value of the clock.
24+
///
25+
/// This clock is not monotonic, therefore calling this function repeatedly
26+
/// will not necessarily produce a sequence of non-decreasing values.
27+
///
28+
/// The returned timestamps represent the number of seconds since
29+
/// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch],
30+
/// also known as [Unix Time].
31+
///
32+
/// The nanoseconds field of the output is always less than 1000000000.
33+
///
34+
/// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
35+
/// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
36+
now: func() -> datetime;
37+
38+
/// Query the resolution of the clock.
39+
///
40+
/// The nanoseconds field of the output is always less than 1000000000.
41+
resolution: func() -> datetime;
42+
}

wit/deps/clocks/world.wit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package wasi:clocks@0.2.0-rc-2023-11-10;
2+
3+
world imports {
4+
import monotonic-clock;
5+
import wall-clock;
6+
}

wit/deps/io/error.wit

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package wasi:io@0.2.0-rc-2023-11-10;
2+
3+
4+
interface error {
5+
/// A resource which represents some error information.
6+
///
7+
/// The only method provided by this resource is `to-debug-string`,
8+
/// which provides some human-readable information about the error.
9+
///
10+
/// In the `wasi:io` package, this resource is returned through the
11+
/// `wasi:io/streams/stream-error` type.
12+
///
13+
/// To provide more specific error information, other interfaces may
14+
/// provide functions to further "downcast" this error into more specific
15+
/// error information. For example, `error`s returned in streams derived
16+
/// from filesystem types to be described using the filesystem's own
17+
/// error-code type, using the function
18+
/// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter
19+
/// `borrow<error>` and returns
20+
/// `option<wasi:filesystem/types/error-code>`.
21+
///
22+
/// The set of functions which can "downcast" an `error` into a more
23+
/// concrete type is open.
24+
resource error {
25+
/// Returns a string that is suitable to assist humans in debugging
26+
/// this error.
27+
///
28+
/// WARNING: The returned string should not be consumed mechanically!
29+
/// It may change across platforms, hosts, or other implementation
30+
/// details. Parsing this string is a major platform-compatibility
31+
/// hazard.
32+
to-debug-string: func() -> string;
33+
}
34+
}

wit/deps/io/poll.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi:io;
1+
package wasi:io@0.2.0-rc-2023-11-10;
22

33
/// A poll API intended to let users wait for I/O events on multiple handles
44
/// at once.

wit/deps/io/streams.wit

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
package wasi:io;
1+
package wasi:io@0.2.0-rc-2023-11-10;
22

33
/// WASI I/O is an I/O abstraction API which is currently focused on providing
44
/// stream types.
55
///
66
/// In the future, the component model is expected to add built-in stream types;
77
/// when it does, they are expected to subsume this API.
88
interface streams {
9+
use error.{error};
910
use poll.{pollable};
1011

1112
/// An error for input-stream and output-stream operations.
@@ -20,26 +21,6 @@ interface streams {
2021
closed
2122
}
2223

23-
/// Contextual error information about the last failure that happened on
24-
/// a read, write, or flush from an `input-stream` or `output-stream`.
25-
///
26-
/// This type is returned through the `stream-error` type whenever an
27-
/// operation on a stream directly fails or an error is discovered
28-
/// after-the-fact, for example when a write's failure shows up through a
29-
/// later `flush` or `check-write`.
30-
///
31-
/// Interfaces such as `wasi:filesystem/types` provide functionality to
32-
/// further "downcast" this error into interface-specific error information.
33-
resource error {
34-
/// Returns a string that's suitable to assist humans in debugging this
35-
/// error.
36-
///
37-
/// The returned string will change across platforms and hosts which
38-
/// means that parsing it, for example, would be a
39-
/// platform-compatibility hazard.
40-
to-debug-string: func() -> string;
41-
}
42-
4324
/// An input bytestream.
4425
///
4526
/// `input-stream`s are *non-blocking* to the extent practical on underlying

wit/deps/io/world.wit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasi:io;
1+
package wasi:io@0.2.0-rc-2023-11-10;
22

33
world imports {
44
import streams;

0 commit comments

Comments
 (0)