5 #ifndef BITCOIN_COMPAT_BYTESWAP_H
6 #define BITCOIN_COMPAT_BYTESWAP_H
8 #if defined(HAVE_CONFIG_H)
9 #include <config/bitcoin-config.h>
14 #if defined(HAVE_BYTESWAP_H)
20 #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)
36 #if HAVE_DECL_BSWAP_16 == 0
38 return (x >> 8) | (x << 8);
42 #if HAVE_DECL_BSWAP_32 == 0
44 return (((x & 0xff000000U) >> 24) | ((x & 0x00ff0000U) >> 8) |
45 ((x & 0x0000ff00U) << 8) | ((x & 0x000000ffU) << 24));
49 #if HAVE_DECL_BSWAP_64 == 0
51 return (((x & 0xff00000000000000ull) >> 56) |
52 ((x & 0x00ff000000000000ull) >> 40) |
53 ((x & 0x0000ff0000000000ull) >> 24) |
54 ((x & 0x000000ff00000000ull) >> 8) |
55 ((x & 0x00000000ff000000ull) << 8) |
56 ((x & 0x0000000000ff0000ull) << 24) |
57 ((x & 0x000000000000ff00ull) << 40) |
58 ((x & 0x00000000000000ffull) << 56));
uint16_t bswap_16(uint16_t x)
uint64_t bswap_64(uint64_t x)
uint32_t bswap_32(uint32_t x)