Fix function type not set issue of aot_call_indirect (#229)

Add registration of libc-wasi to 'wasi_snapshot_preview1' to support cargo-wasi
change zephyr build method from cmake to west
fix problem when preserve space for local vars
fix wasi authority problem
This commit is contained in:
Xu Jun
2020-04-07 11:04:46 +08:00
committed by GitHub
parent 374e687938
commit 5e196253f6
26 changed files with 512 additions and 143 deletions

View File

@ -7,6 +7,11 @@
#include "wasm_export.h"
#include "math.h"
extern bool
wasm_runtime_call_indirect(wasm_exec_env_t exec_env,
uint32_t element_indices,
uint32_t argc, uint32_t argv[]);
// The first parameter is not exec_env because it is invoked by native funtions
void reverse(char * str, int len)
{
@ -63,3 +68,29 @@ int get_pow(wasm_exec_env_t exec_env, int x, int y) {
printf ("calling into native function: %s\n", __FUNCTION__);
return (int)pow(x, y);
}
int32_t
calculate_native(wasm_exec_env_t exec_env, int32_t n, int32_t func1,
int32_t func2)
{
printf("calling into native function: %s, n=%d, func1=%d, func2=%d\n",
__FUNCTION__, n, func1, func2);
uint32_t argv[] = { n };
if (!wasm_runtime_call_indirect(exec_env, func1, 1, argv)) {
printf("call func1 failed\n");
return 0xDEAD;
}
uint32_t n1 = argv[0];
printf("call func1 and return n1=%d\n", n1);
if (!wasm_runtime_call_indirect(exec_env, func2, 1, argv)) {
printf("call func2 failed\n");
return 0xDEAD;
}
uint32_t n2 = argv[0];
printf("call func2 and return n2=%d\n", n2);
return n1 + n2;
}