/Users/eugenesiegel/btc/bitcoin/src/compat/endian.h
| Line | Count | Source (jump to first uncovered line) | 
| 1 |  | // Copyright (c) 2014-2022 The Bitcoin Core developers | 
| 2 |  | // Distributed under the MIT software license, see the accompanying | 
| 3 |  | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | 
| 4 |  |  | 
| 5 |  | #ifndef BITCOIN_COMPAT_ENDIAN_H | 
| 6 |  | #define BITCOIN_COMPAT_ENDIAN_H | 
| 7 |  |  | 
| 8 |  | #include <compat/byteswap.h> | 
| 9 |  |  | 
| 10 |  | #include <bit> | 
| 11 |  | #include <cstdint> | 
| 12 |  |  | 
| 13 |  | inline BSWAP_CONSTEXPR uint16_t htobe16_internal(uint16_t host_16bits) | 
| 14 | 0 | { | 
| 15 | 0 |     if constexpr (std::endian::native == std::endian::little) return internal_bswap_16(host_16bits); | 
| 16 |  |         else return host_16bits; | 
| 17 | 0 | } | 
| 18 |  | inline BSWAP_CONSTEXPR uint16_t htole16_internal(uint16_t host_16bits) | 
| 19 | 0 | { | 
| 20 |  |     if constexpr (std::endian::native == std::endian::big) return internal_bswap_16(host_16bits); | 
| 21 | 0 |         else return host_16bits; | 
| 22 | 0 | } | 
| 23 |  | inline BSWAP_CONSTEXPR uint16_t be16toh_internal(uint16_t big_endian_16bits) | 
| 24 | 19.7k | { | 
| 25 | 19.7k |     if constexpr (std::endian::native == std::endian::little) return internal_bswap_16(big_endian_16bits); | 
| 26 |  |         else return big_endian_16bits; | 
| 27 | 19.7k | } | 
| 28 |  | inline BSWAP_CONSTEXPR uint16_t le16toh_internal(uint16_t little_endian_16bits) | 
| 29 | 0 | { | 
| 30 |  |     if constexpr (std::endian::native == std::endian::big) return internal_bswap_16(little_endian_16bits); | 
| 31 | 0 |         else return little_endian_16bits; | 
| 32 | 0 | } | 
| 33 |  | inline BSWAP_CONSTEXPR uint32_t htobe32_internal(uint32_t host_32bits) | 
| 34 | 1.26G | { | 
| 35 | 1.26G |     if constexpr (std::endian::native == std::endian::little) return internal_bswap_32(host_32bits); | 
| 36 |  |         else return host_32bits; | 
| 37 | 1.26G | } | 
| 38 |  | inline BSWAP_CONSTEXPR uint32_t htole32_internal(uint32_t host_32bits) | 
| 39 | 603M | { | 
| 40 |  |     if constexpr (std::endian::native == std::endian::big) return internal_bswap_32(host_32bits); | 
| 41 | 603M |         else return host_32bits; | 
| 42 | 603M | } | 
| 43 |  | inline BSWAP_CONSTEXPR uint32_t be32toh_internal(uint32_t big_endian_32bits) | 
| 44 | 1.06M | { | 
| 45 | 1.06M |     if constexpr (std::endian::native == std::endian::little) return internal_bswap_32(big_endian_32bits); | 
| 46 |  |         else return big_endian_32bits; | 
| 47 | 1.06M | } | 
| 48 |  | inline BSWAP_CONSTEXPR uint32_t le32toh_internal(uint32_t little_endian_32bits) | 
| 49 | 754M | { | 
| 50 |  |     if constexpr (std::endian::native == std::endian::big) return internal_bswap_32(little_endian_32bits); | 
| 51 | 754M |         else return little_endian_32bits; | 
| 52 | 754M | } | 
| 53 |  | inline BSWAP_CONSTEXPR uint64_t htobe64_internal(uint64_t host_64bits) | 
| 54 | 269M | { | 
| 55 | 269M |     if constexpr (std::endian::native == std::endian::little) return internal_bswap_64(host_64bits); | 
| 56 |  |         else return host_64bits; | 
| 57 | 269M | } | 
| 58 |  | inline BSWAP_CONSTEXPR uint64_t htole64_internal(uint64_t host_64bits) | 
| 59 | 74.5M | { | 
| 60 |  |     if constexpr (std::endian::native == std::endian::big) return internal_bswap_64(host_64bits); | 
| 61 | 74.5M |         else return host_64bits; | 
| 62 | 74.5M | } | 
| 63 |  | inline BSWAP_CONSTEXPR uint64_t be64toh_internal(uint64_t big_endian_64bits) | 
| 64 | 204M | { | 
| 65 | 204M |     if constexpr (std::endian::native == std::endian::little) return internal_bswap_64(big_endian_64bits); | 
| 66 |  |         else return big_endian_64bits; | 
| 67 | 204M | } | 
| 68 |  | inline BSWAP_CONSTEXPR uint64_t le64toh_internal(uint64_t little_endian_64bits) | 
| 69 | 973M | { | 
| 70 |  |     if constexpr (std::endian::native == std::endian::big) return internal_bswap_64(little_endian_64bits); | 
| 71 | 973M |         else return little_endian_64bits; | 
| 72 | 973M | } | 
| 73 |  |  | 
| 74 |  | #endif // BITCOIN_COMPAT_ENDIAN_H |