| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7ab7f97 commit b2a80d7
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1148,6 +1148,21 @@ uint32_t WASI::SchedYield(WASI& wasi, WasmMemory) { | |||
| 1148 | 1148 | return uvwasi_sched_yield(&wasi.uvw_); | |
| 1149 | 1149 | } | |
| 1150 | 1150 | ||
| 1151 | + uint32_t WASI::SockAccept(WASI& wasi, | ||
| 1152 | + WasmMemory memory, | ||
| 1153 | + uint32_t sock, | ||
| 1154 | + uint32_t flags, | ||
| 1155 | + uint32_t fd_ptr) { | ||
| 1156 | + Debug(wasi, "sock_accept(%d, %d, %d)\n", sock, flags, fd_ptr); | ||
| 1157 | + uvwasi_fd_t fd; | ||
| 1158 | + uvwasi_errno_t err = uvwasi_sock_accept(&wasi.uvw_, sock, flags, &fd); | ||
| 1159 | + | ||
| 1160 | + if (err == UVWASI_ESUCCESS) | ||
| 1161 | + uvwasi_serdes_write_size_t(memory.data, fd_ptr, fd); | ||
| 1162 | + | ||
| 1163 | + return err; | ||
| 1164 | + } | ||
| 1165 | + | ||
| 1151 | 1166 | uint32_t WASI::SockRecv(WASI& wasi, | |
| 1152 | 1167 | WasmMemory memory, | |
| 1153 | 1168 | uint32_t sock, | |
@@ -1303,6 +1318,7 @@ static void InitializePreview1(Local<Object> target, | |||
| 1303 | 1318 | V(ProcRaise, "proc_raise") | |
| 1304 | 1319 | V(RandomGet, "random_get") | |
| 1305 | 1320 | V(SchedYield, "sched_yield") | |
| 1321 | + V(SockAccept, "sock_accept") | ||
| 1306 | 1322 | V(SockRecv, "sock_recv") | |
| 1307 | 1323 | V(SockSend, "sock_send") | |
| 1308 | 1324 | V(SockShutdown, "sock_shutdown") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -131,6 +131,7 @@ class WASI : public BaseObject, | |||
| 131 | 131 | static uint32_t ProcRaise(WASI&, WasmMemory, uint32_t); | |
| 132 | 132 | static uint32_t RandomGet(WASI&, WasmMemory, uint32_t, uint32_t); | |
| 133 | 133 | static uint32_t SchedYield(WASI&, WasmMemory); | |
| 134 | + static uint32_t SockAccept(WASI&, WasmMemory, uint32_t, uint32_t, uint32_t); | ||
| 134 | 135 | static uint32_t SockRecv(WASI&, | |
| 135 | 136 | WasmMemory, | |
| 136 | 137 | uint32_t, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,17 @@ | |||
| 1 | + #include <sys/socket.h> | ||
| 2 | + #include <stddef.h> | ||
| 3 | + #include <errno.h> | ||
| 4 | + #include <assert.h> | ||
| 5 | + #include <stdio.h> | ||
| 6 | + | ||
| 7 | + // TODO(mhdawson): Update once sock_accept is implemented in uvwasi | ||
| 8 | + int main(void) { | ||
| 9 | + int fd = 0 ; | ||
| 10 | + socklen_t addrlen = 0; | ||
| 11 | + int flags = 0; | ||
| 12 | + int ret = accept(0, NULL, &addrlen); | ||
| 13 | + assert(ret == -1); | ||
| 14 | + assert(errno == ENOTSUP); | ||
| 15 | + | ||
| 16 | + return 0; | ||
| 17 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -137,6 +137,7 @@ if (process.argv[2] === 'wasi-child-default') { | |||
| 137 | 137 | stdout: `hello from input.txt${checkoutEOL}hello from input.txt${checkoutEOL}`, | |
| 138 | 138 | }); | |
| 139 | 139 | runWASI({ test: 'stat' }); | |
| 140 | + runWASI({ test: 'sock' }); | ||
| 140 | 141 | runWASI({ test: 'write_file' }); | |
| 141 | 142 | ||
| 142 | 143 | // Tests that are currently unsupported on Windows. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments