Skip to content

Merge recv/send into read/write. #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions phases/ephemeral/witx/typenames.witx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
(enum u16
;;; No error occurred. System call completed successfully.
$success
;;; End of stream was reached successfully.
$success_eos
;;; Argument list too long.
$2big
;;; Permission denied.
Expand Down Expand Up @@ -201,7 +203,7 @@
;;; If `path_open` is set, includes the right to invoke
;;; `path_open` with `fdflags::dsync`.
$fd_datasync
;;; The right to invoke `fd_read` and `sock_recv`.
;;; The right to invoke `fd_read`.
;;
;;; If `rights::fd_seek` is set, includes the right to invoke `fd_pread`.
$fd_read
Expand All @@ -218,7 +220,7 @@
;;; remains unaltered (i.e., `whence::cur` with offset zero), or to
;;; invoke `fd_tell`.
$fd_tell
;;; The right to invoke `fd_write` and `sock_send`.
;;; The right to invoke `fd_write`.
;;; If `rights::fd_seek` is set, includes the right to invoke `fd_pwrite`.
$fd_write
;;; The right to invoke `fd_advise`.
Expand Down Expand Up @@ -271,8 +273,10 @@
;;; If `rights::fd_read` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_read`.
;;; If `rights::fd_write` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype::fd_write`.
$poll_fd_readwrite
;;; The right to invoke `sock_shutdown`.
$sock_shutdown
;;; The right to invoke `fd_shutdown`.
$fd_shutdown
;;; The output supports line-oriented terminal output.
$fd_line_oriented_terminal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems a little strange to call this a right.

)
)

Expand Down Expand Up @@ -408,8 +412,6 @@
;;; File descriptor attributes.
(typename $fdstat
(struct
;;; File type.
(field $fs_filetype $filetype)
;;; File descriptor flags.
(field $fs_flags $fdflags)
;;; Rights that apply to this file descriptor.
Expand Down Expand Up @@ -638,25 +640,23 @@
;;; Exit code generated by a process when exiting.
(typename $exitcode u32)

;;; Flags provided to `sock_recv`.
;;; Flags provided to `fd_read`.
(typename $riflags
(flags u16
;;; Returns the message without removing it from the socket's receive queue.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this say something like When reading from a datagram socket?

$recv_peek
;;; On byte-stream sockets, block until the full amount of data can be returned.
$recv_waitall
)
)
;;;
;;; Note: This is similar to the `MSG_PEEK` flag in `recv` in POSIX.
$read_peek

;;; Flags returned by `sock_recv`.
(typename $roflags
(flags u16
;;; Returned by `sock_recv`: Message data has been truncated.
$recv_data_truncated
;;; On bytestream sockets, block until the full amount of data can be returned,
;;; unless an error or disconnect occurs.
;;;
;;; Note: This is similar to the `MSG_WAITALL` flag in `recv` in POSIX.
$read_waitall
)
)

;;; Flags provided to `sock_send`. As there are currently no flags
;;; Flags provided to `fd_write`. As there are currently no flags
;;; defined, it must be set to zero.
(typename $siflags u16)

Expand Down
29 changes: 26 additions & 3 deletions phases/ephemeral/witx/wasi_ephemeral_fd.witx
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,25 @@
)

;;; Read from a file descriptor.
;;; Note: This is similar to `readv` in POSIX.
;;;
;;; When reading from a datagram socket, returns `$msgsize` if a datagram
;;; is larger than the provided buffer
;;;
;;; When the end of the file or stream is reached, this function returns
;;; `$success_eos`.
;;;
;;; Note: This is similar to `readv` and `recv` in POSIX, except that a return
;;; value of 0 does not necessarily indicate end of file/stream.
(@interface func (export "read")
(param $fd $fd)
;;; List of scatter/gather vectors to which to store data.
(param $iovs $iovec_array)
;;; Message flags.
(param $ri_flags $riflags)
(result $error $errno)
;;; The number of bytes read.
;;; The number of bytes read. If this is greater than the total size of the
;;; provided buffer, it indicates the length of a message on a message-based
;;; socket, and data beyond the size of the buffer is discarded.
(result $nread $size)
)

Expand Down Expand Up @@ -249,13 +261,24 @@
)

;;; Write to a file descriptor.
;;; Note: This is similar to `writev` in POSIX.
;;; Note: This is similar to `writev` and `send` in POSIX.
(@interface func (export "write")
(param $fd $fd)
;;; List of scatter/gather vectors from which to retrieve data.
(param $iovs $ciovec_array)
;;; Message flags.
(param $si_flags $siflags)
(result $error $errno)
;;; The number of bytes written.
(result $nwritten $size)
)

;;; Shut down socket send and receive channels.
;;; Note: This is similar to `shutdown` in POSIX.
(@interface func (export "shutdown")
(param $fd $fd)
;;; Which channels on the socket to shut down.
(param $how $sdflags)
(result $error $errno)
)
)
52 changes: 0 additions & 52 deletions phases/ephemeral/witx/wasi_ephemeral_sock.witx

This file was deleted.