提交 4387345a 编写于 作者: P Peter Maydell 提交者: Richard Henderson

tcg: Avoid stores to unaligned addresses

Avoid stores to unaligned addresses in TCG code generation, by using the
usual memcpy() approach. (Using bswap.h would drag a lot of QEMU baggage
into TCG, so it's simpler just to do direct memcpy() here.)
Reviewed-by: NAlex Bennée <alex.bennee@linaro.org>
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: NRichard Henderson <rth@twiddle.net>
上级 86360ad7
......@@ -125,21 +125,21 @@ static inline void tcg_out8(TCGContext *s, uint8_t v)
static inline void tcg_out16(TCGContext *s, uint16_t v)
{
uint8_t *p = s->code_ptr;
*(uint16_t *)p = v;
memcpy(p, &v, sizeof(v));
s->code_ptr = p + 2;
}
static inline void tcg_out32(TCGContext *s, uint32_t v)
{
uint8_t *p = s->code_ptr;
*(uint32_t *)p = v;
memcpy(p, &v, sizeof(v));
s->code_ptr = p + 4;
}
static inline void tcg_out64(TCGContext *s, uint64_t v)
{
uint8_t *p = s->code_ptr;
*(uint64_t *)p = v;
memcpy(p, &v, sizeof(v));
s->code_ptr = p + 8;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册