-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of native size_t
in the API
#119
Comments
I've noticed this, and it's something I've wanted to change. I've run into the exact problem you describe when interfacing with WASM memory. I assumed there was a reason that the WASI spec didn't specify a fixed width size, given the number of fixed width types that it does specify. Now that someone involved with the spec is raising this, I'll make the change today 😄 |
Hmm, now that this is fixed I realize this doesn't help for more complicated cases such as iovec. The problem is (a) that the pointer size itself is different so the struct size is not the same and (b) the interior pointers valid outside of wasm. This means that we there is no way to currently pass an So, it seems that some kind of conversion layer is always needed to convert from the internal wasm memory layout to the external How about two layers of API:
For example today we have the inner function called We could hopefully generate all these wrappers from the witx files directly! I imagine @phickey does something very similar for rust, and we can crib a lot from there. |
Yea, I've had to write WASM memory interfacing logic in both wasm3 and Node.js. This type of logic is also required for struct padding when writing back to WASM memory. The idea of #69 and #94 was to create APIs for this so that embedders don't need to worry about those implementation details. If those were automatically generated, it would be even better. |
Would it be better to avoid the native
size_t
type and use a fixed sizewasi_size_t
?For example in the following API signature:
In this case it would make sense to pass the actual address of the
nwritten
out param in the wasm memory. However since wasi's size_t is fixed at 4 bytes, we wouldn't want to write a 64-bit value into that location. It seems that on LP64 systems weuvwasi_fd_write
would currently write 8 bytes. Maybe I'm misunderstanding?The text was updated successfully, but these errors were encountered: