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:
@ -6,9 +6,11 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int intToStr(int x, char* str, int str_len, int digit);
|
||||
int get_pow(int x, int y);
|
||||
int32_t calculate_native(int32_t n, int32_t func1, int32_t func2);
|
||||
|
||||
//
|
||||
// Primitive parameters functions
|
||||
@ -54,3 +56,27 @@ void float_to_string(float n, char* res, int res_size, int afterpoint)
|
||||
intToStr((int)fpart, res + i + 1, sizeof(res + i + 1), afterpoint);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t mul7(int32_t n)
|
||||
{
|
||||
printf ("calling into WASM function: %s,", __FUNCTION__);
|
||||
n = n * 7;
|
||||
printf (" %s return %d \n", __FUNCTION__, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
int32_t mul5(int32_t n)
|
||||
{
|
||||
printf ("calling into WASM function: %s,", __FUNCTION__);
|
||||
n = n * 5;
|
||||
printf (" %s return %d \n", __FUNCTION__, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
int32_t calculate(int32_t n)
|
||||
{
|
||||
printf ("calling into WASM function: %s\n", __FUNCTION__);
|
||||
int32_t (*f1)(int32_t) = &mul5;
|
||||
int32_t (*f2)(int32_t) = &mul7;
|
||||
return calculate_native(n, (uint32_t)f1, (uint32_t)f2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user