-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add random_get WASI function #195
Conversation
641838a
to
5c9658d
Compare
) | ||
) | ||
|
||
(assert_return (invoke "_start") (i32.const 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't _start
be called automatically? I remember there was a discussion about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is discussed in #187 , but not yet completed
Is random returns with 0? Strange. |
For the record: WASI functions return error codes only and have their ,,result'' written into memory. Error code 0 is |
Oooops... I forgot about this patch, sorry for not responding. :( This test only calls the |
void* buf = (void*)(instance->memory(0)->buffer() + argv[0].asI32()); | ||
uvwasi_size_t length = argv[1].asI32(); | ||
result[0] = Value(uvwasi_random_get(WASI::m_uvwasi, buf, length)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the spec,
random_get
function writes a random data into a buffer input.
Does this buffer mean memory
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes, but I'll ask my co-worker about it to be sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they do mean the memory.
https://github.com/WebAssembly/WASI/blob/main/legacy/application-abi.md
Regardless of the kind, all modules accessing WASI APIs also export a linear memory with the name memory. Data pointers in WASI API calls are relative to this memory's index space.
Maybe in the future if multiple memory ever becomes a standard then these funcitons may also gain an index to which memory to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.