LCOV - code coverage report
Current view: top level - src/crypto - common.h (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 100.0 % 50 50
Test Date: 2024-09-01 05:20:30 Functions: 100.0 % 11 11
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2014-2020 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 <cstdint>
      11                 :             : #include <cstring>
      12                 :             : 
      13                 :      901840 : uint16_t static inline ReadLE16(const unsigned char* ptr)
      14                 :             : {
      15                 :      901840 :     uint16_t x;
      16                 :      901840 :     memcpy(&x, ptr, 2);
      17                 :     1803680 :     return le16toh_internal(x);
      18                 :      901840 : }
      19                 :             : 
      20                 :  1235841877 : uint32_t static inline ReadLE32(const unsigned char* ptr)
      21                 :             : {
      22                 :  1235841877 :     uint32_t x;
      23                 :  1235841877 :     memcpy(&x, ptr, 4);
      24                 :  2471683754 :     return le32toh_internal(x);
      25                 :  1235841877 : }
      26                 :             : 
      27                 :  1669525118 : uint64_t static inline ReadLE64(const unsigned char* ptr)
      28                 :             : {
      29                 :  1669525118 :     uint64_t x;
      30                 :  1669525118 :     memcpy(&x, ptr, 8);
      31                 :  3339050236 :     return le64toh_internal(x);
      32                 :  1669525118 : }
      33                 :             : 
      34                 :       19440 : void static inline WriteLE16(unsigned char* ptr, uint16_t x)
      35                 :             : {
      36                 :       19440 :     uint16_t v = htole16_internal(x);
      37                 :       19440 :     memcpy(ptr, &v, 2);
      38                 :       19440 : }
      39                 :             : 
      40                 :  1035310461 : void static inline WriteLE32(unsigned char* ptr, uint32_t x)
      41                 :             : {
      42                 :  1035310461 :     uint32_t v = htole32_internal(x);
      43                 :  1035310461 :     memcpy(ptr, &v, 4);
      44                 :  1035310461 : }
      45                 :             : 
      46                 :   942479796 : void static inline WriteLE64(unsigned char* ptr, uint64_t x)
      47                 :             : {
      48                 :   942479796 :     uint64_t v = htole64_internal(x);
      49                 :   942479796 :     memcpy(ptr, &v, 8);
      50                 :   942479796 : }
      51                 :             : 
      52                 :     8681440 : uint16_t static inline ReadBE16(const unsigned char* ptr)
      53                 :             : {
      54                 :     8681440 :     uint16_t x;
      55                 :     8681440 :     memcpy(&x, ptr, 2);
      56                 :    17362880 :     return be16toh_internal(x);
      57                 :     8681440 : }
      58                 :             : 
      59                 :   972736910 : uint32_t static inline ReadBE32(const unsigned char* ptr)
      60                 :             : {
      61                 :   972736910 :     uint32_t x;
      62                 :   972736910 :     memcpy(&x, ptr, 4);
      63                 :  1945473820 :     return be32toh_internal(x);
      64                 :   972736910 : }
      65                 :             : 
      66                 :   420142936 : uint64_t static inline ReadBE64(const unsigned char* ptr)
      67                 :             : {
      68                 :   420142936 :     uint64_t x;
      69                 :   420142936 :     memcpy(&x, ptr, 8);
      70                 :   840285872 :     return be64toh_internal(x);
      71                 :   420142936 : }
      72                 :             : 
      73                 :  3028506804 : void static inline WriteBE32(unsigned char* ptr, uint32_t x)
      74                 :             : {
      75                 :  3028506804 :     uint32_t v = htobe32_internal(x);
      76                 :  3028506804 :     memcpy(ptr, &v, 4);
      77                 :  3028506804 : }
      78                 :             : 
      79                 :   558228082 : void static inline WriteBE64(unsigned char* ptr, uint64_t x)
      80                 :             : {
      81                 :   558228082 :     uint64_t v = htobe64_internal(x);
      82                 :   558228082 :     memcpy(ptr, &v, 8);
      83                 :   558228082 : }
      84                 :             : 
      85                 :             : #endif // BITCOIN_CRYPTO_COMMON_H
        

Generated by: LCOV version 2.0-1