Skip to content

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"

wit/deps/clocks/monotonic-clock.wit

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;

wit/ip-name-lookup.wit

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,40 @@
11

22
interface ip-name-lookup {
3-
use wasi:io/poll.{pollable};
4-
use network.{network, error-code, ip-address, ip-address-family};
3+
use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable};
4+
use network.{network, error-code, ip-address};
55

66

77
/// Resolve an internet host name to a list of IP addresses.
8-
///
8+
///
9+
/// Unicode domain names are automatically converted to ASCII using IDNA encoding.
10+
/// If the input is an IP address string, the address is parsed and returned
11+
/// as-is without making any external requests.
12+
///
913
/// See the wasi-socket proposal README.md for a comparison with getaddrinfo.
10-
///
11-
/// # Parameters
12-
/// - `name`: The name to look up. IP addresses are not allowed. Unicode domain names are automatically converted
13-
/// to ASCII using IDNA encoding.
14-
/// - `address-family`: If provided, limit the results to addresses of this specific address family.
15-
/// - `include-unavailable`: When set to true, this function will also return addresses of which the runtime
16-
/// thinks (or knows) can't be connected to at the moment. For example, this will return IPv6 addresses on
17-
/// systems without an active IPv6 interface. Notes:
18-
/// - Even when no public IPv6 interfaces are present or active, names like "localhost" can still resolve to an IPv6 address.
19-
/// - Whatever is "available" or "unavailable" is volatile and can change everytime a network cable is unplugged.
20-
///
21-
/// This function never blocks. It either immediately fails or immediately returns successfully with a `resolve-address-stream`
22-
/// that can be used to (asynchronously) fetch the results.
23-
///
24-
/// At the moment, the stream never completes successfully with 0 items. Ie. the first call
25-
/// to `resolve-next-address` never returns `ok(none)`. This may change in the future.
26-
///
14+
///
15+
/// This function never blocks. It either immediately fails or immediately
16+
/// returns successfully with a `resolve-address-stream` that can be used
17+
/// to (asynchronously) fetch the results.
18+
///
2719
/// # Typical errors
28-
/// - `invalid-name`: `name` is a syntactically invalid domain name.
29-
/// - `invalid-name`: `name` is an IP address.
30-
/// - `address-family-not-supported`: The specified `address-family` is not supported. (EAI_FAMILY)
31-
///
20+
/// - `invalid-argument`: `name` is a syntactically invalid domain name or IP address.
21+
///
3222
/// # References:
3323
/// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>
3424
/// - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
3525
/// - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
3626
/// - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
37-
resolve-addresses: func(network: borrow<network>, name: string, address-family: option<ip-address-family>, include-unavailable: bool) -> result<resolve-address-stream, error-code>;
27+
resolve-addresses: func(network: borrow<network>, name: string) -> result<resolve-address-stream, error-code>;
3828

3929
resource resolve-address-stream {
4030
/// Returns the next address from the resolver.
41-
///
31+
///
4232
/// This function should be called multiple times. On each call, it will
4333
/// return the next address in connection order preference. If all
4434
/// addresses have been exhausted, this function returns `none`.
45-
///
35+
///
4636
/// This function never returns IPv4-mapped IPv6 addresses.
47-
///
37+
///
4838
/// # Typical errors
4939
/// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY)
5040
/// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN)
@@ -53,7 +43,7 @@ interface ip-name-lookup {
5343
resolve-next-address: func() -> result<option<ip-address>, error-code>;
5444

5545
/// Create a `pollable` which will resolve once the stream is ready for I/O.
56-
///
46+
///
5747
/// Note: this function is here for WASI Preview2 only.
5848
/// It's planned to be removed when `future` is natively supported in Preview3.
5949
subscribe: func() -> pollable;

0 commit comments

Comments
 (0)