Skip to content
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

Question: Can we use pointer of structure for the WASI API parameter? #86

Closed
Kevin0626 opened this issue Jul 14, 2019 · 2 comments
Closed

Comments

@Kevin0626
Copy link

Kevin0626 commented Jul 14, 2019

Hi,

I just saw the API __wasi_sock_recv() is using a pointer of __wasi_iovec_t as the second parameter. I wonder if we can use data structure for the data sharing between the WASM inside and outside. There are some concerns about the memory layout and endian might be different. I also found there are some static asserts about the the structure __wasi_iovec_t, and my guess it might be related with these concerns. My question is - do we have any common guideline about using structure pointer as WASI API parameter here?

typedef struct __wasi_iovec_t {
void *buf;
size_t buf_len;
} __wasi_iovec_t;

@sunfishcode
Copy link
Member

In the short term, wasm pointers are always 32-bit and wasm integers are always little-endian, so __wasio_iovec_t will always have a very simple layout. It may differ from the host's layout of the same struct, but wasm pointers will always need to be translated before they can be used on the host, so it's not that different from what hosts would have to do anyway.

Longer term, I expect the API will be defined in terms of the webidl-bindings proposal, which will provide more flexibility.

@sunfishcode
Copy link
Member

I believe the question is answered here; feel free to re-open or file a new issue if you have further questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants