Skip to content

Commit 7302f33

Browse files
rvolosatovssunfishcode
authored andcommitted
build: update WASI and partially regenerate api.h
1 parent 05cd0af commit 7302f33

File tree

6 files changed

+43
-2
lines changed

6 files changed

+43
-2
lines changed

expected/wasm32-wasi/defined-symbols.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ __wasi_poll_oneoff
300300
__wasi_proc_exit
301301
__wasi_random_get
302302
__wasi_sched_yield
303+
__wasi_sock_accept
303304
__wasi_sock_recv
304305
__wasi_sock_send
305306
__wasi_sock_shutdown

expected/wasm32-wasi/predefined-macros.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,6 +2954,7 @@
29542954
#define __WASI_RIGHTS_PATH_SYMLINK ((__wasi_rights_t)(1 << 24))
29552955
#define __WASI_RIGHTS_PATH_UNLINK_FILE ((__wasi_rights_t)(1 << 26))
29562956
#define __WASI_RIGHTS_POLL_FD_READWRITE ((__wasi_rights_t)(1 << 27))
2957+
#define __WASI_RIGHTS_SOCK_ACCEPT ((__wasi_rights_t)(1 << 29))
29572958
#define __WASI_RIGHTS_SOCK_SHUTDOWN ((__wasi_rights_t)(1 << 28))
29582959
#define __WASI_ROFLAGS_RECV_DATA_TRUNCATED ((__wasi_roflags_t)(1 << 0))
29592960
#define __WASI_SDFLAGS_RD ((__wasi_sdflags_t)(1 << 0))

expected/wasm32-wasi/undefined-symbols.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ __imported_wasi_snapshot_preview1_poll_oneoff
5252
__imported_wasi_snapshot_preview1_proc_exit
5353
__imported_wasi_snapshot_preview1_random_get
5454
__imported_wasi_snapshot_preview1_sched_yield
55+
__imported_wasi_snapshot_preview1_sock_accept
5556
__imported_wasi_snapshot_preview1_sock_recv
5657
__imported_wasi_snapshot_preview1_sock_send
5758
__imported_wasi_snapshot_preview1_sock_shutdown

libc-bottom-half/headers/public/wasi/api.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,11 @@ typedef uint64_t __wasi_rights_t;
657657
*/
658658
#define __WASI_RIGHTS_SOCK_SHUTDOWN ((__wasi_rights_t)(1 << 28))
659659

660+
/**
661+
* The right to invoke `sock_accept`.
662+
*/
663+
#define __WASI_RIGHTS_SOCK_ACCEPT ((__wasi_rights_t)(1 << 29))
664+
660665
/**
661666
* A file descriptor handle.
662667
*/
@@ -1394,7 +1399,8 @@ _Static_assert(_Alignof(__wasi_prestat_t) == 4, "witx calculated align");
13941399

13951400
/**
13961401
* Read command-line argument data.
1397-
* The size of the array should match that returned by `args_sizes_get`
1402+
* The size of the array should match that returned by `args_sizes_get`.
1403+
* Each argument is expected to be `\0` terminated.
13981404
*/
13991405
__wasi_errno_t __wasi_args_get(
14001406
uint8_t * * argv,
@@ -1413,6 +1419,7 @@ __wasi_errno_t __wasi_args_sizes_get(
14131419
/**
14141420
* Read environment variable data.
14151421
* The sizes of the buffers should match that returned by `environ_sizes_get`.
1422+
* Key/value pairs are expected to be joined with `=`s, and terminated with `\0`s.
14161423
*/
14171424
__wasi_errno_t __wasi_environ_get(
14181425
uint8_t * * environ,
@@ -2005,6 +2012,23 @@ __wasi_errno_t __wasi_random_get(
20052012
uint8_t * buf,
20062013
__wasi_size_t buf_len
20072014
) __attribute__((__warn_unused_result__));
2015+
/**
2016+
* Accept a new incoming connection.
2017+
* Note: This is similar to `accept` in POSIX.
2018+
* @return
2019+
* New socket connection
2020+
*/
2021+
__wasi_errno_t __wasi_sock_accept(
2022+
/**
2023+
* The listening socket.
2024+
*/
2025+
__wasi_fd_t fd,
2026+
/**
2027+
* The desired values of the file descriptor flags.
2028+
*/
2029+
__wasi_fdflags_t flags,
2030+
__wasi_fd_t *retptr0
2031+
) __attribute__((__warn_unused_result__));
20082032
/**
20092033
* Receive a message from a socket.
20102034
* Note: This is similar to `recv` in POSIX, though it also supports reading

libc-bottom-half/sources/__wasilibc_real.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,20 @@ __wasi_errno_t __wasi_random_get(
599599
return (uint16_t) ret;
600600
}
601601

602+
int32_t __imported_wasi_snapshot_preview1_sock_accept(int32_t arg0, int32_t arg1, int32_t arg2) __attribute__((
603+
__import_module__("wasi_snapshot_preview1"),
604+
__import_name__("sock_accept")
605+
));
606+
607+
__wasi_errno_t __wasi_sock_accept(
608+
__wasi_fd_t fd,
609+
__wasi_fdflags_t flags,
610+
__wasi_fd_t *retptr0
611+
){
612+
int32_t ret = __imported_wasi_snapshot_preview1_sock_accept((int32_t) fd, flags, (int32_t) retptr0);
613+
return (uint16_t) ret;
614+
}
615+
602616
int32_t __imported_wasi_snapshot_preview1_sock_recv(int32_t arg0, int32_t arg1, int32_t arg2, int32_t arg3, int32_t arg4, int32_t arg5) __attribute__((
603617
__import_module__("wasi_snapshot_preview1"),
604618
__import_name__("sock_recv")

tools/wasi-headers/WASI

Submodule WASI updated 77 files

0 commit comments

Comments
 (0)