diff --git a/std/assembly/bindings/wasi_snapshot_preview1.ts b/std/assembly/bindings/wasi_snapshot_preview1.ts index 9bb6a6e6b2..2470e06c49 100644 --- a/std/assembly/bindings/wasi_snapshot_preview1.ts +++ b/std/assembly/bindings/wasi_snapshot_preview1.ts @@ -959,8 +959,7 @@ export namespace errno { } export type errno = u16; -/** An event that occurred. */ -@unmanaged export abstract class event { +@unmanaged abstract class $event { // size=16/32 /** User-provided value that got attached to `subscription#userdata`. */ userdata: userdata; /** If non-zero, an error that occurred while processing the subscription request. */ @@ -971,8 +970,14 @@ export type errno = u16; private __padding0: u16; } +/** An event that occurred. */ +@unmanaged export abstract class event extends $event { + private __padding1: u64; + private __padding2: u64; +} + /** An event that occurred when type is `eventtype.FD_READ` or `eventtype.FD_WRITE`. */ -@unmanaged export class event_fd_readwrite extends event { +@unmanaged export class event_fd_readwrite extends $event { /* The number of bytes available for reading or writing. */ nbytes: filesize; /* The state of the file descriptor. */ @@ -1187,14 +1192,18 @@ export namespace preopentype { } export type preopentype = u8; -/* Information about a pre-opened capability. */ -export abstract class prestat { +@unmanaged abstract class $prestat { // WASM32: size=1/8, WASM64: size=1/16 /* The type of the pre-opened capability. */ type: preopentype; } +/* Information about a pre-opened capability. */ +@unmanaged export abstract class prestat extends $prestat { + private __padding0: usize; +} + /** The contents of a $prestat when type is `preopentype.DIR`. */ -export class prestat_dir extends prestat { +@unmanaged export class prestat_dir extends $prestat { /** The length of the directory name for use with `fd_prestat_dir_name`. */ name_len: usize; } @@ -1491,8 +1500,7 @@ export namespace subclockflags { } export type subclockflags = u16; -/** Subscription to an event. */ -@unmanaged export abstract class subscription { +@unmanaged abstract class $subscription { // size=16/48 /** User-provided value that is attached to the subscription. */ userdata: userdata; /** The type of the event to which to subscribe. */ @@ -1501,8 +1509,16 @@ export type subclockflags = u16; private __padding0: u32; } +/** Subscription to an event. */ +@unmanaged export abstract class subscription extends $subscription { + private __padding1: u64; + private __padding2: u64; + private __padding3: u64; + private __padding4: u64; +} + /* Subscription to an event of type `eventtype.CLOCK`.**/ -@unmanaged export class subscription_clock extends subscription { +@unmanaged export class subscription_clock extends $subscription { /** The clock against which to compare the timestamp. */ clock_id: clockid; /** The absolute or relative timestamp. */ @@ -1516,9 +1532,13 @@ export type subclockflags = u16; } /* Subscription to an event of type `eventtype.FD_READ` or `eventtype.FD_WRITE`.**/ -@unmanaged export class subscription_fd_readwrite extends subscription { +@unmanaged export class subscription_fd_readwrite extends $subscription { /** The file descriptor on which to wait for it to become ready for reading or writing. */ file_descriptor: fd; + + private __padding1: u64; + private __padding2: u64; + private __padding3: u64; } /** Timestamp in nanoseconds. */ diff --git a/tests/compiler/wasi/snapshot_preview1.ts b/tests/compiler/wasi/snapshot_preview1.ts index 271f784475..1ee34b7877 100644 --- a/tests/compiler/wasi/snapshot_preview1.ts +++ b/tests/compiler/wasi/snapshot_preview1.ts @@ -1,12 +1,15 @@ import { dirent, + event, event_fd_readwrite, fdstat, filestat, iovec, + subscription, subscription_clock, subscription_fd_readwrite, signal, + prestat, prestat_dir } from "bindings/wasi"; @@ -25,6 +28,8 @@ assert(offsetof("nbytes") == 16); assert(offsetof("flags") == 24); assert(offsetof() == 32); +assert(offsetof() == 32); + assert(offsetof("filetype") == 0); assert(offsetof("flags") == 2); assert(offsetof("rights_base") == 8); @@ -63,15 +68,19 @@ assert(offsetof() == 48); assert(offsetof("userdata") == 0); assert(offsetof("type") == 8); assert(offsetof("file_descriptor") == 16); -assert(offsetof() == 20); +assert(offsetof() == 48); + +assert(offsetof() == 48); assert(offsetof("type") == 0); if (ASC_TARGET == Target.WASM32) { assert(offsetof("name_len") == 4); assert(offsetof() == 8); + assert(offsetof() == 8); } else if (ASC_TARGET == Target.WASM64) { assert(offsetof("name_len") == 8); assert(offsetof() == 16); + assert(offsetof() == 16); } else { assert(false); } diff --git a/tests/compiler/wasi/snapshot_preview1.untouched.wat b/tests/compiler/wasi/snapshot_preview1.untouched.wat index 0f7cccfc5b..ab8cf77c14 100644 --- a/tests/compiler/wasi/snapshot_preview1.untouched.wat +++ b/tests/compiler/wasi/snapshot_preview1.untouched.wat @@ -54,6 +54,10 @@ i32.const 32 i32.eq drop + i32.const 32 + i32.const 32 + i32.eq + drop i32.const 0 i32.const 0 i32.eq @@ -166,8 +170,12 @@ i32.const 16 i32.eq drop - i32.const 20 - i32.const 20 + i32.const 48 + i32.const 48 + i32.eq + drop + i32.const 48 + i32.const 48 i32.eq drop i32.const 0 @@ -186,6 +194,10 @@ i32.const 8 i32.eq drop + i32.const 8 + i32.const 8 + i32.eq + drop i32.const 9 global.set $wasi/snapshot_preview1/sig )