Skip to content

Commit

Permalink
add stub for sock_accept (#185)
Browse files Browse the repository at this point in the history
* 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 <mdawson@devrus.com>
  • Loading branch information
mhdawson authored Feb 22, 2023
1 parent 370cb05 commit 96f37fe
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/uvwasi.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ uvwasi_errno_t uvwasi_random_get(uvwasi_t* uvwasi,
void* buf,
uvwasi_size_t buf_len);
uvwasi_errno_t uvwasi_sched_yield(uvwasi_t* uvwasi);
uvwasi_errno_t uvwasi_sock_accept(uvwasi_t* uvwasi,
uvwasi_fd_t sock,
uvwasi_fdflags_t flags,
uvwasi_fd_t* fd);
uvwasi_errno_t uvwasi_sock_recv(uvwasi_t* uvwasi,
uvwasi_fd_t sock,
const uvwasi_iovec_t* ri_data,
Expand Down
1 change: 1 addition & 0 deletions include/wasi_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ typedef uint64_t uvwasi_rights_t; /* Bitfield */
#define UVWASI_RIGHT_PATH_UNLINK_FILE (1 << 26)
#define UVWASI_RIGHT_POLL_FD_READWRITE (1 << 27)
#define UVWASI_RIGHT_SOCK_SHUTDOWN (1 << 28)
#define UVWASI_RIGHT_SOCK_ACCEPT (1 << 29)

typedef uint16_t uvwasi_roflags_t; /* Bitfield */
#define UVWASI_SOCK_RECV_DATA_TRUNCATED (1 << 0)
Expand Down
9 changes: 9 additions & 0 deletions src/uvwasi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2557,6 +2557,15 @@ uvwasi_errno_t uvwasi_sock_shutdown(uvwasi_t* uvwasi,
return UVWASI_ENOTSUP;
}

uvwasi_errno_t uvwasi_sock_accept(uvwasi_t* uvwasi,
uvwasi_fd_t sock,
uvwasi_fdflags_t flags,
uvwasi_fd_t* fd) {
/* TODO(mhdawson): Needs implementation */
UVWASI_DEBUG("uvwasi_sock_accept(uvwasi=%p, unimplemented)\n", uvwasi);
return UVWASI_ENOTSUP;
};


const char* uvwasi_embedder_err_code_to_string(uvwasi_errno_t code) {
switch (code) {
Expand Down
3 changes: 2 additions & 1 deletion src/wasi_rights.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
UVWASI_RIGHT_PATH_UNLINK_FILE | \
UVWASI_RIGHT_PATH_REMOVE_DIRECTORY | \
UVWASI_RIGHT_POLL_FD_READWRITE | \
UVWASI_RIGHT_SOCK_SHUTDOWN)
UVWASI_RIGHT_SOCK_SHUTDOWN | \
UVWASI_RIGHT_SOCK_ACCEPT)

#define UVWASI__RIGHTS_BLOCK_DEVICE_BASE UVWASI__RIGHTS_ALL
#define UVWASI__RIGHTS_BLOCK_DEVICE_INHERITING UVWASI__RIGHTS_ALL
Expand Down
1 change: 1 addition & 0 deletions test/test-enotsup-apis.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ int main(void) {
assert(UVWASI_ENOTSUP == uvwasi_sock_recv(NULL, 0, NULL, 0, 0, NULL, NULL));
assert(UVWASI_ENOTSUP == uvwasi_sock_send(NULL, 0, NULL, 0, 0, NULL));
assert(UVWASI_ENOTSUP == uvwasi_sock_shutdown(NULL, 0, 0));
assert(UVWASI_ENOTSUP == uvwasi_sock_accept(NULL, 0, 0, NULL));

return 0;
}

0 comments on commit 96f37fe

Please sign in to comment.