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

c-api: add wasi_config_set_stdin_bytes #5179

Merged
merged 2 commits into from
Nov 2, 2022

Conversation

ShuP1
Copy link
Contributor

@ShuP1 ShuP1 commented Nov 2, 2022

As discussed in issue #4372 and respective issues about python and go bindings.

Can replace wasi_config_inherit_stdin in examples/wasi/main.c:78

wasi_config_t *wasi_config = wasi_config_new();
assert(wasi_config);
wasm_byte_vec_t binary;
wasm_name_new_from_string_nt(&binary, "sent to stdin");
wasi_config_set_stdin_bytes(wasi_config, &binary);
error = wasmtime_context_set_wasi(context, wasi_config);

(cc @alexcrichton)

@github-actions github-actions bot added the wasmtime:c-api Issues pertaining to the C API. label Nov 2, 2022
@github-actions
Copy link

github-actions bot commented Nov 2, 2022

Subscribe to Label Action

cc @peterhuene

This issue or pull request has been labeled: "wasmtime:c-api"

Thus the following users have been cc'd because of the following labels:

  • peterhuene: wasmtime:c-api

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for this! One small nit on the C side but otherwise I think this might also need a cargo fmt to pass CI.

*
* This function takes ownership of the `binary` argument.
*/
WASI_API_EXTERN void wasi_config_set_stdin_bytes(wasi_config_t* config, const wasm_byte_vec_t* binary);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this takes owneship of the argument here I think it might be good to drop the const qualifier since it's actually mutated.

@alexcrichton alexcrichton merged commit 348f962 into bytecodealliance:main Nov 2, 2022
@alexcrichton
Copy link
Member

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasmtime:c-api Issues pertaining to the C API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants