Upgrade WASI version to wasi_snapshot_preview1 (#1691)
wasm: Upgrade WASI version to wasi_snapshot_preview1 Addresses #1647.
Этот коммит содержится в:
родитель
7d1ce24be5
коммит
303acf5ed6
3 изменённых файлов: 13 добавлений и 15 удалений
|
@ -12,7 +12,7 @@ type __wasi_iovec_t struct {
|
||||||
bufLen uint
|
bufLen uint
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:wasm-module wasi_unstable
|
//go:wasm-module wasi_snapshot_preview1
|
||||||
//export fd_write
|
//export fd_write
|
||||||
func fd_write(id uint32, iovs *__wasi_iovec_t, iovs_len uint, nwritten *uint) (errno uint)
|
func fd_write(id uint32, iovs *__wasi_iovec_t, iovs_len uint, nwritten *uint) (errno uint)
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ var (
|
||||||
u: __wasi_subscription_u_t{
|
u: __wasi_subscription_u_t{
|
||||||
tag: __wasi_eventtype_t_clock,
|
tag: __wasi_eventtype_t_clock,
|
||||||
u: __wasi_subscription_clock_t{
|
u: __wasi_subscription_clock_t{
|
||||||
userData: 0,
|
|
||||||
id: 0,
|
id: 0,
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
precision: timePrecisionNanoseconds,
|
precision: timePrecisionNanoseconds,
|
||||||
|
@ -48,23 +47,23 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
func sleepTicks(d timeUnit) {
|
func sleepTicks(d timeUnit) {
|
||||||
sleepTicksSubscription.u.u.timeout = int64(d)
|
sleepTicksSubscription.u.u.timeout = uint64(d)
|
||||||
poll_oneoff(&sleepTicksSubscription, &sleepTicksResult, 1, &sleepTicksNEvents)
|
poll_oneoff(&sleepTicksSubscription, &sleepTicksResult, 1, &sleepTicksNEvents)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ticks() timeUnit {
|
func ticks() timeUnit {
|
||||||
var nano int64
|
var nano uint64
|
||||||
clock_time_get(0, timePrecisionNanoseconds, &nano)
|
clock_time_get(0, timePrecisionNanoseconds, &nano)
|
||||||
return timeUnit(nano)
|
return timeUnit(nano)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implementations of wasi_unstable APIs
|
// Implementations of wasi_unstable APIs
|
||||||
|
|
||||||
//go:wasm-module wasi_unstable
|
//go:wasm-module wasi_snapshot_preview1
|
||||||
//export clock_time_get
|
//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
|
//export poll_oneoff
|
||||||
func poll_oneoff(in *__wasi_subscription_t, out *__wasi_event_t, nsubscriptions uint32, nevents *uint32) (errno uint16)
|
func poll_oneoff(in *__wasi_subscription_t, out *__wasi_event_t, nsubscriptions uint32, nevents *uint32) (errno uint16)
|
||||||
|
|
||||||
|
@ -77,7 +76,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
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 {
|
__wasi_subscription_t struct {
|
||||||
userData uint64
|
userData uint64
|
||||||
u __wasi_subscription_u_t
|
u __wasi_subscription_u_t
|
||||||
|
@ -90,18 +89,17 @@ type (
|
||||||
u __wasi_subscription_clock_t
|
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 {
|
__wasi_subscription_clock_t struct {
|
||||||
userData uint64
|
|
||||||
id uint32
|
id uint32
|
||||||
timeout int64
|
timeout uint64
|
||||||
precision int64
|
precision uint64
|
||||||
flags uint16
|
flags uint16
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
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 {
|
__wasi_event_t struct {
|
||||||
userData uint64
|
userData uint64
|
||||||
errno uint16
|
errno uint16
|
||||||
|
|
|
@ -247,8 +247,8 @@
|
||||||
|
|
||||||
const timeOrigin = Date.now() - performance.now();
|
const timeOrigin = Date.now() - performance.now();
|
||||||
this.importObject = {
|
this.importObject = {
|
||||||
wasi_unstable: {
|
wasi_snapshot_preview1: {
|
||||||
// https://github.com/bytecodealliance/wasmtime/blob/master/docs/WASI-api.md#__wasi_fd_write
|
// https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md#fd_write
|
||||||
fd_write: function(fd, iovs_ptr, iovs_len, nwritten_ptr) {
|
fd_write: function(fd, iovs_ptr, iovs_len, nwritten_ptr) {
|
||||||
let nwritten = 0;
|
let nwritten = 0;
|
||||||
if (fd == 1) {
|
if (fd == 1) {
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче