Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Add pseudo-streams. #29

Merged
merged 22 commits into from
Dec 23, 2022
Merged

Add pseudo-streams. #29

merged 22 commits into from
Dec 23, 2022

Commits on Dec 23, 2022

  1. Add pseudo-streams.

    This add a pseudo-stream type to the wasi-poll interface, and adds ways
    to obtain streams from command invocation and from files. In the future,
    it can support sockets too. With this, `command` takes streams for
    stdin/stdout, rather than filesystem descriptors.
    
    Streams support reading and writing, as well as skipping,
    repeated-element writing, and splicing from one stream to another. And
    there are `subscribe-*` functions to produce pseudo-futures from
    pseudo-streams, allowing them to be polled.
    
    This makes the polyfill somewhat more complex, but this is largely due
    to the polyfill being tied to the preview1 API.
    
    This replaces the `seek` and `tell` functions, and implemented `fd_seek`
    and `fd_tell` in terms of the polyfill's own position.
    
    Also, add a dedicated stderr API for writing to stderr in a way that
    tolerates strings that aren't necessarily expected to be newlines. And
    add a way to test whether stderr is a terminal.
    sunfishcode committed Dec 23, 2022
    Configuration menu
    Copy the full SHA
    cc6ef6b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5ff595e View commit details
    Browse the repository at this point in the history
  3. Implement file streaming.

    sunfishcode committed Dec 23, 2022
    Configuration menu
    Copy the full SHA
    f29f2b7 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    06cb75a View commit details
    Browse the repository at this point in the history
  5. Implement drop_stream.

    sunfishcode committed Dec 23, 2022
    Configuration menu
    Copy the full SHA
    79ea367 View commit details
    Browse the repository at this point in the history
  6. Minor simplification.

    sunfishcode committed Dec 23, 2022
    Configuration menu
    Copy the full SHA
    b85cc6f View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    abbe490 View commit details
    Browse the repository at this point in the history
  8. Implement the host side of poll_oneoff.

    This implements pseudo-futures and subscription functions, and adds
    polling for streams.
    sunfishcode committed Dec 23, 2022
    Configuration menu
    Copy the full SHA
    0b2355b View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    b4460e5 View commit details
    Browse the repository at this point in the history
  10. Implement clock subscriptions.

    wasi.wit:
    
     - Remove the "timers" API from wasi-clocks, as it's now redundant with
       pseudo-future clock subscriptions.
    
     - Remove `subscribe-wall-clock`. Wall-clock timeouts were implemented by
       converting them to monotonic-clock timeouts anyway, so just make that
       explicit in the WASI API, and teach the polyfill how to convert
       wall-clock timeouts into monotonic-clock timeouts.
    
     - Move `subscribe-monotonic-clock` out of wasi-clocks and into wasi-poll,
       as it's closely tied to the pseudo-futures mechanism and the `poll-oneoff`
       implementation.
    
     - While here, fix `stream-read` and related functions to return an
       end-of-stream/file indicator.
    
    Code changes:
    
     - `default_wall_clock()` and `default_monotonic_clock()` now always
       create a new table entry, rather than holding a table index in the
       `WasiCtx` which could potentially dangle.
    
     - Add support for monotonic-clock poll subscriptions.
    
     - Say "wall clock" instead of "system clock" when we have a choice.
    sunfishcode committed Dec 23, 2022
    Configuration menu
    Copy the full SHA
    226d362 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    1f1d523 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    ffcc3ab View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    9d4c691 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    e7099d4 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    b1d6bfb View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    6bd0dda View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    65daab2 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    484077b View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    195847a View commit details
    Browse the repository at this point in the history
  20. Add documentation for the default-clock functions.

    This ports the wording from WebAssembly/wasi-clocks#22.
    sunfishcode committed Dec 23, 2022
    Configuration menu
    Copy the full SHA
    ddd9632 View commit details
    Browse the repository at this point in the history
  21. Use ...

    sunfishcode committed Dec 23, 2022
    Configuration menu
    Copy the full SHA
    a12af00 View commit details
    Browse the repository at this point in the history
  22. Clean up debugging code.

    sunfishcode committed Dec 23, 2022
    Configuration menu
    Copy the full SHA
    7dcf631 View commit details
    Browse the repository at this point in the history