Example 2: Using "native-lib"
The related code/working directory of this example resides in directory {WAMR_DIR}/samples/native-lib
static int
foo_wrapper(wasm_exec_env_t exec_env, int x, int y)
{
return x + y;
}
#define REG_NATIVE_FUNC(func_name, signature) \
{ #func_name, func_name##_wrapper, signature, NULL }
static NativeSymbol native_symbols[] = {
REG_NATIVE_FUNC(foo, "(ii)i")
};
uint32_t
get_native_lib(char **p_module_name, NativeSymbol **p_native_symbols)
{
*p_module_name = "env";
*p_native_symbols = native_symbols;
return sizeof(native_symbols) / sizeof(NativeSymbol);
}Preparation
Build the sample
Run workload
Linux
macOS
Last updated