Upgrade WASI version to wasi_snapshot_preview1 (#1691)

wasm: Upgrade WASI version to wasi_snapshot_preview1

Addresses #1647.
This commit is contained in:
Federico G. Schwindt
2021-03-15 11:41:37 +00:00
committed by GitHub
parent 7d1ce24be5
commit 303acf5ed6
3 changed files with 13 additions and 15 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ type __wasi_iovec_t struct {
bufLen uint
}
//go:wasm-module wasi_unstable
//go:wasm-module wasi_snapshot_preview1
//export fd_write
func fd_write(id uint32, iovs *__wasi_iovec_t, iovs_len uint, nwritten *uint) (errno uint)
+10 -12
View File
@@ -35,7 +35,6 @@ var (
u: __wasi_subscription_u_t{
tag: __wasi_eventtype_t_clock,
u: __wasi_subscription_clock_t{
userData: 0,
id: 0,
timeout: 0,
precision: timePrecisionNanoseconds,
@@ -48,23 +47,23 @@ var (
)
func sleepTicks(d timeUnit) {
sleepTicksSubscription.u.u.timeout = int64(d)
sleepTicksSubscription.u.u.timeout = uint64(d)
poll_oneoff(&sleepTicksSubscription, &sleepTicksResult, 1, &sleepTicksNEvents)
}
func ticks() timeUnit {
var nano int64
var nano uint64
clock_time_get(0, timePrecisionNanoseconds, &nano)
return timeUnit(nano)
}
// Implementations of wasi_unstable APIs
//go:wasm-module wasi_unstable
//go:wasm-module wasi_snapshot_preview1
//export clock_time_get
func clock_time_get(clockid uint32, precision uint64, time *int64) (errno uint16)
func clock_time_get(clockid uint32, precision uint64, time *uint64) (errno uint16)
//go:wasm-module wasi_unstable
//go:wasm-module wasi_snapshot_preview1
//export poll_oneoff
func poll_oneoff(in *__wasi_subscription_t, out *__wasi_event_t, nsubscriptions uint32, nevents *uint32) (errno uint16)
@@ -77,7 +76,7 @@ const (
)
type (
// https://github.com/wasmerio/wasmer/blob/1.0.0-alpha3/lib/wasi/src/syscalls/types.rs#L584-L588
// https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#-subscription-record
__wasi_subscription_t struct {
userData uint64
u __wasi_subscription_u_t
@@ -90,18 +89,17 @@ type (
u __wasi_subscription_clock_t
}
// https://github.com/wasmerio/wasmer/blob/1.0.0-alpha3/lib/wasi/src/syscalls/types.rs#L711-L718
// https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#-subscription_clock-record
__wasi_subscription_clock_t struct {
userData uint64
id uint32
timeout int64
precision int64
timeout uint64
precision uint64
flags uint16
}
)
type (
// https://github.com/wasmerio/wasmer/blob/1.0.0-alpha3/lib/wasi/src/syscalls/types.rs#L191-L198
// https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#-event-record
__wasi_event_t struct {
userData uint64
errno uint16
+2 -2
View File
@@ -247,8 +247,8 @@
const timeOrigin = Date.now() - performance.now();
this.importObject = {
wasi_unstable: {
// https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-api.md#__wasi_fd_write
wasi_snapshot_preview1: {
// https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#fd_write
fd_write: function(fd, iovs_ptr, iovs_len, nwritten_ptr) {
let nwritten = 0;
if (fd == 1) {