Add parameter module inst for native wrapper functions (#117)

And add asm code of em64/arm/mips version to call native wrapper functions;
Fix some issues of calling wrapper functions;
This commit is contained in:
wenyongh
2019-09-10 10:23:46 +08:00
committed by GitHub
parent 2294f52e3a
commit 26149021ff
58 changed files with 1287 additions and 494 deletions

View File

@ -23,10 +23,10 @@
* This file is the consumer of connection lib which is implemented by different platforms
*/
uint32 wasm_open_connection(int32 name_offset, int32 args_offset, uint32 len)
uint32
wasm_open_connection(wasm_module_inst_t module_inst,
int32 name_offset, int32 args_offset, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst();
attr_container_t *args;
char *name, *args_buf;
@ -44,15 +44,17 @@ uint32 wasm_open_connection(int32 name_offset, int32 args_offset, uint32 len)
return -1;
}
void wasm_close_connection(uint32 handle)
void
wasm_close_connection(wasm_module_inst_t module_inst, uint32 handle)
{
if (connection_impl._close != NULL)
connection_impl._close(handle);
}
int wasm_send_on_connection(uint32 handle, int32 data_offset, uint32 len)
int
wasm_send_on_connection(wasm_module_inst_t module_inst,
uint32 handle, int32 data_offset, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst();
char *data;
if (!validate_app_addr(data_offset, len) ||
@ -65,9 +67,10 @@ int wasm_send_on_connection(uint32 handle, int32 data_offset, uint32 len)
return -1;
}
bool wasm_config_connection(uint32 handle, int32 cfg_offset, uint32 len)
bool
wasm_config_connection(wasm_module_inst_t module_inst,
uint32 handle, int32 cfg_offset, uint32 len)
{
wasm_module_inst_t module_inst = get_module_inst();
char *cfg_buf;
attr_container_t *cfg;

View File

@ -45,7 +45,9 @@ static WGLNativeFuncDef btn_native_func_defs[] = {
};
/*************** Native Interface to Wasm App ***********/
void wasm_btn_native_call(int32 func_id, uint32 argv_offset, uint32 argc)
void
wasm_btn_native_call(wasm_module_inst_t module_inst,
int32 func_id, uint32 argv_offset, uint32 argc)
{
uint32 size = sizeof(btn_native_func_defs) / sizeof(WGLNativeFuncDef);

View File

@ -61,7 +61,9 @@ static WGLNativeFuncDef cb_native_func_defs[] = {
};
/*************** Native Interface to Wasm App ***********/
void wasm_cb_native_call(int32 func_id, uint32 argv_offset, uint32 argc)
void
wasm_cb_native_call(wasm_module_inst_t module_inst,
int32 func_id, uint32 argv_offset, uint32 argc)
{
uint32 size = sizeof(cb_native_func_defs) / sizeof(WGLNativeFuncDef);

View File

@ -60,7 +60,9 @@ static WGLNativeFuncDef label_native_func_defs[] = {
};
/*************** Native Interface to Wasm App ***********/
void wasm_label_native_call(int32 func_id, uint32 argv_offset, uint32 argc)
void
wasm_label_native_call(wasm_module_inst_t module_inst,
int32 func_id, uint32 argv_offset, uint32 argc)
{
uint32 size = sizeof(label_native_func_defs) / sizeof(WGLNativeFuncDef);

View File

@ -51,7 +51,9 @@ static WGLNativeFuncDef list_native_func_defs[] = {
};
/*************** Native Interface to Wasm App ***********/
void wasm_list_native_call(int32 func_id, uint32 argv_offset, uint32 argc)
void
wasm_list_native_call(wasm_module_inst_t module_inst,
int32 func_id, uint32 argv_offset, uint32 argc)
{
uint32 size = sizeof(list_native_func_defs) / sizeof(WGLNativeFuncDef);

View File

@ -341,7 +341,9 @@ static WGLNativeFuncDef obj_native_func_defs[] = {
};
/*************** Native Interface to Wasm App ***********/
void wasm_obj_native_call(int32 func_id, uint32 argv_offset, uint32 argc)
void
wasm_obj_native_call(wasm_module_inst_t module_inst,
int32 func_id, uint32 argv_offset, uint32 argc)
{
uint32 size = sizeof(obj_native_func_defs) / sizeof(WGLNativeFuncDef);

View File

@ -22,8 +22,10 @@
static sys_sensor_t * g_sys_sensors = NULL;
static int g_sensor_id_max = 0;
static sensor_client_t *find_sensor_client(sys_sensor_t * sensor,
unsigned int client_id, bool remove_if_found);
static sensor_client_t *
find_sensor_client(sys_sensor_t * sensor,
unsigned int client_id, bool remove_if_found);
void (*rechedule_sensor_callback)() = NULL;
@ -32,7 +34,8 @@ void (*rechedule_sensor_callback)() = NULL;
*
*/
static void sensor_event_cleaner(sensor_event_data_t *sensor_event)
static void
sensor_event_cleaner(sensor_event_data_t *sensor_event)
{
if (sensor_event->data != NULL) {
if (sensor_event->data_fmt == FMT_ATTR_CONTAINER)
@ -44,8 +47,8 @@ static void sensor_event_cleaner(sensor_event_data_t *sensor_event)
bh_free(sensor_event);
}
static void wasm_sensor_callback(void *client, uint32 sensor_id,
void *user_data)
static void
wasm_sensor_callback(void *client, uint32 sensor_id, void *user_data)
{
attr_container_t *sensor_data = (attr_container_t *) user_data;
attr_container_t *sensor_data_clone;
@ -92,7 +95,10 @@ static void wasm_sensor_callback(void *client, uint32 sensor_id,
bh_post_msg2(module->queue, msg);
}
bool wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay)
bool
wasm_sensor_config(wasm_module_inst_t module_inst,
uint32 sensor, int interval,
int bit_cfg, int delay)
{
attr_container_t * attr_cont;
sensor_client_t * c;
@ -132,9 +138,10 @@ bool wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay)
return true;
}
uint32 wasm_sensor_open(int32 name_offset, int instance)
uint32
wasm_sensor_open(wasm_module_inst_t module_inst,
int32 name_offset, int instance)
{
wasm_module_inst_t module_inst = get_module_inst();
char *name = NULL;
if (!validate_app_addr(name_offset, 1))
@ -185,10 +192,11 @@ uint32 wasm_sensor_open(int32 name_offset, int instance)
return -1;
}
bool wasm_sensor_config_with_attr_container(uint32 sensor, int32 buffer_offset,
int len)
bool
wasm_sensor_config_with_attr_container(wasm_module_inst_t module_inst,
uint32 sensor, int32 buffer_offset,
int len)
{
wasm_module_inst_t module_inst = get_module_inst();
char *buffer = NULL;
if (!validate_app_addr(buffer_offset, len))
@ -211,7 +219,8 @@ bool wasm_sensor_config_with_attr_container(uint32 sensor, int32 buffer_offset,
return false;
}
bool wasm_sensor_close(uint32 sensor)
bool
wasm_sensor_close(wasm_module_inst_t module_inst, uint32 sensor)
{
unsigned int mod_id = app_manager_get_module_id(Module_WASM_App);
unsigned int client_id = mod_id;
@ -271,8 +280,9 @@ void refresh_read_interval(sensor_obj_t sensor)
sensor->read_interval = interval;
}
sensor_obj_t add_sys_sensor(char * name, char * description, int instance,
uint32 default_interval, void * read_func, void * config_func)
sensor_obj_t
add_sys_sensor(char * name, char * description, int instance,
uint32 default_interval, void * read_func, void * config_func)
{
sys_sensor_t * s = (sys_sensor_t *) bh_malloc(sizeof(sys_sensor_t));
if (s == NULL)

View File

@ -19,6 +19,8 @@
#include "bh_platform.h"
#include "attr_container.h"
#include "wasm_export.h"
struct _sys_sensor;
typedef struct _sys_sensor* sensor_obj_t;
@ -60,16 +62,19 @@ int check_sensor_timers();
void reschedule_sensor_read();
uint32
wasm_sensor_open(int32 name_offset, int instance);
wasm_sensor_open(wasm_module_inst_t module_inst,
int32 name_offset, int instance);
bool
wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay);
wasm_sensor_config(wasm_module_inst_t module_inst,
uint32 sensor, int interval, int bit_cfg, int delay);
bool
wasm_sensor_config_with_attr_container(uint32 sensor, int32 buffer_offset,
int len);
wasm_sensor_config_with_attr_container(wasm_module_inst_t module_inst,
uint32 sensor, int32 buffer_offset,
int len);
bool
wasm_sensor_close(uint32 sensor);
wasm_sensor_close(wasm_module_inst_t module_inst, uint32 sensor);
#endif /* LIB_EXTENSION_RUNTIME_SENSOR_H_ */