1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:17:35 +00:00

LibWasm: Explicitly place the paddings in the WASI API types

This makes it so we don't rely on e.g. u64 to have an 8-byte alignment,
fixing breakage on i686 systems.
This commit is contained in:
Ali Mohammad Pur 2023-09-03 19:45:40 +03:30 committed by Ali Mohammad Pur
parent d6906736cc
commit 4fb209d25f
2 changed files with 25 additions and 16 deletions

View file

@ -169,8 +169,8 @@ void FDStat::serialize_into(Array<Bytes, 1> bytes) const
void PreStat::serialize_into(Array<Bytes, 1> bytes) const
{
auto data = bytes[0];
ABI::serialize(tag, Array { data.slice(0, sizeof(tag)) });
if (tag == 0)
ABI::serialize(type, Array { data.slice(0, sizeof(type)) });
if (type == PreOpenType::Dir)
ABI::serialize(dir, Array { data.slice(offsetof(PreStat, dir), sizeof(dir)) });
else
VERIFY_NOT_REACHED();
@ -477,7 +477,7 @@ ErrorOr<Result<PreStat>> Implementation::impl$fd_prestat_get(Configuration&, FD
auto index = m_first_unmapped_preopened_directory_index++;
m_fd_map.insert(unmapped_fd.value(), PreopenedDirectoryDescriptor(index));
return PreStat {
.tag = 0,
.type = PreOpenType::Dir,
.dir = PreStatDir {
.pr_name_len = paths[index].mapped_path.string().bytes().size(),
},
@ -488,7 +488,7 @@ ErrorOr<Result<PreStat>> Implementation::impl$fd_prestat_get(Configuration&, FD
},
[&](PreopenedDirectoryDescriptor fd) -> Result<PreStat> {
return PreStat {
.tag = 0,
.type = PreOpenType::Dir,
.dir = PreStatDir {
.pr_name_len = paths[fd.value()].mapped_path.string().bytes().size(),
},