Apply clang-format for core/iwasm compilation and libraries (#784)

Apply clang-format for core/iwasm/compilation and core/iwasm/libraries files.
Add wasm-c-api empty_imports sample to workflow test.
And enable triggering workflow when core/config.h changes.
This commit is contained in:
Wenyong Huang
2021-10-13 15:13:00 +08:00
committed by GitHub
parent dc65d2910a
commit fb4afc7ca4
87 changed files with 9321 additions and 9829 deletions

View File

@ -7,7 +7,6 @@
typedef struct {
bh_list_link l;
void (*destroy_cb)(WASMCluster *);
} DestroyCallBackNode;
@ -133,8 +132,7 @@ wasm_cluster_create(WASMExecEnv *exec_env)
}
/* Prepare the aux stack top and size for every thread */
if (!wasm_exec_env_get_aux_stack(exec_env,
&aux_stack_start,
if (!wasm_exec_env_get_aux_stack(exec_env, &aux_stack_start,
&aux_stack_size)) {
LOG_VERBOSE("No aux stack info for this module, can't create thread");
@ -167,13 +165,13 @@ wasm_cluster_create(WASMExecEnv *exec_env)
total_size = cluster_max_thread_num * sizeof(uint32);
if (total_size >= UINT32_MAX
|| !(cluster->stack_tops =
wasm_runtime_malloc((uint32)total_size))) {
wasm_runtime_malloc((uint32)total_size))) {
goto fail;
}
memset(cluster->stack_tops, 0, (uint32)total_size);
if (!(cluster->stack_segment_occupied =
wasm_runtime_malloc(cluster_max_thread_num * sizeof(bool)))) {
wasm_runtime_malloc(cluster_max_thread_num * sizeof(bool)))) {
goto fail;
}
memset(cluster->stack_segment_occupied, 0,
@ -215,8 +213,8 @@ destroy_cluster_visitor(void *node, void *user_data)
void
wasm_cluster_destroy(WASMCluster *cluster)
{
traverse_list(destroy_callback_list,
destroy_cluster_visitor, (void *)cluster);
traverse_list(destroy_callback_list, destroy_cluster_visitor,
(void *)cluster);
/* Remove the cluster from the cluster list */
os_mutex_lock(&cluster_list_lock);
@ -302,7 +300,7 @@ wasm_cluster_search_exec_env(WASMCluster *cluster,
}
/* search the global cluster list to find if the given
module instance have a corresponding exec_env */
module instance have a corresponding exec_env */
WASMExecEnv *
wasm_clusters_search_exec_env(WASMModuleInstanceCommon *module_inst)
{
@ -338,21 +336,19 @@ wasm_cluster_spawn_exec_env(WASMExecEnv *exec_env)
return NULL;
}
if (!(new_module_inst =
wasm_runtime_instantiate_internal(module, true, 8192,
0, NULL, 0))) {
if (!(new_module_inst = wasm_runtime_instantiate_internal(
module, true, 8192, 0, NULL, 0))) {
return NULL;
}
if (module_inst) {
/* Set custom_data to new module instance */
wasm_runtime_set_custom_data_internal(
new_module_inst,
wasm_runtime_get_custom_data(module_inst));
new_module_inst, wasm_runtime_get_custom_data(module_inst));
}
new_exec_env = wasm_exec_env_create_internal(
new_module_inst, exec_env->wasm_stack_size);
new_exec_env = wasm_exec_env_create_internal(new_module_inst,
exec_env->wasm_stack_size);
if (!new_exec_env)
goto fail1;
@ -400,7 +396,7 @@ wasm_cluster_destroy_spawned_exec_env(WASMExecEnv *exec_env)
}
/* start routine of thread manager */
static void*
static void *
thread_manager_start_routine(void *arg)
{
void *ret;
@ -432,8 +428,7 @@ thread_manager_start_routine(void *arg)
int32
wasm_cluster_create_thread(WASMExecEnv *exec_env,
wasm_module_inst_t module_inst,
void* (*thread_routine)(void *),
void *arg)
void *(*thread_routine)(void *), void *arg)
{
WASMCluster *cluster;
WASMExecEnv *new_exec_env;
@ -443,8 +438,8 @@ wasm_cluster_create_thread(WASMExecEnv *exec_env,
cluster = wasm_exec_env_get_cluster(exec_env);
bh_assert(cluster);
new_exec_env = wasm_exec_env_create_internal(
module_inst, exec_env->wasm_stack_size);
new_exec_env =
wasm_exec_env_create_internal(module_inst, exec_env->wasm_stack_size);
if (!new_exec_env)
return -1;
@ -466,9 +461,10 @@ wasm_cluster_create_thread(WASMExecEnv *exec_env,
new_exec_env->thread_start_routine = thread_routine;
new_exec_env->thread_arg = arg;
if (0 != os_thread_create(&tid, thread_manager_start_routine,
(void *)new_exec_env,
APP_THREAD_STACK_SIZE_DEFAULT)) {
if (0
!= os_thread_create(&tid, thread_manager_start_routine,
(void *)new_exec_env,
APP_THREAD_STACK_SIZE_DEFAULT)) {
goto fail3;
}
@ -520,9 +516,10 @@ wasm_cluster_destroy_exenv_status(WASMCurrentEnvStatus *status)
}
inline static bool
wasm_cluster_thread_is_running(WASMExecEnv *exec_env) {
return exec_env->current_status->running_status == STATUS_RUNNING
|| exec_env->current_status->running_status == STATUS_STEP;
wasm_cluster_thread_is_running(WASMExecEnv *exec_env)
{
return exec_env->current_status->running_status == STATUS_RUNNING
|| exec_env->current_status->running_status == STATUS_STEP;
}
void
@ -532,7 +529,7 @@ wasm_cluster_clear_thread_signal(WASMExecEnv *exec_env)
}
void
wasm_cluster_wait_thread_status(WASMExecEnv *exec_env, uint32 * status)
wasm_cluster_wait_thread_status(WASMExecEnv *exec_env, uint32 *status)
{
os_mutex_lock(&exec_env->current_status->wait_lock);
while (wasm_cluster_thread_is_running(exec_env)) {
@ -576,21 +573,23 @@ wasm_cluster_send_signal_all(WASMCluster *cluster, uint32 signo)
}
}
void wasm_cluster_thread_exited(WASMExecEnv *exec_env)
void
wasm_cluster_thread_exited(WASMExecEnv *exec_env)
{
exec_env->current_status->running_status = STATUS_EXIT;
os_cond_signal(&exec_env->current_status->wait_cond);
}
void wasm_cluster_thread_continue(WASMExecEnv *exec_env)
void
wasm_cluster_thread_continue(WASMExecEnv *exec_env)
{
wasm_cluster_clear_thread_signal(exec_env);
exec_env->current_status->running_status = STATUS_RUNNING;
os_cond_signal(&exec_env->wait_cond);
}
void wasm_cluster_thread_step(WASMExecEnv *exec_env)
void
wasm_cluster_thread_step(WASMExecEnv *exec_env)
{
exec_env->current_status->running_status = STATUS_STEP;
os_cond_signal(&exec_env->wait_cond);
@ -654,12 +653,12 @@ wasm_cluster_cancel_thread(WASMExecEnv *exec_env)
{
/* Set the termination flag */
#if WASM_ENABLE_DEBUG_INTERP != 0
wasm_cluster_thread_send_signal(exec_env, WAMR_SIG_TERM);
wasm_cluster_thread_exited(exec_env);
wasm_cluster_thread_send_signal(exec_env, WAMR_SIG_TERM);
wasm_cluster_thread_exited(exec_env);
#else
exec_env->suspend_flags.flags |= 0x01;
#endif
return 0;
return 0;
}
static void
@ -678,16 +677,15 @@ terminate_thread_visitor(void *node, void *user_data)
void
wasm_cluster_terminate_all(WASMCluster *cluster)
{
traverse_list(&cluster->exec_env_list,
terminate_thread_visitor, NULL);
traverse_list(&cluster->exec_env_list, terminate_thread_visitor, NULL);
}
void
wasm_cluster_terminate_all_except_self(WASMCluster *cluster,
WASMExecEnv *exec_env)
{
traverse_list(&cluster->exec_env_list,
terminate_thread_visitor, (void *)exec_env);
traverse_list(&cluster->exec_env_list, terminate_thread_visitor,
(void *)exec_env);
}
bool
@ -726,16 +724,15 @@ suspend_thread_visitor(void *node, void *user_data)
void
wasm_cluster_suspend_all(WASMCluster *cluster)
{
traverse_list(&cluster->exec_env_list,
suspend_thread_visitor, NULL);
traverse_list(&cluster->exec_env_list, suspend_thread_visitor, NULL);
}
void
wasm_cluster_suspend_all_except_self(WASMCluster *cluster,
WASMExecEnv *exec_env)
{
traverse_list(&cluster->exec_env_list,
suspend_thread_visitor, (void *)exec_env);
traverse_list(&cluster->exec_env_list, suspend_thread_visitor,
(void *)exec_env);
}
void
@ -765,8 +762,7 @@ set_exception_visitor(void *node, void *user_data)
WASMExecEnv *curr_exec_env = (WASMExecEnv *)node;
WASMExecEnv *exec_env = (WASMExecEnv *)user_data;
WASMModuleInstanceCommon *module_inst = get_module_inst(exec_env);
WASMModuleInstanceCommon *curr_module_inst =
get_module_inst(curr_exec_env);
WASMModuleInstanceCommon *curr_module_inst = get_module_inst(curr_exec_env);
const char *exception = wasm_runtime_get_exception(module_inst);
/* skip "Exception: " */
exception += 11;
@ -806,7 +802,6 @@ wasm_cluster_spread_custom_data(WASMModuleInstanceCommon *module_inst,
cluster = wasm_exec_env_get_cluster(exec_env);
bh_assert(cluster);
traverse_list(&cluster->exec_env_list,
set_custom_data_visitor,
traverse_list(&cluster->exec_env_list, set_custom_data_visitor,
custom_data);
}