/Users/eugenesiegel/btc/bitcoin/src/crypto/common.h
| Line | Count | Source (jump to first uncovered line) | 
| 1 |  | // Copyright (c) 2014-present 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_CRYPTO_COMMON_H | 
| 6 |  | #define BITCOIN_CRYPTO_COMMON_H | 
| 7 |  |  | 
| 8 |  | #include <compat/endian.h> | 
| 9 |  |  | 
| 10 |  | #include <concepts> | 
| 11 |  | #include <cstddef> | 
| 12 |  | #include <cstdint> | 
| 13 |  | #include <cstring> | 
| 14 |  |  | 
| 15 |  | template <typename B> | 
| 16 |  | concept ByteType = std::same_as<B, unsigned char> || std::same_as<B, std::byte>; | 
| 17 |  |  | 
| 18 |  | template <ByteType B> | 
| 19 |  | inline uint16_t ReadLE16(const B* ptr) | 
| 20 | 0 | { | 
| 21 | 0 |     uint16_t x; | 
| 22 | 0 |     memcpy(&x, ptr, 2); | 
| 23 | 0 |     return le16toh_internal(x); | 
| 24 | 0 | } | 
| 25 |  |  | 
| 26 |  | template <ByteType B> | 
| 27 |  | inline uint32_t ReadLE32(const B* ptr) | 
| 28 | 675M | { | 
| 29 | 675M |     uint32_t x; | 
| 30 | 675M |     memcpy(&x, ptr, 4); | 
| 31 | 675M |     return le32toh_internal(x); | 
| 32 | 675M | } _Z8ReadLE32ITk8ByteTypehEjPKT_| Line | Count | Source |  | 28 | 451M | { |  | 29 | 451M |     uint32_t x; |  | 30 | 451M |     memcpy(&x, ptr, 4); |  | 31 | 451M |     return le32toh_internal(x); |  | 32 | 451M | } | 
_Z8ReadLE32ITk8ByteTypeSt4byteEjPKT_| Line | Count | Source |  | 28 | 223M | { |  | 29 | 223M |     uint32_t x; |  | 30 | 223M |     memcpy(&x, ptr, 4); |  | 31 | 223M |     return le32toh_internal(x); |  | 32 | 223M | } | 
 | 
| 33 |  |  | 
| 34 |  | template <ByteType B> | 
| 35 |  | inline uint64_t ReadLE64(const B* ptr) | 
| 36 | 954M | { | 
| 37 | 954M |     uint64_t x; | 
| 38 | 954M |     memcpy(&x, ptr, 8); | 
| 39 | 954M |     return le64toh_internal(x); | 
| 40 | 954M | } _Z8ReadLE64ITk8ByteTypehEyPKT_| Line | Count | Source |  | 36 | 942M | { |  | 37 | 942M |     uint64_t x; |  | 38 | 942M |     memcpy(&x, ptr, 8); |  | 39 | 942M |     return le64toh_internal(x); |  | 40 | 942M | } | 
_Z8ReadLE64ITk8ByteTypeSt4byteEyPKT_| Line | Count | Source |  | 36 | 12.5M | { |  | 37 | 12.5M |     uint64_t x; |  | 38 | 12.5M |     memcpy(&x, ptr, 8); |  | 39 | 12.5M |     return le64toh_internal(x); |  | 40 | 12.5M | } | 
 | 
| 41 |  |  | 
| 42 |  | template <ByteType B> | 
| 43 |  | inline void WriteLE16(B* ptr, uint16_t x) | 
| 44 | 0 | { | 
| 45 | 0 |     uint16_t v = htole16_internal(x); | 
| 46 | 0 |     memcpy(ptr, &v, 2); | 
| 47 | 0 | } | 
| 48 |  |  | 
| 49 |  | template <ByteType B> | 
| 50 |  | inline void WriteLE32(B* ptr, uint32_t x) | 
| 51 | 302M | { | 
| 52 | 302M |     uint32_t v = htole32_internal(x); | 
| 53 | 302M |     memcpy(ptr, &v, 4); | 
| 54 | 302M | } _Z9WriteLE32ITk8ByteTypehEvPT_j| Line | Count | Source |  | 51 | 410k | { |  | 52 | 410k |     uint32_t v = htole32_internal(x); |  | 53 | 410k |     memcpy(ptr, &v, 4); |  | 54 | 410k | } | 
_Z9WriteLE32ITk8ByteTypeSt4byteEvPT_j| Line | Count | Source |  | 51 | 302M | { |  | 52 | 302M |     uint32_t v = htole32_internal(x); |  | 53 | 302M |     memcpy(ptr, &v, 4); |  | 54 | 302M | } | 
 | 
