From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOL5U-0004DY-U9 for qemu-devel@nongnu.org; Wed, 17 Oct 2012 00:18:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOL5T-00016u-RU for qemu-devel@nongnu.org; Wed, 17 Oct 2012 00:18:32 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:58808) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOL5T-00016W-LN for qemu-devel@nongnu.org; Wed, 17 Oct 2012 00:18:31 -0400 Received: by mail-pa0-f45.google.com with SMTP id fb10so6633126pad.4 for ; Tue, 16 Oct 2012 21:18:31 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Wed, 17 Oct 2012 14:17:15 +1000 Message-Id: <1350447438-8603-2-git-send-email-rth@twiddle.net> In-Reply-To: <1350447438-8603-1-git-send-email-rth@twiddle.net> References: <1350447438-8603-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH 1/4] cpu-all: Add unaligned load/store helper functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Riku Voipio Signed-off-by: Richard Henderson --- cpu-all.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/cpu-all.h b/cpu-all.h index 2b99682..2db4414 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -113,6 +113,44 @@ static inline void tswap64s(uint64_t *s) #define bswaptls(s) bswap64s(s) #endif +/* Unaligned loads and stores. */ + +static inline uint16_t unaligned_r16(const void *ptr) +{ + uint16_t ret; + memcpy(&ret, ptr, sizeof(ret)); + return ret; +} + +static inline uint32_t unaligned_r32(const void *ptr) +{ + uint32_t ret; + memcpy(&ret, ptr, sizeof(ret)); + return ret; +} + +static inline uint64_t unaligned_r64(const void *ptr) +{ + uint64_t ret; + memcpy(&ret, ptr, sizeof(ret)); + return ret; +} + +static inline void unaligned_w16(void *ptr, uint16_t v) +{ + memcpy(ptr, &v, sizeof(v)); +} + +static inline void unaligned_w32(void *ptr, uint32_t v) +{ + memcpy(ptr, &v, sizeof(v)); +} + +static inline void unaligned_w64(void *ptr, uint64_t v) +{ + memcpy(ptr, &v, sizeof(v)); +} + /* CPU memory access without any memory or io remapping */ /* -- 1.7.11.7