diff --git a/std/assembly/bindings/wasi_unstable.ts b/std/assembly/bindings/wasi_unstable.ts index c2e5ca01..6e6524b7 100644 --- a/std/assembly/bindings/wasi_unstable.ts +++ b/std/assembly/bindings/wasi_unstable.ts @@ -164,7 +164,7 @@ export declare function fd_prestat_get( /** Input: The file descriptor about which to retrieve information. */ fd: fd, /** Input: The buffer where the description is stored. */ - buf: usize // TODO: struct + buf: struct ): errno; /** Return a description of the given preopened file descriptor. */ @@ -1085,6 +1085,23 @@ export namespace oflags { } export type oflags = u16; +// TODO: undocumented +export namespace preopentype { + @inline + export const DIR: preopentype = 0; +} +export type preopentype = u8; + +// TODO: undocumented +export abstract class prestat { + type: preopentype; +} + +// TODO: undocumented +export class dirprestat extends prestat { + name_len: usize; +} + /** Flags provided to `sock_recv`. */ export namespace riflags { /** Returns the message without removing it from the socket's receive queue. */ diff --git a/tests/compiler/wasi.ts b/tests/compiler/wasi.ts index 618f1e2d..05e35485 100644 --- a/tests/compiler/wasi.ts +++ b/tests/compiler/wasi.ts @@ -1,4 +1,4 @@ -import { dirent, rwevent, fdstat, filestat, iovec, clocksubscription, fdsubscription, signal } from "bindings/wasi"; +import { dirent, rwevent, fdstat, filestat, iovec, clocksubscription, fdsubscription, signal, dirprestat } from "bindings/wasi"; // TODO: WASM64 @@ -49,6 +49,10 @@ assert(offsetof("type") == 8); assert(offsetof("fd") == 16); assert(offsetof() == 20); +assert(offsetof("type") == 0); +assert(offsetof("name_len") == 4); +assert(offsetof() == 8); + // check assignability of mimicked typed enums var sig: signal = signal.HUP; sig = signal.KILL; diff --git a/tests/compiler/wasi.untouched.wat b/tests/compiler/wasi.untouched.wat index 9bb03b94..c8b4ea00 100644 --- a/tests/compiler/wasi.untouched.wat +++ b/tests/compiler/wasi.untouched.wat @@ -492,6 +492,42 @@ call $~lib/env/abort unreachable end + i32.const 0 + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 52 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 4 + i32.const 4 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 53 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 8 + i32.const 8 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 54 + i32.const 0 + call $~lib/env/abort + unreachable + end i32.const 9 global.set $wasi/sig )