fix unaligned 64bit access on MCU (#192)

This commit is contained in:
Xu Jun
2020-03-10 11:48:28 +08:00
committed by GitHub
parent 180ee4c78a
commit 381859d530
2 changed files with 14 additions and 9 deletions

View File

@ -534,13 +534,16 @@ read_leb(const uint8 *buf, uint32 *p_offset, uint32 maxbits, bool sign)
#if WASM_CPU_SUPPORTS_UNALIGNED_64BIT_ACCESS != 0
#define DEF_OP_NUMERIC_64 DEF_OP_NUMERIC
#else
#define DEF_OP_NUMERIC_64(src_type1, src_type2, src_op_type, operation) do {\
src_type1 val1; \
src_type2 val2; \
val1 = (src_type1)GET_##src_op_type##_FROM_ADDR(frame_ip + 2); \
val2 = (src_type2)GET_##src_op_type##_FROM_ADDR(frame_ip); \
val1 operation##= val2; \
PUT_##src_op_type##_TO_ADDR(frame_ip + 4, val1); \
#define DEF_OP_NUMERIC_64(src_type1, src_type2, src_op_type, operation) do { \
src_type1 val1; \
src_type2 val2; \
val1 = \
(src_type1)GET_##src_op_type##_FROM_ADDR(frame_lp + (*(int16*)(frame_ip + 2))); \
val2 = \
(src_type2)GET_##src_op_type##_FROM_ADDR(frame_lp + (*(int16*)(frame_ip))); \
val1 operation##= val2; \
PUT_##src_op_type##_TO_ADDR(frame_lp + (*(int16*)(frame_ip + 4)), val1); \
frame_ip += 6; \
} while (0)
#endif