Skip to content

Commit

Permalink
Fix inconsistent coding convention (bytecodealliance#3171)
Browse files Browse the repository at this point in the history
  • Loading branch information
no1wudi authored Feb 22, 2024
1 parent edbf214 commit 87d09bb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 35 deletions.
32 changes: 13 additions & 19 deletions core/iwasm/common/wasm_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "wasm_runtime_common.h"
#include "../interpreter/wasm_runtime.h"
#include "../aot/aot_runtime.h"
#include "bh_platform.h"
#include "mem_alloc.h"
#include "wasm_memory.h"

Expand Down Expand Up @@ -53,11 +52,11 @@ align_as_and_cast(uint64 size, uint64 alignment)
static bool
wasm_memory_init_with_pool(void *mem, unsigned int bytes)
{
mem_allocator_t _allocator = mem_allocator_create(mem, bytes);
mem_allocator_t allocator = mem_allocator_create(mem, bytes);

if (_allocator) {
if (allocator) {
memory_mode = MEMORY_MODE_POOL;
pool_allocator = _allocator;
pool_allocator = allocator;
global_pool_size = bytes;
return true;
}
Expand All @@ -84,18 +83,18 @@ wasm_memory_init_with_allocator(void *_user_data, void *_malloc_func,
}
#else
static bool
wasm_memory_init_with_allocator(void *_malloc_func, void *_realloc_func,
void *_free_func)
wasm_memory_init_with_allocator(void *malloc_func_ptr, void *realloc_func_ptr,
void *free_func_ptr)
{
if (_malloc_func && _free_func && _malloc_func != _free_func) {
if (malloc_func_ptr && free_func_ptr && malloc_func_ptr != free_func_ptr) {
memory_mode = MEMORY_MODE_ALLOCATOR;
malloc_func = _malloc_func;
realloc_func = _realloc_func;
free_func = _free_func;
malloc_func = malloc_func_ptr;
realloc_func = realloc_func_ptr;
free_func = free_func_ptr;
return true;
}
LOG_ERROR("Init memory with allocator (%p, %p, %p) failed.\n", _malloc_func,
_realloc_func, _free_func);
LOG_ERROR("Init memory with allocator (%p, %p, %p) failed.\n",
malloc_func_ptr, realloc_func_ptr, free_func_ptr);
return false;
}
#endif
Expand Down Expand Up @@ -123,18 +122,13 @@ wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type,
alloc_option->pool.heap_size);
}
else if (mem_alloc_type == Alloc_With_Allocator) {
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
return wasm_memory_init_with_allocator(
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
alloc_option->allocator.user_data,
#endif
alloc_option->allocator.malloc_func,
alloc_option->allocator.realloc_func,
alloc_option->allocator.free_func);
#else
return wasm_memory_init_with_allocator(
alloc_option->allocator.malloc_func,
alloc_option->allocator.realloc_func,
alloc_option->allocator.free_func);
#endif
}
else if (mem_alloc_type == Alloc_With_System_Allocator) {
memory_mode = MEMORY_MODE_SYSTEM_ALLOCATOR;
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/common/wasm_runtime_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -3630,7 +3630,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
{
WASMModuleInstanceCommon *module = wasm_runtime_get_module_inst(exec_env);
typedef void (*NativeRawFuncPtr)(WASMExecEnv *, uint64 *);
NativeRawFuncPtr invokeNativeRaw = (NativeRawFuncPtr)func_ptr;
NativeRawFuncPtr invoke_native_raw = (NativeRawFuncPtr)func_ptr;
uint64 argv_buf[16] = { 0 }, *argv1 = argv_buf, *argv_dst, size;
uint32 *argv_src = argv, i, argc1, ptr_len;
uint32 arg_i32;
Expand Down Expand Up @@ -3744,7 +3744,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
}

exec_env->attachment = attachment;
invokeNativeRaw(exec_env, argv1);
invoke_native_raw(exec_env, argv1);
exec_env->attachment = NULL;

if (func_type->result_count > 0) {
Expand Down
4 changes: 2 additions & 2 deletions core/iwasm/common/wasm_shared_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,14 @@ destroy_wait_info(void *wait_info)
}

static void
map_try_release_wait_info(HashMap *wait_map_, AtomicWaitInfo *wait_info,
map_try_release_wait_info(HashMap *wait_hash_map, AtomicWaitInfo *wait_info,
void *address)
{
if (wait_info->wait_list->len > 0) {
return;
}

bh_hash_map_remove(wait_map_, address, NULL, NULL);
bh_hash_map_remove(wait_hash_map, address, NULL, NULL);
destroy_wait_info(wait_info);
}

Expand Down
24 changes: 12 additions & 12 deletions core/iwasm/compilation/aot_emit_aot_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1342,28 +1342,28 @@ exchange_uint32(uint8 *p_data)
}

static void
exchange_uint64(uint8 *pData)
exchange_uint64(uint8 *p_data)
{
uint32 value;

value = *(uint32 *)pData;
*(uint32 *)pData = *(uint32 *)(pData + 4);
*(uint32 *)(pData + 4) = value;
exchange_uint32(pData);
exchange_uint32(pData + 4);
value = *(uint32 *)p_data;
*(uint32 *)p_data = *(uint32 *)(p_data + 4);
*(uint32 *)(p_data + 4) = value;
exchange_uint32(p_data);
exchange_uint32(p_data + 4);
}

static void
exchange_uint128(uint8 *pData)
exchange_uint128(uint8 *p_data)
{
/* swap high 64bit and low 64bit */
uint64 value = *(uint64 *)pData;
*(uint64 *)pData = *(uint64 *)(pData + 8);
*(uint64 *)(pData + 8) = value;
uint64 value = *(uint64 *)p_data;
*(uint64 *)p_data = *(uint64 *)(p_data + 8);
*(uint64 *)(p_data + 8) = value;
/* exchange high 64bit */
exchange_uint64(pData);
exchange_uint64(p_data);
/* exchange low 64bit */
exchange_uint64(pData + 8);
exchange_uint64(p_data + 8);
}

static union {
Expand Down

0 comments on commit 87d09bb

Please sign in to comment.