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:
@ -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);
|
||||
|
||||
@ -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"),
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
|
||||
set (WASM_LIB_SENSOR_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
add_definitions (-DAPP_FRAMEWORK_SENSOR)
|
||||
|
||||
include_directories(${WASM_LIB_SENSOR_DIR})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user