Skip to content

Commit 984fa4f

Browse files
authored
Update to the latest WASI snapshot1 and release 0.10.3 (WebAssembly#62)
* Update to the latest WASI snapshot1 definition This pulls in `sock_accept()` and some minor documentation updates. Signed-off-by: Nathaniel McCallum <nathaniel@profian.com> * Bump to 0.10.3 Signed-off-by: Nathaniel McCallum <nathaniel@profian.com>
1 parent d3c7a34 commit 984fa4f

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "wasi"
3-
version = "0.10.2+wasi-snapshot-preview1"
3+
version = "0.10.3+wasi-snapshot-preview1"
44
authors = ["The Cranelift Project Developers"]
55
license = "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT"
66
description = "Experimental WASI API bindings for Rust"

crates/witx-bindgen/WASI

Submodule WASI updated 66 files

src/lib_generated.rs

+31-2
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ pub const RIGHTS_PATH_UNLINK_FILE: Rights = 1 << 26;
482482
pub const RIGHTS_POLL_FD_READWRITE: Rights = 1 << 27;
483483
/// The right to invoke `sock_shutdown`.
484484
pub const RIGHTS_SOCK_SHUTDOWN: Rights = 1 << 28;
485+
/// The right to invoke `sock_accept`.
486+
pub const RIGHTS_SOCK_ACCEPT: Rights = 1 << 29;
485487

486488
pub type Fd = u32;
487489
#[repr(C)]
@@ -1204,7 +1206,8 @@ pub struct Prestat {
12041206
}
12051207

12061208
/// Read command-line argument data.
1207-
/// The size of the array should match that returned by `args_sizes_get`
1209+
/// The size of the array should match that returned by `args_sizes_get`.
1210+
/// Each argument is expected to be `\0` terminated.
12081211
pub unsafe fn args_get(argv: *mut *mut u8, argv_buf: *mut u8) -> Result<(), Errno> {
12091212
let ret = wasi_snapshot_preview1::args_get(argv as i32, argv_buf as i32);
12101213
match ret {
@@ -1235,6 +1238,7 @@ pub unsafe fn args_sizes_get() -> Result<(Size, Size), Errno> {
12351238

12361239
/// Read environment variable data.
12371240
/// The sizes of the buffers should match that returned by `environ_sizes_get`.
1241+
/// Key/value pairs are expected to be joined with `=`s, and terminated with `\0`s.
12381242
pub unsafe fn environ_get(environ: *mut *mut u8, environ_buf: *mut u8) -> Result<(), Errno> {
12391243
let ret = wasi_snapshot_preview1::environ_get(environ as i32, environ_buf as i32);
12401244
match ret {
@@ -2057,6 +2061,26 @@ pub unsafe fn random_get(buf: *mut u8, buf_len: Size) -> Result<(), Errno> {
20572061
}
20582062
}
20592063

2064+
/// Accept a new incoming connection.
2065+
/// Note: This is similar to `accept` in POSIX.
2066+
///
2067+
/// ## Parameters
2068+
///
2069+
/// * `fd` - The listening socket.
2070+
/// * `flags` - The desired values of the file descriptor flags.
2071+
///
2072+
/// ## Return
2073+
///
2074+
/// New socket connection
2075+
pub unsafe fn sock_accept(fd: Fd, flags: Fdflags) -> Result<Fd, Errno> {
2076+
let mut rp0 = MaybeUninit::<Fd>::uninit();
2077+
let ret = wasi_snapshot_preview1::sock_accept(fd as i32, flags as i32, rp0.as_mut_ptr() as i32);
2078+
match ret {
2079+
0 => Ok(core::ptr::read(rp0.as_mut_ptr() as i32 as *const Fd)),
2080+
_ => Err(Errno(ret as u16)),
2081+
}
2082+
}
2083+
20602084
/// Receive a message from a socket.
20612085
/// Note: This is similar to `recv` in POSIX, though it also supports reading
20622086
/// the data into multiple buffers in the manner of `readv`.
@@ -2142,12 +2166,14 @@ pub mod wasi_snapshot_preview1 {
21422166
#[link(wasm_import_module = "wasi_snapshot_preview1")]
21432167
extern "C" {
21442168
/// Read command-line argument data.
2145-
/// The size of the array should match that returned by `args_sizes_get`
2169+
/// The size of the array should match that returned by `args_sizes_get`.
2170+
/// Each argument is expected to be `\0` terminated.
21462171
pub fn args_get(arg0: i32, arg1: i32) -> i32;
21472172
/// Return command-line argument data sizes.
21482173
pub fn args_sizes_get(arg0: i32, arg1: i32) -> i32;
21492174
/// Read environment variable data.
21502175
/// The sizes of the buffers should match that returned by `environ_sizes_get`.
2176+
/// Key/value pairs are expected to be joined with `=`s, and terminated with `\0`s.
21512177
pub fn environ_get(arg0: i32, arg1: i32) -> i32;
21522178
/// Return environment variable data sizes.
21532179
pub fn environ_sizes_get(arg0: i32, arg1: i32) -> i32;
@@ -2322,6 +2348,9 @@ pub mod wasi_snapshot_preview1 {
23222348
/// required, it's advisable to use this function to seed a pseudo-random
23232349
/// number generator, rather than to provide the random data directly.
23242350
pub fn random_get(arg0: i32, arg1: i32) -> i32;
2351+
/// Accept a new incoming connection.
2352+
/// Note: This is similar to `accept` in POSIX.
2353+
pub fn sock_accept(arg0: i32, arg1: i32, arg2: i32) -> i32;
23252354
/// Receive a message from a socket.
23262355
/// Note: This is similar to `recv` in POSIX, though it also supports reading
23272356
/// the data into multiple buffers in the manner of `readv`.

0 commit comments

Comments
 (0)