From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZ9L-0004Is-8j for qemu-devel@nongnu.org; Fri, 28 Mar 2014 11:56:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTZ9K-0002oT-5s for qemu-devel@nongnu.org; Fri, 28 Mar 2014 11:56:55 -0400 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:47189) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZ9J-0002o7-W1 for qemu-devel@nongnu.org; Fri, 28 Mar 2014 11:56:54 -0400 From: Peter Maydell Date: Fri, 28 Mar 2014 15:29:47 +0000 Message-Id: <1396020588-2137-3-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1396020588-2137-1-git-send-email-peter.maydell@linaro.org> References: <1396020588-2137-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [RFC 2/3] tcg: Avoid stores to unaligned addresses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Richard Henderson , patches@linaro.org 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.) Signed-off-by: Peter Maydell --- tcg/tcg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index f1e0763..60f06c5 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; } -- 1.9.0