qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@iki.fi>
Subject: [Qemu-devel] [PATCH 1/4] cpu-all: Add unaligned load/store helper functions
Date: Wed, 17 Oct 2012 14:17:15 +1000	[thread overview]
Message-ID: <1350447438-8603-2-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1350447438-8603-1-git-send-email-rth@twiddle.net>

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 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	other threads:[~2012-10-17  4:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-17  4:17 [Qemu-devel] [PATCH 0/4] linux-user improvements Richard Henderson
2012-10-17  4:17 ` Richard Henderson [this message]
2012-10-19 16:52   ` [Qemu-devel] [PATCH 1/4] cpu-all: Add unaligned load/store helper functions Blue Swirl
2012-10-17  4:17 ` [Qemu-devel] [PATCH 2/4] linux-user: Rewrite __get_user/__put_user with __builtin_choose_expr Richard Henderson
2012-10-17  4:17 ` [Qemu-devel] [PATCH 3/4] alpha-linux-user: Fix sigaction Richard Henderson
2012-10-17  4:17 ` [Qemu-devel] [PATCH 4/4] user: Consider symbolic links as possible directories Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350447438-8603-2-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).