Skip to content

Commit

Permalink
bwap: add qemu_bswap helper
Browse files Browse the repository at this point in the history
add helper that can swap values of 4, 2, 1 bytes

Signed-off-by: Michael S. Tsirkin <[email protected]>
  • Loading branch information
mstsirkin committed Feb 14, 2010
1 parent 186993e commit e73d6e3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit e73d6e3

Please sign in to comment.