qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCHv2 1/3] bwap: add qemu_bswap helper


From: Michael S. Tsirkin
Subject: [Qemu-devel] [PATCHv2 1/3] bwap: add qemu_bswap helper
Date: Mon, 18 Jan 2010 12:56:30 +0200
User-agent: Mutt/1.5.19 (2009-01-05)

add helper that can swap values of 4, 2, 1 bytes

Signed-off-by: Michael S. Tsirkin <address@hidden>
---
 bswap.h |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/bswap.h b/bswap.h
index 4558704..aace9b7 100644
--- a/bswap.h
+++ b/bswap.h
@@ -214,4 +214,10 @@ static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
 #undef le_bswaps
 #undef be_bswaps
 
+/* len must be one of 1, 2, 4 */
+static inline uint32_t qemu_bswap_len(uint32_t value, int len)
+{
+    return bswap32(value) >> (32 - 8 * len);
+}
+
 #endif /* BSWAP_H */
-- 
1.6.6.144.g5c3af





reply via email to

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