Apply clang-format for more source files (#795)

Apply clang-format for C source files in folder core/app-mgr,
core/app-framework, and test-tools.
And rename folder component_test to component-test, update
zephyr build document.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
Wenyong Huang
2021-10-21 13:58:34 +08:00
committed by GitHub
parent 225f5d0a64
commit 32242988ed
143 changed files with 5377 additions and 4627 deletions

View File

@ -10,16 +10,15 @@
#include "req_resp_native_api.h"
#include "timer_native_api.h"
static NativeSymbol extended_native_symbol_defs[] = {
/* TODO: use macro EXPORT_WASM_API() or EXPORT_WASM_API2() to
add functions to register. */
#include "base_lib.inl"
/* TODO: use macro EXPORT_WASM_API() or EXPORT_WASM_API2() to
add functions to register. */
#include "base_lib.inl"
};
uint32 get_base_lib_export_apis(NativeSymbol **p_base_lib_apis)
uint32
get_base_lib_export_apis(NativeSymbol **p_base_lib_apis)
{
*p_base_lib_apis = extended_native_symbol_defs;
return sizeof(extended_native_symbol_defs) / sizeof(NativeSymbol);
}

View File

@ -27,4 +27,3 @@ wasm_sub_event(wasm_exec_env_t exec_env, char *url);
#endif
#endif /* end of _REQ_RESP_API_H_ */

View File

@ -8,7 +8,8 @@
#include "wasm_export.h"
#include "bh_assert.h"
extern void module_request_handler(request_t *request, void *user_data);
extern void
module_request_handler(request_t *request, void *user_data);
bool
wasm_response_send(wasm_exec_env_t exec_env, char *buffer, int size)
@ -33,8 +34,8 @@ wasm_register_resource(wasm_exec_env_t exec_env, char *url)
wasm_module_inst_t module_inst = get_module_inst(exec_env);
if (url != NULL) {
unsigned int mod_id = app_manager_get_module_id(Module_WASM_App,
module_inst);
unsigned int mod_id =
app_manager_get_module_id(Module_WASM_App, module_inst);
bh_assert(mod_id != ID_NONE);
am_register_resource(url, module_request_handler, mod_id);
}
@ -54,8 +55,8 @@ wasm_post_request(wasm_exec_env_t exec_env, char *buffer, int size)
// TODO: add permission check, ensure app can't do harm
// set sender to help dispatch the response to the sender ap
unsigned int mod_id = app_manager_get_module_id(Module_WASM_App,
module_inst);
unsigned int mod_id =
app_manager_get_module_id(Module_WASM_App, module_inst);
bh_assert(mod_id != ID_NONE);
req->sender = mod_id;
@ -74,11 +75,10 @@ wasm_sub_event(wasm_exec_env_t exec_env, char *url)
wasm_module_inst_t module_inst = get_module_inst(exec_env);
if (url != NULL) {
unsigned int mod_id = app_manager_get_module_id(Module_WASM_App,
module_inst);
unsigned int mod_id =
app_manager_get_module_id(Module_WASM_App, module_inst);
bh_assert(mod_id != ID_NONE);
am_register_event(url, mod_id);
}
}

View File

@ -6,13 +6,17 @@
#ifndef LIB_BASE_RUNTIME_LIB_H_
#define LIB_BASE_RUNTIME_LIB_H_
#include "runtime_timer.h"
void init_wasm_timer();
void exit_wasm_timer();
timer_ctx_t get_wasm_timer_ctx();
timer_ctx_t create_wasm_timer_ctx(unsigned int module_id, int prealloc_num);
void destroy_module_timer_ctx(unsigned int module_id);
void
init_wasm_timer();
void
exit_wasm_timer();
timer_ctx_t
get_wasm_timer_ctx();
timer_ctx_t
create_wasm_timer_ctx(unsigned int module_id, int prealloc_num);
void
destroy_module_timer_ctx(unsigned int module_id);
#endif /* LIB_BASE_RUNTIME_LIB_H_ */

View File

@ -9,7 +9,6 @@
#include "bh_platform.h"
#include "wasm_export.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -23,15 +22,14 @@ typedef unsigned int timer_id_t;
typedef unsigned int timer_id_t;
timer_id_t
wasm_create_timer(wasm_exec_env_t exec_env,
int interval, bool is_period, bool auto_start);
wasm_create_timer(wasm_exec_env_t exec_env, int interval, bool is_period,
bool auto_start);
void
wasm_timer_destroy(wasm_exec_env_t exec_env, timer_id_t timer_id);
void
wasm_timer_cancel(wasm_exec_env_t exec_env, timer_id_t timer_id);
void
wasm_timer_restart(wasm_exec_env_t exec_env,
timer_id_t timer_id, int interval);
wasm_timer_restart(wasm_exec_env_t exec_env, timer_id_t timer_id, int interval);
uint32
wasm_get_sys_tick_ms(wasm_exec_env_t exec_env);
@ -40,4 +38,3 @@ wasm_get_sys_tick_ms(wasm_exec_env_t exec_env);
#endif
#endif /* end of _TIMER_API_H_ */

View File

