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

@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
EXPORT_WASM_API(wasm_open_connection),
EXPORT_WASM_API(wasm_close_connection),
EXPORT_WASM_API(wasm_send_on_connection),
EXPORT_WASM_API(wasm_config_connection),
EXPORT_WASM_API_WITH_SIG(wasm_open_connection, "($*~)i"),
EXPORT_WASM_API_WITH_SIG(wasm_close_connection, "(i)"),
EXPORT_WASM_API_WITH_SIG(wasm_send_on_connection, "(i*~)i"),
EXPORT_WASM_API_WITH_SIG(wasm_config_connection, "(i*~)i"),

View File

@ -20,16 +20,16 @@ extern "C" {
uint32
wasm_open_connection(wasm_exec_env_t exec_env,
int32 name_offset, int32 args_offset, uint32 len);
char *name, char *args_buf, uint32 len);
void
wasm_close_connection(wasm_exec_env_t exec_env,
uint32 handle);
int
wasm_send_on_connection(wasm_exec_env_t exec_env,
uint32 handle, int32 data_offset, uint32 len);
uint32 handle, char *data, uint32 len);
bool
wasm_config_connection(wasm_exec_env_t exec_env,
uint32 handle, int32 cfg_offset, uint32 len);
uint32 handle, char *cfg_buf, uint32 len);

View File

@ -16,17 +16,10 @@
uint32
wasm_open_connection(wasm_exec_env_t exec_env,
int32 name_offset, int32 args_offset, uint32 len)
char *name, char *args_buf, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
attr_container_t *args;
char *name, *args_buf;
if (!validate_app_str_addr(name_offset) ||
!validate_app_addr(args_offset, len) ||
!(name = addr_app_to_native(name_offset)) ||
!(args_buf = addr_app_to_native(args_offset)))
return -1;
args = (attr_container_t *)args_buf;
@ -45,15 +38,8 @@ wasm_close_connection(wasm_exec_env_t exec_env, uint32 handle)
int
wasm_send_on_connection(wasm_exec_env_t exec_env,
uint32 handle, int32 data_offset, uint32 len)
uint32 handle, char *data, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *data;
if (!validate_app_addr(data_offset, len) ||
!(data = addr_app_to_native(data_offset)))
return -1;
if (connection_impl._send != NULL)
return connection_impl._send(handle, data, len);
@ -62,16 +48,10 @@ wasm_send_on_connection(wasm_exec_env_t exec_env,
bool
wasm_config_connection(wasm_exec_env_t exec_env,
uint32 handle, int32 cfg_offset, uint32 len)
uint32 handle, char *cfg_buf, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
char *cfg_buf;
attr_container_t *cfg;
if (!validate_app_addr(cfg_offset, len) ||
!(cfg_buf = addr_app_to_native(cfg_offset)))
return false;
cfg = (attr_container_t *)cfg_buf;
if (connection_impl._config != NULL)

View File

@ -5,6 +5,9 @@ set (WASM_LIB_CONN_DIR ${CMAKE_CURRENT_LIST_DIR})
include_directories(${WASM_LIB_CONN_DIR})
add_definitions (-DAPP_FRAMEWORK_CONNECTION)
include (${CMAKE_CURRENT_LIST_DIR}/${WAMR_BUILD_PLATFORM}/connection_mgr.cmake)
file (GLOB source_all