mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-04 10:07:27 -05:00
1a445343f6
-BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
66 lines
1.8 KiB
C
66 lines
1.8 KiB
C
// Copyright (c) 2014-2016 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_COMPAT_BYTESWAP_H
|
|
#define BITCOIN_COMPAT_BYTESWAP_H
|
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
#include <config/bitcoin-config.h>
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
|
|
#if defined(HAVE_BYTESWAP_H)
|
|
#include <byteswap.h>
|
|
#endif
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
#if !defined(bswap_16)
|
|
|
|
// Mac OS X / Darwin features; we include a check for bswap_16 because if it is already defined, protobuf has
|
|
// defined these macros for us already; if it isn't, we do it ourselves. In either case, we get the exact same
|
|
// result regardless which path was taken
|
|
#include <libkern/OSByteOrder.h>
|
|
#define bswap_16(x) OSSwapInt16(x)
|
|
#define bswap_32(x) OSSwapInt32(x)
|
|
#define bswap_64(x) OSSwapInt64(x)
|
|
|
|
#endif // !defined(bswap_16)
|
|
|
|
#else
|
|
// Non-Mac OS X / non-Darwin
|
|
|
|
#if HAVE_DECL_BSWAP_16 == 0
|
|
inline uint16_t bswap_16(uint16_t x)
|
|
{
|
|
return (x >> 8) | (x << 8);
|
|
}
|
|
#endif // HAVE_DECL_BSWAP16
|
|
|
|
#if HAVE_DECL_BSWAP_32 == 0
|
|
inline uint32_t bswap_32(uint32_t x)
|
|
{
|
|
return (((x & 0xff000000U) >> 24) | ((x & 0x00ff0000U) >> 8) |
|
|
((x & 0x0000ff00U) << 8) | ((x & 0x000000ffU) << 24));
|
|
}
|
|
#endif // HAVE_DECL_BSWAP32
|
|
|
|
#if HAVE_DECL_BSWAP_64 == 0
|
|
inline uint64_t bswap_64(uint64_t x)
|
|
{
|
|
return (((x & 0xff00000000000000ull) >> 56)
|
|
| ((x & 0x00ff000000000000ull) >> 40)
|
|
| ((x & 0x0000ff0000000000ull) >> 24)
|
|
| ((x & 0x000000ff00000000ull) >> 8)
|
|
| ((x & 0x00000000ff000000ull) << 8)
|
|
| ((x & 0x0000000000ff0000ull) << 24)
|
|
| ((x & 0x000000000000ff00ull) << 40)
|
|
| ((x & 0x00000000000000ffull) << 56));
|
|
}
|
|
#endif // HAVE_DECL_BSWAP64
|
|
|
|
#endif // defined(__APPLE__)
|
|
|
|
#endif // BITCOIN_COMPAT_BYTESWAP_H
|