| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b52aacb commit 407af51
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1503,6 +1503,37 @@ void WASI::SchedYield(const FunctionCallbackInfo<Value>& args) { | |||
| 1503 | 1503 | args.GetReturnValue().Set(err); | |
| 1504 | 1504 | } | |
| 1505 | 1505 | ||
| 1506 | + void WASI::SockAccept(const FunctionCallbackInfo<Value>& args) { | ||
| 1507 | + WASI* wasi; | ||
| 1508 | + uint32_t sock; | ||
| 1509 | + uint32_t flags; | ||
| 1510 | + uint32_t fd_ptr; | ||
| 1511 | + char* memory; | ||
| 1512 | + size_t mem_size; | ||
| 1513 | + RETURN_IF_BAD_ARG_COUNT(args, 3); | ||
| 1514 | + CHECK_TO_TYPE_OR_RETURN(args, args[0], Uint32, sock); | ||
| 1515 | + CHECK_TO_TYPE_OR_RETURN(args, args[1], Uint32, flags); | ||
| 1516 | + CHECK_TO_TYPE_OR_RETURN(args, args[2], Uint32, fd_ptr); | ||
| 1517 | + ASSIGN_INITIALIZED_OR_RETURN_UNWRAP(&wasi, args.This()); | ||
| 1518 | + Debug(wasi, | ||
| 1519 | + "sock_accept(%d, %d, %d)\n", | ||
| 1520 | + sock, | ||
| 1521 | + flags, | ||
| 1522 | + fd_ptr); | ||
| 1523 | + GET_BACKING_STORE_OR_RETURN(wasi, args, &memory, &mem_size); | ||
| 1524 | + CHECK_BOUNDS_OR_RETURN(args, mem_size, fd_ptr, UVWASI_SERDES_SIZE_fd_t); | ||
| 1525 | + | ||
| 1526 | + uvwasi_fd_t fd; | ||
| 1527 | + uvwasi_errno_t err = uvwasi_sock_accept(&wasi->uvw_, | ||
| 1528 | + sock, | ||
| 1529 | + flags, | ||
| 1530 | + &fd); | ||
| 1531 | + | ||
| 1532 | + if (err == UVWASI_ESUCCESS) | ||
| 1533 | + uvwasi_serdes_write_size_t(memory, fd_ptr, fd); | ||
| 1534 | + | ||
| 1535 | + args.GetReturnValue().Set(err); | ||
| 1536 | + } | ||
| 1506 | 1537 | ||
| 1507 | 1538 | void WASI::SockRecv(const FunctionCallbackInfo<Value>& args) { | |
| 1508 | 1539 | WASI* wasi; | |
@@ -1720,6 +1751,7 @@ static void Initialize(Local<Object> target, | |||
| 1720 | 1751 | SetProtoMethod(isolate, tmpl, "proc_raise", WASI::ProcRaise); | |
| 1721 | 1752 | SetProtoMethod(isolate, tmpl, "random_get", WASI::RandomGet); | |
| 1722 | 1753 | SetProtoMethod(isolate, tmpl, "sched_yield", WASI::SchedYield); | |
| 1754 | + SetProtoMethod(isolate, tmpl, "sock_accept", WASI::SockAccept); | ||
| 1723 | 1755 | SetProtoMethod(isolate, tmpl, "sock_recv", WASI::SockRecv); | |
| 1724 | 1756 | SetProtoMethod(isolate, tmpl, "sock_send", WASI::SockSend); | |
| 1725 | 1757 | SetProtoMethod(isolate, tmpl, "sock_shutdown", WASI::SockShutdown); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -71,6 +71,7 @@ class WASI : public BaseObject, | |||
| 71 | 71 | static void ProcRaise(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 72 | 72 | static void RandomGet(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 73 | 73 | static void SchedYield(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 74 | + static void SockAccept(const v8::FunctionCallbackInfo<v8::Value>& args); | ||
| 74 | 75 | static void SockRecv(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 75 | 76 | static void SockSend(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 76 | 77 | static void SockShutdown(const v8::FunctionCallbackInfo<v8::Value>& args); | |
| 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 | |
|---|---|---|---|
@@ -92,6 +92,7 @@ if (process.argv[2] === 'wasi-child') { | |||
| 92 | 92 | stdout: `hello from input.txt${checkoutEOL}hello from input.txt${checkoutEOL}`, | |
| 93 | 93 | }); | |
| 94 | 94 | runWASI({ test: 'stat' }); | |
| 95 | + runWASI({ test: 'sock' }); | ||
| 95 | 96 | runWASI({ test: 'write_file' }); | |
| 96 | 97 | ||
| 97 | 98 | // Tests that are currently unsupported on Windows. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments