Implement native function pointer check, addr conversion and register, update documents (#185)

Modified WASM runtime API:
- wasm_runtime_module_malloc()
- wasm_runtime_lookup_function()
Introduced runtime API
- wasm_runtime_register_natives()
This commit is contained in:
wenyongh
2020-03-04 20:12:38 +08:00
committed by GitHub
parent 2e36149e32
commit 0d3f304191
96 changed files with 2293 additions and 2317 deletions

View File

@ -135,15 +135,9 @@ wasm_sensor_config(wasm_exec_env_t exec_env,
uint32
wasm_sensor_open(wasm_exec_env_t exec_env,
int32 name_offset, int instance)
char *name, int instance)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *name = NULL;
if (!validate_app_str_addr(name_offset))
return -1;
name = addr_app_to_native(name_offset);
if (name != NULL) {
sensor_client_t *c;
@ -192,17 +186,8 @@ wasm_sensor_open(wasm_exec_env_t exec_env,
bool
wasm_sensor_config_with_attr_container(wasm_exec_env_t exec_env,
uint32 sensor, int32 buffer_offset,
int len)
uint32 sensor, char *buffer, int len)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *buffer = NULL;
if (!validate_app_addr(buffer_offset, len))
return false;
buffer = addr_app_to_native(buffer_offset);
if (buffer != NULL) {
attr_container_t *cfg = (attr_container_t *)buffer;
sensor_obj_t s = find_sys_sensor_id(sensor);

View File

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
EXPORT_WASM_API(wasm_sensor_open),
EXPORT_WASM_API(wasm_sensor_config),
EXPORT_WASM_API(wasm_sensor_config_with_attr_container),
EXPORT_WASM_API(wasm_sensor_close),
EXPORT_WASM_API_WITH_SIG(wasm_sensor_open, "($i)i"),
EXPORT_WASM_API_WITH_SIG(wasm_sensor_config, "(iiii)i"),
EXPORT_WASM_API_WITH_SIG(wasm_sensor_config_with_attr_container, "(i*~)i"),
EXPORT_WASM_API_WITH_SIG(wasm_sensor_close, "(i)i"),

View File

@ -19,12 +19,11 @@ wasm_sensor_config(wasm_exec_env_t exec_env,
int bit_cfg, int delay);
uint32
wasm_sensor_open(wasm_exec_env_t exec_env,
int32 name_offset, int instance);
char *name, int instance);
bool
wasm_sensor_config_with_attr_container(wasm_exec_env_t exec_env,
uint32 sensor, int32 buffer_offset,
int len);
uint32 sensor, char *buffer, int len);
bool
wasm_sensor_close(wasm_exec_env_t exec_env, uint32 sensor);

View File

@ -3,6 +3,8 @@
set (WASM_LIB_SENSOR_DIR ${CMAKE_CURRENT_LIST_DIR})
add_definitions (-DAPP_FRAMEWORK_SENSOR)
include_directories(${WASM_LIB_SENSOR_DIR})