hardware cursor depth = 15 fix
[qemu.git] / bswap.h
blob0df6efcb4d66d6d7607f139aec65f9d88979f1b1
1 #ifndef BSWAP_H
2 #define BSWAP_H
4 #include "config-host.h"
6 #include <inttypes.h>
8 #ifdef HAVE_BYTESWAP_H
9 #include <byteswap.h>
10 #else
12 #define bswap_16(x) \
13 ({ \
14 uint16_t __x = (x); \
15 ((uint16_t)( \
16 (((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
17 (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
20 #define bswap_32(x) \
21 ({ \
22 uint32_t __x = (x); \
23 ((uint32_t)( \
24 (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
25 (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
26 (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
27 (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
30 #define bswap_64(x) \
31 ({ \
32 uint64_t __x = (x); \
33 ((uint64_t)( \
34 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
35 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
36 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
37 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
38 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
39 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
40 (uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
41 (uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
44 #endif /* !HAVE_BYTESWAP_H */
46 static inline uint16_t bswap16(uint16_t x)
48 return bswap_16(x);
51 static inline uint32_t bswap32(uint32_t x)
53 return bswap_32(x);
56 static inline uint64_t bswap64(uint64_t x)
58 return bswap_64(x);
61 static inline void bswap16s(uint16_t *s)
63 *s = bswap16(*s);
66 static inline void bswap32s(uint32_t *s)
68 *s = bswap32(*s);
71 static inline void bswap64s(uint64_t *s)
73 *s = bswap64(*s);
76 #endif /* BSWAP_H */