5 #ifndef BITCOIN_COMPAT_BYTESWAP_H 6 #define BITCOIN_COMPAT_BYTESWAP_H 8 #if defined(HAVE_CONFIG_H) 14 #if defined(HAVE_BYTESWAP_H) 20 #include <libkern/OSByteOrder.h> 21 #define bswap_16(x) OSSwapInt16(x) 22 #define bswap_32(x) OSSwapInt32(x) 23 #define bswap_64(x) OSSwapInt64(x) 28 #if HAVE_DECL_BSWAP_16 == 0 31 return (x >> 8) | (x << 8);
33 #endif // HAVE_DECL_BSWAP16 == 0 35 #if HAVE_DECL_BSWAP_32 == 0 38 return (((x & 0xff000000U) >> 24) | ((x & 0x00ff0000U) >> 8) |
39 ((x & 0x0000ff00U) << 8) | ((x & 0x000000ffU) << 24));
41 #endif // HAVE_DECL_BSWAP32 == 0 43 #if HAVE_DECL_BSWAP_64 == 0 46 return (((x & 0xff00000000000000ull) >> 56)
47 | ((x & 0x00ff000000000000ull) >> 40)
48 | ((x & 0x0000ff0000000000ull) >> 24)
49 | ((x & 0x000000ff00000000ull) >> 8)
50 | ((x & 0x00000000ff000000ull) << 8)
51 | ((x & 0x0000000000ff0000ull) << 24)
52 | ((x & 0x000000000000ff00ull) << 40)
53 | ((x & 0x00000000000000ffull) << 56));
55 #endif // HAVE_DECL_BSWAP64 == 0 57 #endif // defined(MAC_OSX) 59 #endif // BITCOIN_COMPAT_BYTESWAP_H uint32_t bswap_32(uint32_t x)
uint16_t bswap_16(uint16_t x)
uint64_t bswap_64(uint64_t x)