From ba38b7e214fe8266c5b8b2bd6c09f55ce5fb2ef1 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Wed, 10 Aug 2022 15:59:46 +0300 Subject: [PATCH] Add wasi_* C-API function changes in migration guide for 3.0.0 - `wasi_env_new` changed signature - `wasi_get_imports` changed signature - `wasi_env_set_memory` was added Closes #3077 --- docs/migration_to_3.0.0.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/migration_to_3.0.0.md b/docs/migration_to_3.0.0.md index 6530255ae5e..f387409461a 100644 --- a/docs/migration_to_3.0.0.md +++ b/docs/migration_to_3.0.0.md @@ -13,6 +13,7 @@ and provide examples to make migrating to the new API as simple as possible. - [Differences](#differences) - [Managing imports](#managing-imports) - [Engines](#engines) + - [C-API changes](#c-api) ## Rationale for changes in 3.0.0 @@ -171,6 +172,31 @@ let engine = EngineBuilder::new(compiler).set_features(Some(features)); let store = Store::new(engine); ``` +### C-API + +The WASM C-API hasn't changed. Some wasmer-specific functions have changed, that relate to setting up WASI environments. + +- `wasi_env_new` function changed input parameters to accommodate the new Store API, it now is: + ```C + struct wasi_env_t *wasi_env_new(wasm_store_t *store, struct wasi_config_t *config); + ``` +- `wasi_get_imports` function changed input parameters to accommodate the new Store API, it now is: + ```c + bool wasi_get_imports(const wasm_store_t *_store, + struct wasi_env_t *wasi_env, + const wasm_module_t *module, + wasm_extern_vec_t *imports); + ``` +- `wasi_env_set_memory` was added. It's necessary to set the `WasiEnv` memory by getting it from `Instance`s memory exports after its initialization. This must be performed in a specific order: + 1. Create WasiEnv + 2. Create Instance + 3. Get Instance Exports + 4. Find Memory from Instance Exports and store it to WasiEnv + The function's signature is: + ```c + void wasi_env_set_memory(struct wasi_env_t *env, const wasm_memory_t *memory); + ``` + [examples]: https://docs.wasmer.io/integrations/examples [wasmer]: https://crates.io/crates/wasmer [wasmer-wasi]: https://crates.io/crates/wasmer-wasi