Skip to content

Commit 08be569

Browse files
authored
wasip3: Implement UDP (WebAssembly#763)
Ungate a number of functions to get UDP send/recv working.
1 parent 65ef246 commit 08be569

5 files changed

Lines changed: 185 additions & 48 deletions

File tree

expected/wasm32-wasip3/defined-symbols.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ __wasilibc_sockaddr_to_wasi
341341
__wasilibc_sockaddr_validate
342342
__wasilibc_stat
343343
__wasilibc_stream_block_on
344+
__wasilibc_subtask_await_nonblocking
344345
__wasilibc_subtask_block_on_and_drop
345346
__wasilibc_tell
346347
__wasilibc_unlinkat

libc-bottom-half/headers/private/wasi/wasip3_block.h

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,28 @@
88
#include <wasi/descriptor_table.h> // for waitable_t
99

1010
// Waits for a subtask to return
11-
void __wasilibc_subtask_block_on_and_drop(wasip3_subtask_t status);
11+
void __wasilibc_subtask_block_on_and_drop(wasip3_subtask_t subtask);
12+
13+
// Blocks the current thread until the subtask invocation indicated by `status`
14+
// has completed.
15+
//
16+
// This will block the current thread until the `status`'s subtask, if present,
17+
// has completed. This function takes ownership of the subtask indicated by
18+
// `subtask`.
19+
static inline void __wasilibc_subtask_await(wasip3_subtask_status_t status) {
20+
if (WASIP3_SUBTASK_STATE(status) != WASIP3_SUBTASK_RETURNED)
21+
__wasilibc_subtask_block_on_and_drop(WASIP3_SUBTASK_HANDLE(status));
22+
}
23+
24+
// Attempts to see if `status` indicates a completed task. If it does not then
25+
// the task is cancelled.
26+
//
27+
// This method is unlike `__wasilibc_subtask_await` in that it will not block
28+
// the current thread.
29+
//
30+
// This function returns 0 if the subtask completed, and otherwise returns -1
31+
// and sets `errno` to `EWOULDBLOCK` if the subtask was successfully cancelled.
32+
int __wasilibc_subtask_await_nonblocking(wasip3_subtask_status_t status);
1233

1334
/// Waits for `future` to be resolved after a previous operation yielded
1435
/// `status` as a result.

0 commit comments

Comments
 (0)