@ -22,7 +22,7 @@ static korp_mutex g_timer_ctx_list_mutex;
void
wasm_timer_callback(timer_id_t id, unsigned int mod_id)
{
module_data* module = module_data_list_lookup_id(mod_id);
module_data *module = module_data_list_lookup_id(mod_id);
if (module == NULL)
return;
@ -40,7 +40,8 @@ wasm_timer_callback(timer_id_t id, unsigned int mod_id)
* the module from module id. It is for avoiding that situation.
*/
void * thread_modulers_timer_check(void * arg)
void *
thread_modulers_timer_check(void *arg)
{
uint32 ms_to_expiry;
uint64 us_to_wait;
@ -48,8 +49,8 @@ void * thread_modulers_timer_check(void * arg)
while (timer_thread_run) {
ms_to_expiry = (uint32)-1;
os_mutex_lock(&g_timer_ctx_list_mutex);
timer_ctx_node_t* elem = (timer_ctx_node_t*)
bh_list_first_elem(&g_timer_ctx_list);
timer_ctx_node_t *elem =
(timer_ctx_node_t *)bh_list_first_elem(&g_timer_ctx_list);
while (elem) {
uint32 next = check_app_timers(elem->timer_ctx);
if (next != (uint32)-1) {
@ -57,7 +58,7 @@ void * thread_modulers_timer_check(void * arg)
ms_to_expiry = next;
}
elem = (timer_ctx_node_t*) bh_list_elem_next(elem);
elem = (timer_ctx_node_t *)bh_list_elem_next(elem);
}
os_mutex_unlock(&g_timer_ctx_list_mutex);
@ -93,8 +94,8 @@ init_wasm_timer()
would recursive lock the mutex */
os_recursive_mutex_init(&g_timer_ctx_list_mutex);
os_thread_create(&tm_tid, thread_modulers_timer_check,
NULL, BH_APPLET_PRESERVED_STACK_SIZE);
os_thread_create(&tm_tid, thread_modulers_timer_check, NULL,
BH_APPLET_PRESERVED_STACK_SIZE);
}
void
@ -106,15 +107,15 @@ exit_wasm_timer()
timer_ctx_t
create_wasm_timer_ctx(unsigned int module_id, int prealloc_num)
{
timer_ctx_t ctx = create_timer_ctx(wasm_timer_callback,
wakeup_modules_timer_thread,
prealloc_num, module_id);
timer_ctx_t ctx =
create_timer_ctx(wasm_timer_callback, wakeup_modules_timer_thread,
prealloc_num, module_id);
if (ctx == NULL)
return NULL;
timer_ctx_node_t * node = (timer_ctx_node_t*)
wasm_runtime_malloc(sizeof(timer_ctx_node_t));
timer_ctx_node_t *node =
(timer_ctx_node_t *)wasm_runtime_malloc(sizeof(timer_ctx_node_t));
if (node == NULL) {
destroy_timer_ctx(ctx);
return NULL;
@ -132,11 +133,10 @@ create_wasm_timer_ctx(unsigned int module_id, int prealloc_num)
void
destroy_module_timer_ctx(unsigned int module_id)
{
timer_ctx_node_t* elem;
timer_ctx_node_t *elem;
os_mutex_lock(&g_timer_ctx_list_mutex);
elem = (timer_ctx_node_t*)
bh_list_first_elem(&g_timer_ctx_list);
elem = (timer_ctx_node_t *)bh_list_first_elem(&g_timer_ctx_list);
while (elem) {
if (timer_ctx_get_owner(elem->timer_ctx) == module_id) {
bh_list_remove(&g_timer_ctx_list, elem);
@ -145,7 +145,7 @@ destroy_module_timer_ctx(unsigned int module_id)
break;
}
elem = (timer_ctx_node_t*) bh_list_elem_next(elem);
elem = (timer_ctx_node_t *)bh_list_elem_next(elem);
}
os_mutex_unlock(&g_timer_ctx_list_mutex);
}
@ -153,16 +153,15 @@ destroy_module_timer_ctx(unsigned int module_id)
timer_ctx_t
get_wasm_timer_ctx(wasm_module_inst_t module_inst)
{
module_data * m = app_manager_get_module_data(Module_WASM_App,
module_inst);
module_data *m = app_manager_get_module_data(Module_WASM_App, module_inst);
if (m == NULL)
return NULL;
return m->timer_ctx;
}
timer_id_t
wasm_create_timer(wasm_exec_env_t exec_env,
int interval, bool is_period, bool auto_start)
wasm_create_timer(wasm_exec_env_t exec_env, int interval, bool is_period,
bool auto_start)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
timer_ctx_t timer_ctx = get_wasm_timer_ctx(module_inst);
@ -189,8 +188,7 @@ wasm_timer_cancel(wasm_exec_env_t exec_env, timer_id_t timer_id)
}
void
wasm_timer_restart(wasm_exec_env_t exec_env,
timer_id_t timer_id, int interval)
wasm_timer_restart(wasm_exec_env_t exec_env, timer_id_t timer_id, int interval)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
timer_ctx_t timer_ctx = get_wasm_timer_ctx(module_inst);
@ -203,4 +201,3 @@ wasm_get_sys_tick_ms(wasm_exec_env_t exec_env)
{
return (uint32)bh_get_tick_ms();
}