mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
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>
This commit is contained in:
parent
186993ee2f
commit
e73d6e3a02
1 changed files with 6 additions and 0 deletions
6
bswap.h
6
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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue