;; WASI Poll API.
;;
;; Some content here is derived from [CloudABI](https://github.com/NuxiNL/cloudabi).
;;
;; This is a `witx` file. See [here](https://github.com/WebAssembly/WASI/tree/master/docs/witx.md)
;; for an explanation of what that means.

(use "typenames.witx")

(module $wasi_ephemeral_poll
  ;;; Linear memory to be accessed by WASI functions that need it.
  (import "memory" (memory))

  ;;; Concurrently poll for the occurrence of a set of events.
  ;;;
  ;;; If `nsubscriptions` is 0, returns `errno::inval`.
  (@interface func (export "oneoff")
    ;;; The events to which to subscribe.
    (param $in (@witx const_pointer $subscription))
    ;;; The events that have occurred.
    (param $out (@witx pointer $event))
    ;;; Both the number of subscriptions and events.
    (param $nsubscriptions $size)
    ;;; The number of events stored.
    (result $error (expected $size (error $errno)))
  )
)