mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 20:56:13 +00:00
Fix inconsistent coding convention (#3171)
This commit is contained in:
parent
58c980c4df
commit
1429d8cc03
|
@ -6,7 +6,6 @@
|
||||||
#include "wasm_runtime_common.h"
|
#include "wasm_runtime_common.h"
|
||||||
#include "../interpreter/wasm_runtime.h"
|
#include "../interpreter/wasm_runtime.h"
|
||||||
#include "../aot/aot_runtime.h"
|
#include "../aot/aot_runtime.h"
|
||||||
#include "bh_platform.h"
|
|
||||||
#include "mem_alloc.h"
|
#include "mem_alloc.h"
|
||||||
#include "wasm_memory.h"
|
#include "wasm_memory.h"
|
||||||
|
|
||||||
|
@ -53,11 +52,11 @@ align_as_and_cast(uint64 size, uint64 alignment)
|
||||||
static bool
|
static bool
|
||||||
wasm_memory_init_with_pool(void *mem, unsigned int bytes)
|
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;
|
memory_mode = MEMORY_MODE_POOL;
|
||||||
pool_allocator = _allocator;
|
pool_allocator = allocator;
|
||||||
global_pool_size = bytes;
|
global_pool_size = bytes;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -84,18 +83,18 @@ wasm_memory_init_with_allocator(void *_user_data, void *_malloc_func,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static bool
|
static bool
|
||||||
wasm_memory_init_with_allocator(void *_malloc_func, void *_realloc_func,
|
wasm_memory_init_with_allocator(void *malloc_func_ptr, void *realloc_func_ptr,
|
||||||
void *_free_func)
|
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;
|
memory_mode = MEMORY_MODE_ALLOCATOR;
|
||||||
malloc_func = _malloc_func;
|
malloc_func = malloc_func_ptr;
|
||||||
realloc_func = _realloc_func;
|
realloc_func = realloc_func_ptr;
|
||||||
free_func = _free_func;
|
free_func = free_func_ptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LOG_ERROR("Init memory with allocator (%p, %p, %p) failed.\n", _malloc_func,
|
LOG_ERROR("Init memory with allocator (%p, %p, %p) failed.\n",
|
||||||
_realloc_func, _free_func);
|
malloc_func_ptr, realloc_func_ptr, free_func_ptr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -123,18 +122,13 @@ wasm_runtime_memory_init(mem_alloc_type_t mem_alloc_type,
|
||||||
alloc_option->pool.heap_size);
|
alloc_option->pool.heap_size);
|
||||||
}
|
}
|
||||||
else if (mem_alloc_type == Alloc_With_Allocator) {
|
else if (mem_alloc_type == Alloc_With_Allocator) {
|
||||||
|
return wasm_memory_init_with_allocator(
|
||||||
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
||||||
return wasm_memory_init_with_allocator(
|
|
||||||
alloc_option->allocator.user_data,
|
alloc_option->allocator.user_data,
|
||||||
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
|
#endif
|
||||||
|
alloc_option->allocator.malloc_func,
|
||||||
|
alloc_option->allocator.realloc_func,
|
||||||
|
alloc_option->allocator.free_func);
|
||||||
}
|
}
|
||||||
else if (mem_alloc_type == Alloc_With_System_Allocator) {
|
else if (mem_alloc_type == Alloc_With_System_Allocator) {
|
||||||
memory_mode = MEMORY_MODE_SYSTEM_ALLOCATOR;
|
memory_mode = MEMORY_MODE_SYSTEM_ALLOCATOR;
|
||||||
|
|
|
@ -3630,7 +3630,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
||||||
{
|
{
|
||||||
WASMModuleInstanceCommon *module = wasm_runtime_get_module_inst(exec_env);
|
WASMModuleInstanceCommon *module = wasm_runtime_get_module_inst(exec_env);
|
||||||
typedef void (*NativeRawFuncPtr)(WASMExecEnv *, uint64 *);
|
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;
|
uint64 argv_buf[16] = { 0 }, *argv1 = argv_buf, *argv_dst, size;
|
||||||
uint32 *argv_src = argv, i, argc1, ptr_len;
|
uint32 *argv_src = argv, i, argc1, ptr_len;
|
||||||
uint32 arg_i32;
|
uint32 arg_i32;
|
||||||
|
@ -3744,7 +3744,7 @@ wasm_runtime_invoke_native_raw(WASMExecEnv *exec_env, void *func_ptr,
|
||||||
}
|
}
|
||||||
|
|
||||||
exec_env->attachment = attachment;
|
exec_env->attachment = attachment;
|
||||||
invokeNativeRaw(exec_env, argv1);
|
invoke_native_raw(exec_env, argv1);
|
||||||
exec_env->attachment = NULL;
|
exec_env->attachment = NULL;
|
||||||
|
|
||||||
if (func_type->result_count > 0) {
|
if (func_type->result_count > 0) {
|
||||||
|
|
|
@ -232,14 +232,14 @@ destroy_wait_info(void *wait_info)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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)
|
void *address)
|
||||||
{
|
{
|
||||||
if (wait_info->wait_list->len > 0) {
|
if (wait_info->wait_list->len > 0) {
|
||||||
return;
|
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);
|
destroy_wait_info(wait_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1342,28 +1342,28 @@ exchange_uint32(uint8 *p_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
exchange_uint64(uint8 *pData)
|
exchange_uint64(uint8 *p_data)
|
||||||
{
|
{
|
||||||
uint32 value;
|
uint32 value;
|
||||||
|
|
||||||
value = *(uint32 *)pData;
|
value = *(uint32 *)p_data;
|
||||||
*(uint32 *)pData = *(uint32 *)(pData + 4);
|
*(uint32 *)p_data = *(uint32 *)(p_data + 4);
|
||||||
*(uint32 *)(pData + 4) = value;
|
*(uint32 *)(p_data + 4) = value;
|
||||||
exchange_uint32(pData);
|
exchange_uint32(p_data);
|
||||||
exchange_uint32(pData + 4);
|
exchange_uint32(p_data + 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
exchange_uint128(uint8 *pData)
|
exchange_uint128(uint8 *p_data)
|
||||||
{
|
{
|
||||||
/* swap high 64bit and low 64bit */
|
/* swap high 64bit and low 64bit */
|
||||||
uint64 value = *(uint64 *)pData;
|
uint64 value = *(uint64 *)p_data;
|
||||||
*(uint64 *)pData = *(uint64 *)(pData + 8);
|
*(uint64 *)p_data = *(uint64 *)(p_data + 8);
|
||||||
*(uint64 *)(pData + 8) = value;
|
*(uint64 *)(p_data + 8) = value;
|
||||||
/* exchange high 64bit */
|
/* exchange high 64bit */
|
||||||
exchange_uint64(pData);
|
exchange_uint64(p_data);
|
||||||
/* exchange low 64bit */
|
/* exchange low 64bit */
|
||||||
exchange_uint64(pData + 8);
|
exchange_uint64(p_data + 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static union {
|
static union {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user