256 Commits

Author SHA1 Message Date
Christian Stewart 5500f5c252 poll_oneoff: generalize blocking fd polling for non-stdin fds (#2481)
poll_oneoff only polled stdin for blocking fd read subscriptions,
silently dropping non-stdin pollable fds. Generalize the deferred
polling to poll each blocking fd individually, tracking remaining time
budget across iterations so total wall time never exceeds the requested
timeout.

Changes:
- Generalize poll_oneoff blocking fd handling: track each deferred
subscription's file and poll it individually instead of only stdin
- Track elapsed time per poll so N blocking fds complete within 1x
timeout
- Add test for poll_oneoff with non-stdin pollable fd

Fixes: #1500

Signed-off-by: Christian Stewart <christian@aperture.us>
2026-05-29 10:46:15 +01:00
Edoardo Vacchi a3374cf27a refactor: wasm.ValueType as type definition + widening (uint64) (#2495) 2026-05-11 12:01:15 -07:00
涵曦 2bbd517b76 Fix fd_prestat_get integer overflow on 32-bit platforms (#2491)
On 32-bit platforms (e.g., ARM/v7), len(name) returns a 32-bit int. The
expression `uint64(len(name) << 32)` causes the shift to overflow to 0
before the uint64 cast, making fd_prestat_get report dir_name_len=0 for
preopened directories. This breaks all WASI filesystem operations
(mkdir, open, stat, etc.) with EBADF.

Fix: cast to uint64 before shifting — `uint64(len(name)) << 32`.

More: https://github.com/mimusic-org/mimusic/issues/29

Signed-off-by: 涵曦 <im.hanxi@gmail.com>
2026-04-27 18:39:16 -07:00
Christian Stewart a877b1b410 sysfs: support Poll() on custom stdin implementations (#2476)
When using WithStdin() with a custom io.Reader, allow it to implement
Poll() for proper async I/O in poll_oneoff. Previously, only os.Stdin
(via NewStdioFile) had Poll support.

Add Pollable and PollableFile interfaces to experimental/sys so users
can implement polling on their custom readers and filesystems.
PollableFile extends File with Poll, IsNonblock, and SetNonblock without
modifying the existing File interface, avoiding breakage for downstream
File implementors.

As discussed in #2462, the current poll_oneoff implementation has
special handling for stdin but doesn't allow custom stdin
implementations to participate in polling. This prevents proper async
I/O when using custom readers (e.g., virtual terminals, networked I/O).

With these changes, users can now:

- Pass a custom io.Reader to WithStdin() implementing
experimental/sys.Pollable
- The poll_oneoff WASI function will call this implementation
- Implement experimental/sys.PollableFile for full file poll support

Changes:

- Add Pollable interface and Pflag type to experimental/sys
- Add PollableFile interface to experimental/sys (File + Pollable +
nonblock methods)
- Make internal/fsapi.File a type alias for
experimental/sys.PollableFile
- Add Pollable check in StdinFile.Poll() and fsFile.Poll()
- Check Pollable before POLLIN flag so impl. can handle non-POLLIN flags
- Re-export Pflag types from internal/fsapi via type aliases to
experimental/sys canonical definitions
- Add unit tests for Poll using in-memory files

Fixes #1500

---------

Signed-off-by: Christian Stewart <christian@aperture.us>
2026-03-04 10:40:00 +00:00
Nuno Cruces 77db9681cc Change version policy to two versions. (#2448)
As discussed in #2434. This is just raising the minimum Go version, not
adding dependencies.

I fixed some deprecations that caused actual CI breakages, and adjusted
comments mentioning specific Go versions (also checked nothing important
changed).

Since I was touching the yaml file, I updated OS versions we test
against (for the BSD, etc).

Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2025-11-18 12:59:45 +00:00
Anuraag (Rag) Agrawal 96f2052f6d ci: update Go floor to 1.22 and run CI with 1.22/1.24 (#2379)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2025-02-18 07:24:27 -08:00
Anuraag (Rag) Agrawal 8358482d4a Update to latest TinyGo and Rust (#2368)
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
2025-01-21 07:42:05 -08:00
Nuno Cruces 5ed4c174cc ci: upgrade to Go 1.23 (#2301) 2024-08-14 06:41:47 -07:00
jerbob92 c345ddf2b5 Add support for Emscripten version 3.1.57 (#2290)
This update the imports/emscripten package implementation
so that it can support v3.1.57+ which came with a breaking
change: https://github.com/emscripten-core/emscripten/pull/21555

Signed-off-by: Jeroen Bobbeldijk <jeroen@klippa.com>
2024-07-19 08:17:29 -07:00
Takeshi Yoneda e73ede5f55 Uses unsafe.String where possible (#2282)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-07-09 08:00:31 -07:00
Yage Hu 8b3af37da0 wasi: path_open should accept a dir with RIGHT_FD_WRITE (#2244)
Signed-off-by: Yage Hu <me@huyage.dev>
2024-06-11 18:02:47 +02:00
Yage Hu 0c5d97141e Fix path_symlink only works when dir mounted to / (#2229) 2024-06-05 19:51:59 -07:00
Yage Hu 4201f5442a Disallow empty path on path_open (#2223)
Signed-off-by: Yage Hu <me@huyage.dev>
2024-05-29 10:22:12 +02:00
Takeshi Yoneda 7ad2b70626 Removes GOOS=js related leftovers (#2193)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-04-22 11:17:10 +09:00
Nuno Cruces a0fbb18544 experimental: configure custom memory allocator (#2177)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2024-04-10 20:13:57 +09:00
Nuno Cruces c6a907bb9d experimental: cleanup context keys (#2175)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2024-04-06 21:04:55 +09:00
Takeshi Yoneda a05f23b0ff wasi: uses the shared compilation cache in tests (#2149)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-03-12 12:46:09 +09:00
Takeshi Yoneda 9f56676383 testing: removes remaining gotip usage (#2147)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-03-12 11:50:45 +09:00
Edoardo Vacchi f2c9a986b6 chore: ensure all tinygo binaries have been built with 0.31.1 (#2140)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2024-03-08 14:57:01 +09:00
Takeshi Yoneda 3c7bc733c5 Nuke old singlepass compiler, enable optimizing compiler by default (#2130)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-03-07 15:26:45 +09:00
Takeshi Yoneda 81d1f20428 wazevo: implements MutableGlobal.Set, fixes emscripten test (#2129)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-03-07 12:33:59 +09:00
Takeshi Yoneda 712f9370a4 api: reverts the uint32->uint64 breaking change for 2.0 release (#2106)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-03-02 13:05:10 +09:00
Nuno Cruces 8a61b01faf Changes Read to receive uint64 byte count. (#2085)
Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2024-02-29 08:58:53 +09:00
Takeshi Yoneda 1458ccc8b0 Changes the type of Size() to uint64 (#2074)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
2024-02-20 07:47:57 +09:00
Edoardo Vacchi c1c071ecc4 wasi: fix flaky tests (#2068)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2024-02-20 07:01:22 +09:00
Takeshi Yoneda abf0ada941 Set floor Go version at 1.20 (#2025)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2024-02-09 13:29:57 -08:00
Yage Hu 656d872980 wasi: use proper param type for size in fd_filestat_set_size to handle EFBIG (#1871)
Signed-off-by: Yage Hu <me@huyage.dev>
2023-12-14 09:36:08 -08:00
Yage Hu f46d5b943d wasi: resets offsets in reopen (#1866)
Signed-off-by: Yage Hu <me@huyage.dev>
2023-12-12 15:29:20 -08:00
Yage Hu 99ededcefd Fix fd_fdstat_set_flags truncating with O_TRUNC (#1863) 2023-12-12 06:49:56 -08:00
Danlock eba1b5a4e1 Deprecates emscripten.Instantiate in favor of InstantiateForModule (#1782)
Signed-off-by: Daniel Lockhart <dflocked@gmail.com>
2023-10-16 07:29:31 +09:00
Edoardo Vacchi a5b30a508c wasi: fix symlink-related issues with path handling (#1648)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-08-24 07:25:55 +09:00
Philipp Gillé 84708fe4e6 Fix broken link in example README (#1629)
Signed-off-by: Philipp Gillé <philippgille@users.noreply.github.com>
2023-08-14 23:09:28 +01:00
jerbob92 a2b6510ede Implement Emscripten jmp support in indirect function calls (invoke_xxx) (#1611)
Signed-off-by: Jeroen Bobbeldijk <jeroen@klippa.com>
2023-08-10 08:03:35 +09:00
Edoardo Vacchi 76dce033d3 Upgrade floor Go version to 1.19 everywhere. (#1622) 2023-08-10 06:09:16 +09:00
Nuno Cruces fa11db75a6 Use unix build constraint.
Now that we floor on Go 1.19, take advantage of the unix build constraint:
https://tip.golang.org/doc/go1.19#go-unix

Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
2023-08-09 11:46:04 +01:00
Crypt Keeper 009ee7056c Re-introduces internal fsapi.File with non-blocking methods (#1613)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-08-07 15:50:38 +08:00
Edoardo Vacchi edb7bc2b10 wasi: add more test cases to poll_oneoff, cleanup impl (#1612)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-08-05 15:22:15 +02:00
Crypt Keeper 2f2b6a9d2c sysfs: Makes ReadFS and AdaptFS embeddable (#1607)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-08-02 08:27:50 +08:00
Crypt Keeper 1f8c908f1c Exposes writeable filesystem as experimentalsys.FS (#1605)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-31 07:56:28 +08:00
Crypt Keeper 66070781b1 Supports compilation with GOOS=plan9 (#1603)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-31 06:47:23 +08:00
Crypt Keeper 2382bbf730 sysfs: decouples FS and File from the syscall package (#1602)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-30 16:06:22 +08:00
Crypt Keeper 8d3874d3c8 fsapi: migrates PollRead to Poll with Pflag (#1599)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Co-authored-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-07-30 10:56:17 +08:00
Crypt Keeper 180ff682d9 sysfs: changes PollRead to accept int32 timeoutMillis (#1597)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-07-28 10:01:00 +08:00
Crypt Keeper 789a5333c7 docs: adds issue links on TinyGo TODO (#1590)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-23 14:45:44 +09:00
Crypt Keeper fb6147ca94 Emulates AT_SYMLINK_NOFOLLOW instead of sometimes implementing it (#1588)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-22 08:03:47 +08:00
Crypt Keeper b842d6cbfd fsapi: adds Oflag to decouple from syscall package (#1586)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-19 16:01:44 +08:00
Edoardo Vacchi 1e0c73d569 wasi: nonblocking I/O for sockets and pipes on Windows (#1579)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-07-19 07:30:06 +08:00
Edoardo Vacchi 1cdb72d431 fs: nonblocking writes should use syscall.Write (#1581)
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
2023-07-17 10:19:27 +02:00
Crypt Keeper 2f8dd23097 adds experimental sys.Errno to begin decoupling from the syscall package (#1582)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-17 08:13:29 +08:00
Crypt Keeper 15fa5c4de5 Changes build to test go 1.21rc2 (#1571)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-10 13:39:37 +08:00