6 #ifndef RAVEN_COMPAT_BYTESWAP_H 7 #define RAVEN_COMPAT_BYTESWAP_H 9 #if defined(HAVE_CONFIG_H) 15 #if defined(HAVE_BYTESWAP_H) 19 #if defined(__APPLE__) 21 #if !defined(bswap_16) 26 #include <libkern/OSByteOrder.h> 27 #define bswap_16(x) OSSwapInt16(x) 28 #define bswap_32(x) OSSwapInt32(x) 29 #define bswap_64(x) OSSwapInt64(x) 31 #endif // !defined(bswap_16) 36 #if HAVE_DECL_BSWAP_16 == 0 39 return (x >> 8) | (x << 8);
41 #endif // HAVE_DECL_BSWAP16 43 #if HAVE_DECL_BSWAP_32 == 0 46 return (((x & 0xff000000U) >> 24) | ((x & 0x00ff0000U) >> 8) |
47 ((x & 0x0000ff00U) << 8) | ((x & 0x000000ffU) << 24));
49 #endif // HAVE_DECL_BSWAP32 51 #if HAVE_DECL_BSWAP_64 == 0 54 return (((x & 0xff00000000000000ull) >> 56)
55 | ((x & 0x00ff000000000000ull) >> 40)
56 | ((x & 0x0000ff0000000000ull) >> 24)
57 | ((x & 0x000000ff00000000ull) >> 8)
58 | ((x & 0x00000000ff000000ull) << 8)
59 | ((x & 0x0000000000ff0000ull) << 24)
60 | ((x & 0x000000000000ff00ull) << 40)
61 | ((x & 0x00000000000000ffull) << 56));
63 #endif // HAVE_DECL_BSWAP64 65 #endif // defined(__APPLE__) 67 #endif // RAVEN_COMPAT_BYTESWAP_H uint32_t bswap_32(uint32_t x)
uint16_t bswap_16(uint16_t x)
uint64_t bswap_64(uint64_t x)