diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2010-01-14 15:58:52 +0200 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2010-02-14 16:10:53 +0200 |
commit | e73d6e3a028c777e642c687d433db914d8be8679 (patch) | |
tree | ca1f43dec86460ebb9fac7231dfb738a93c9a62c | |
parent | 186993ee2fec8da1dc7d9ca15df295ab76a5b789 (diff) |
bwap: add qemu_bswap helper
add helper that can swap values of 4, 2, 1 bytes
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | bswap.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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 */ |