Skip to content

Commit

Permalink
Add wasi_* C-API function changes in migration guide for 3.0.0
Browse files Browse the repository at this point in the history
- `wasi_env_new` changed signature
- `wasi_get_imports` changed signature
- `wasi_env_set_memory` was added

Closes #3077
  • Loading branch information
epilys authored and ptitSeb committed Oct 20, 2022
1 parent c3e7f16 commit 4b6d283
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/migration_to_3.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4b6d283

Please sign in to comment.