Implement more wasm-c-apis and enable Envoy integration (#622)

Implement more wasm-c-api APIs to support Envoy integration:
- sync up with latest c-api definition
- change CMakeLists to export necessary headers and install the static library of iwasm
- enable to export tables and memories
- support memorytype and tabletype APIs
- update wasm-c-api sampels
- enable to export importtype APIs

And refine bazel scripts for sample XNNPACK workload, add license headers for sample simple.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
Wenyong Huang
2021-04-27 17:05:40 +08:00
committed by GitHub
parent a332a49a0d
commit eb29385963
36 changed files with 3190 additions and 1939 deletions

View File

@ -4,14 +4,6 @@
#include <inttypes.h>
#include "wasm_c_api.h"
#include "wasm_export.h"
#include "bh_platform.h"
extern bool
reader(const char *module_name, uint8 **p_buffer, uint32 *p_size);
extern void
destroyer(uint8 *buffer, uint32 size);
#define own
@ -69,8 +61,6 @@ own wasm_trap_t* closure_callback(
int main(int argc, const char* argv[]) {
wasm_runtime_set_module_reader(reader, destroyer);
// Initialize.
printf("Initializing...\n");
wasm_engine_t* engine = wasm_engine_new();
@ -78,11 +68,7 @@ int main(int argc, const char* argv[]) {
// Load binary.
printf("Loading binary...\n");
#if WASM_ENABLE_AOT != 0 && WASM_ENABLE_INTERP == 0
FILE* file = fopen("callback.aot", "rb");
#else
FILE* file = fopen("callback.wasm", "rb");
#endif
if (!file) {
printf("> Error loading module!\n");
return 1;
@ -154,12 +140,8 @@ int main(int argc, const char* argv[]) {
// Call.
printf("Calling export...\n");
wasm_val_t args[2];
args[0].kind = WASM_I32;
args[0].of.i32 = 3;
args[1].kind = WASM_I32;
args[1].of.i32 = 4;
wasm_val_t results[1];
wasm_val_t args[2] = { WASM_I32_VAL(3), WASM_I32_VAL(4) };
wasm_val_t results[1] = { WASM_INIT_VAL };
if (wasm_func_call(run_func, args, results)) {
printf("> Error calling function!\n");
return 1;