summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-03-28 15:29:47 +0000
committerRichard Henderson <rth@twiddle.net>2014-05-12 10:03:04 -0700
commit4387345a962284c77435a9644d528d2356adecc5 (patch)
tree7f87db3e24c4a169ad573472dd9413cf88ed1a5a
parent86360ad71df0070283469b8ae59f33cdd013501d (diff)
downloadqemu-4387345a962284c77435a9644d528d2356adecc5.tar.gz
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: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
-rw-r--r--tcg/tcg.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tcg/tcg.c b/tcg/tcg.c
index e71f7a0975..293f00bc5a 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -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;
}