4 #if !defined(__BYTE_ORDER) && defined(BYTE_ORDER)
5 # define __BYTE_ORDER = BYTE_ORDER
12 #define __LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
13 #define __BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
14 #define __PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */
16 #if defined(sun386) || defined(i386)
17 #define __BYTE_ORDER __LITTLE_ENDIAN
21 #define __BYTE_ORDER __BIG_ENDIAN
24 #endif /* __linux__ */
25 #endif /* __BYTE_ORDER */
29 # error "Undefined __BYTE_ORDER"
36 static inline uint16_t bswap_16(uint16_t x)
38 return ((((x) & 0xff00) >> 8) | \
39 (((x) & 0x00ff) << 8));
41 static inline uint32_t bswap_32(uint32_t x)
43 return ((((x) & 0xff000000) >> 24) | \
44 (((x) & 0x00ff0000) >> 8) | \
45 (((x) & 0x0000ff00) << 8) | \
46 (((x) & 0x000000ff) << 24));