From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46308) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV5gt-0000pX-Sz for qemu-devel@nongnu.org; Tue, 01 Apr 2014 16:53:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WV5gn-0007VV-Vb for qemu-devel@nongnu.org; Tue, 01 Apr 2014 16:53:51 -0400 Received: from mail-qg0-x22f.google.com ([2607:f8b0:400d:c04::22f]:39056) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WV5gn-0007VQ-Qv for qemu-devel@nongnu.org; Tue, 01 Apr 2014 16:53:45 -0400 Received: by mail-qg0-f47.google.com with SMTP id 63so9563341qgz.20 for ; Tue, 01 Apr 2014 13:53:45 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Tue, 1 Apr 2014 13:53:27 -0700 Message-Id: <1396385614-19267-3-git-send-email-rth@twiddle.net> In-Reply-To: <1396385614-19267-1-git-send-email-rth@twiddle.net> References: <1396385614-19267-1-git-send-email-rth@twiddle.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v2 2/9] tcg: Avoid stores to unaligned addresses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org From: Peter Maydell 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 Signed-off-by: Peter Maydell Signed-off-by: Richard Henderson --- 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