Implement module instance context APIs (#2436)
Introduce module instance context APIs which can set one or more contexts created
by the embedder for a wasm module instance:
```C
wasm_runtime_create_context_key
wasm_runtime_destroy_context_key
wasm_runtime_set_context
wasm_runtime_set_context_spread
wasm_runtime_get_context
```
And make libc-wasi use it and set wasi context as the first context bound to the wasm
module instance.
Also add samples.
Refer to https://github.com/bytecodealliance/wasm-micro-runtime/issues/2460.
This commit is contained in:
19
samples/inst-context/wasm-apps/testapp.c
Normal file
19
samples/inst-context/wasm-apps/testapp.c
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int32_t
|
||||
add_native(int32_t n);
|
||||
|
||||
int32_t
|
||||
calculate(int32_t n)
|
||||
{
|
||||
printf("calling into WASM function: %s\n", __FUNCTION__);
|
||||
return add_native(n);
|
||||
}
|
||||
Reference in New Issue
Block a user