Skip to content

Commit

Permalink
Merge #3089
Browse files Browse the repository at this point in the history
3089: Add wasi_* C-API function changes in migration guide for 3.0.0 r=epilys a=epilys

- `wasi_env_new` changed signature
- `wasi_get_imports` changed signature
- `wasi_env_set_memory` was added

Closes #3077

<!-- 
Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test:
https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests

-->

# Description
<!-- 
Provide details regarding the change including motivation,
links to related issues, and the context of the PR.
-->


Co-authored-by: Manos Pitsidianakis <[email protected]>
  • Loading branch information
bors[bot] and epilys authored Aug 10, 2022
2 parents a6ddf4e + ba38b7e commit f0ed34c
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 f0ed34c

Please sign in to comment.