Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions core/iwasm/common/wasm_runtime_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#ifndef _WASM_COMMON_H
#define _WASM_COMMON_H

#include <string.h>

#include "bh_platform.h"
#include "bh_common.h"
#include "wasm_exec_env.h"
Expand All @@ -31,6 +33,12 @@ extern "C" {
/* Internal use for setting default running mode */
#define Mode_Default 0

#define STORE_PTR(addr, ptr) \
do { \
void *val = (ptr); \
memcpy((addr), &val, sizeof(void *)); \
} while (0)

#if WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0

#define PUT_I64_TO_ADDR(addr, value) \
Expand Down Expand Up @@ -88,11 +96,6 @@ STORE_V128(void *addr, V128 value)
#define LOAD_U16(addr) (*(uint16 *)(addr))
#define LOAD_V128(addr) (*(V128 *)(addr))

#define STORE_PTR(addr, ptr) \
do { \
*(void **)addr = (void *)ptr; \
} while (0)

#else /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */

#define PUT_V128_TO_ADDR(addr, value) \
Expand Down Expand Up @@ -465,12 +468,6 @@ LOAD_I16(void *addr)
#define LOAD_U32(addr) ((uint32)LOAD_I32(addr))
#define LOAD_U16(addr) ((uint16)LOAD_I16(addr))

#if UINTPTR_MAX == UINT32_MAX
#define STORE_PTR(addr, ptr) STORE_U32(addr, (uintptr_t)ptr)
#elif UINTPTR_MAX == UINT64_MAX
#define STORE_PTR(addr, ptr) STORE_I64(addr, (uintptr_t)ptr)
#endif

#endif /* WASM_CPU_SUPPORTS_UNALIGNED_ADDR_ACCESS != 0 */

#if WASM_ENABLE_SHARED_MEMORY != 0
Expand Down
Loading