| 55 |  |  | 
| 56 |  | template <ByteType B> | 
| 57 |  | inline void WriteLE64(B* ptr, uint64_t x) | 
| 58 | 956 | { | 
| 59 | 956 |     uint64_t v = htole64_internal(x); | 
| 60 | 956 |     memcpy(ptr, &v, 8); | 
| 61 | 956 | } Unexecuted instantiation: _Z9WriteLE64ITk8ByteTypeSt4byteEvPT_y_Z9WriteLE64ITk8ByteTypehEvPT_y| Line | Count | Source |  | 58 | 956 | { |  | 59 | 956 |     uint64_t v = htole64_internal(x); |  | 60 | 956 |     memcpy(ptr, &v, 8); |  | 61 | 956 | } | 
 | 
| 62 |  |  | 
| 63 |  | template <ByteType B> | 
| 64 |  | inline uint16_t ReadBE16(const B* ptr) | 
| 65 | 19.7k | { | 
| 66 | 19.7k |     uint16_t x; | 
| 67 | 19.7k |     memcpy(&x, ptr, 2); | 
| 68 | 19.7k |     return be16toh_internal(x); | 
| 69 | 19.7k | } | 
| 70 |  |  | 
| 71 |  | template <ByteType B> | 
| 72 |  | inline uint32_t ReadBE32(const B* ptr) | 
| 73 | 1.06M | { | 
| 74 | 1.06M |     uint32_t x; | 
| 75 | 1.06M |     memcpy(&x, ptr, 4); | 
| 76 | 1.06M |     return be32toh_internal(x); | 
| 77 | 1.06M | } _Z8ReadBE32ITk8ByteTypehEjPKT_| Line | Count | Source |  | 73 | 1.06M | { |  | 74 | 1.06M |     uint32_t x; |  | 75 | 1.06M |     memcpy(&x, ptr, 4); |  | 76 | 1.06M |     return be32toh_internal(x); |  | 77 | 1.06M | } | 
Unexecuted instantiation: _Z8ReadBE32ITk8ByteTypeSt4byteEjPKT_ | 
| 78 |  |  | 
| 79 |  | template <ByteType B> | 
| 80 |  | inline uint64_t ReadBE64(const B* ptr) | 
| 81 | 204M | { | 
| 82 | 204M |     uint64_t x; | 
| 83 | 204M |     memcpy(&x, ptr, 8); | 
| 84 | 204M |     return be64toh_internal(x); | 
| 85 | 204M | } | 
| 86 |  |  | 
| 87 |  | template <ByteType B> | 
| 88 |  | inline void WriteBE16(B* ptr, uint16_t x) | 
| 89 | 0 | { | 
| 90 | 0 |     uint16_t v = htobe16_internal(x); | 
| 91 | 0 |     memcpy(ptr, &v, 2); | 
| 92 | 0 | } | 
| 93 |  |  | 
| 94 |  | template <ByteType B> | 
| 95 |  | inline void WriteBE32(B* ptr, uint32_t x) | 
| 96 | 1.26G | { | 
| 97 | 1.26G |     uint32_t v = htobe32_internal(x); | 
| 98 | 1.26G |     memcpy(ptr, &v, 4); | 
| 99 | 1.26G | } | 
| 100 |  |  | 
| 101 |  | template <ByteType B> | 
| 102 |  | inline void WriteBE64(B* ptr, uint64_t x) | 
| 103 | 268M | { | 
| 104 | 268M |     uint64_t v = htobe64_internal(x); | 
| 105 | 268M |     memcpy(ptr, &v, 8); | 
| 106 | 268M | } | 
| 107 |  |  | 
| 108 |  | #endif // BITCOIN_CRYPTO_COMMON_H |