2 * Lame bswap replacements as we can't assume the host is sane and provides
3 * working versions of these.
10 # include <byteswap.h>
13 static __inline__
uint16_t bswap_16(uint16_t x
)
15 return ((((x
) & 0xff00) >> 8) | \
16 (((x
) & 0x00ff) << 8));
18 static __inline__
uint32_t bswap_32(uint32_t x
)
20 return ((((x
) & 0xff000000) >> 24) | \
21 (((x
) & 0x00ff0000) >> 8) | \
22 (((x
) & 0x0000ff00) << 8) | \
23 (((x
) & 0x000000ff) << 24));
25 static __inline__
uint64_t bswap_64(uint64_t x
)
27 #define _uswap_64(x, sfx) \
28 return ((((x) & 0xff00000000000000##sfx) >> 56) | \
29 (((x) & 0x00ff000000000000##sfx) >> 40) | \
30 (((x) & 0x0000ff0000000000##sfx) >> 24) | \
31 (((x) & 0x000000ff00000000##sfx) >> 8) | \
32 (((x) & 0x00000000ff000000##sfx) << 8) | \
33 (((x) & 0x0000000000ff0000##sfx) << 24) | \
34 (((x) & 0x000000000000ff00##sfx) << 40) | \
35 (((x) & 0x00000000000000ff##sfx) << 56));