qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/4] cpu-all: Add unaligned load/store helper functi


From: Richard Henderson
Subject: [Qemu-devel] [PATCH 1/4] cpu-all: Add unaligned load/store helper functions
Date: Wed, 17 Oct 2012 14:17:15 +1000

Signed-off-by: Richard Henderson <address@hidden>
---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]