-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement uvwasi library and improve WASI structure
Introduce uvwasi into the build system. Introduce class WasiFunction to enable WASI to acces Instance resources. Implement further WASI types and fd_write function. Signed-off-by: Adam Laszlo Kulcsar <[email protected]>
- Loading branch information
1 parent
54c0b6a
commit 187a895
Showing
12 changed files
with
330 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2023-present Samsung Electronics Co., Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Walrus { | ||
|
||
void WASI::fd_write(ExecutionState& state, Value* argv, Value* result, Instance* instance) | ||
{ | ||
int32_t fd = argv[0].asI32(); | ||
int32_t iovptr = argv[1].asI32(); | ||
int32_t iovcnt = argv[2].asI32(); | ||
WASI::wasi_iovec_t wasi_iovs; | ||
|
||
if (!WASI::checkMemOffset(instance->memory(0), iovptr, iovcnt)) { | ||
result[0] = Value(static_cast<int16_t>(WASI::wasi_errno::inval)); | ||
result[1] = Value(static_cast<int32_t>(0)); | ||
return; | ||
} | ||
|
||
wasi_iovs.buf = reinterpret_cast<uint8_t*>(iovptr); | ||
wasi_iovs.len = iovcnt; | ||
|
||
std::vector<uvwasi_ciovec_t> iovs(iovcnt); | ||
for (int i = 0; i < iovcnt; i++) { | ||
iovs[i].buf_len = wasi_iovs.len; | ||
iovs[0].buf = wasi_iovs.buf; | ||
} | ||
|
||
uvwasi_size_t out_addr; | ||
result[0] = Value(static_cast<int16_t>(uvwasi_fd_write(WASI::m_uvwasi, fd, iovs.data(), iovs.size(), &out_addr))); | ||
result[1] = Value(static_cast<int32_t>(out_addr)); | ||
} | ||
|
||
} // namespace Walrus |
Oops, something went wrong.