Skip to content

Commit 96f37fe

Browse files
authored
add stub for sock_accept (#185)
* add sub for sock_accept Refs: #183 add the stub for sock_accept so that we have stubs for all method in the current version of snapshot 1. sock_accept was added later after snapshot 1 was first documented. Does not complete #183 but is first step. Signed-off-by: Michael Dawson <[email protected]>
1 parent 370cb05 commit 96f37fe

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

include/uvwasi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ uvwasi_errno_t uvwasi_random_get(uvwasi_t* uvwasi,
251251
void* buf,
252252
uvwasi_size_t buf_len);
253253
uvwasi_errno_t uvwasi_sched_yield(uvwasi_t* uvwasi);
254+
uvwasi_errno_t uvwasi_sock_accept(uvwasi_t* uvwasi,
255+
uvwasi_fd_t sock,
256+
uvwasi_fdflags_t flags,
257+
uvwasi_fd_t* fd);
254258
uvwasi_errno_t uvwasi_sock_recv(uvwasi_t* uvwasi,
255259
uvwasi_fd_t sock,
256260
const uvwasi_iovec_t* ri_data,

include/wasi_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ typedef uint64_t uvwasi_rights_t; /* Bitfield */
214214
#define UVWASI_RIGHT_PATH_UNLINK_FILE (1 << 26)
215215
#define UVWASI_RIGHT_POLL_FD_READWRITE (1 << 27)
216216
#define UVWASI_RIGHT_SOCK_SHUTDOWN (1 << 28)
217+
#define UVWASI_RIGHT_SOCK_ACCEPT (1 << 29)
217218

218219
typedef uint16_t uvwasi_roflags_t; /* Bitfield */
219220
#define UVWASI_SOCK_RECV_DATA_TRUNCATED (1 << 0)

src/uvwasi.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2557,6 +2557,15 @@ uvwasi_errno_t uvwasi_sock_shutdown(uvwasi_t* uvwasi,
25572557
return UVWASI_ENOTSUP;
25582558
}
25592559

2560+
uvwasi_errno_t uvwasi_sock_accept(uvwasi_t* uvwasi,
2561+
uvwasi_fd_t sock,
2562+
uvwasi_fdflags_t flags,
2563+
uvwasi_fd_t* fd) {
2564+
/* TODO(mhdawson): Needs implementation */
2565+
UVWASI_DEBUG("uvwasi_sock_accept(uvwasi=%p, unimplemented)\n", uvwasi);
2566+
return UVWASI_ENOTSUP;
2567+
};
2568+
25602569

25612570
const char* uvwasi_embedder_err_code_to_string(uvwasi_errno_t code) {
25622571
switch (code) {

src/wasi_rights.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
UVWASI_RIGHT_PATH_UNLINK_FILE | \
3232
UVWASI_RIGHT_PATH_REMOVE_DIRECTORY | \
3333
UVWASI_RIGHT_POLL_FD_READWRITE | \
34-
UVWASI_RIGHT_SOCK_SHUTDOWN)
34+
UVWASI_RIGHT_SOCK_SHUTDOWN | \
35+
UVWASI_RIGHT_SOCK_ACCEPT)
3536

3637
#define UVWASI__RIGHTS_BLOCK_DEVICE_BASE UVWASI__RIGHTS_ALL
3738
#define UVWASI__RIGHTS_BLOCK_DEVICE_INHERITING UVWASI__RIGHTS_ALL

test/test-enotsup-apis.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ int main(void) {
66
assert(UVWASI_ENOTSUP == uvwasi_sock_recv(NULL, 0, NULL, 0, 0, NULL, NULL));
77
assert(UVWASI_ENOTSUP == uvwasi_sock_send(NULL, 0, NULL, 0, 0, NULL));
88
assert(UVWASI_ENOTSUP == uvwasi_sock_shutdown(NULL, 0, 0));
9+
assert(UVWASI_ENOTSUP == uvwasi_sock_accept(NULL, 0, 0, NULL));
910

1011
return 0;
1112
}

0 commit comments

Comments
 (0)