LCOV - code coverage report
Current view: top level - src/compat - byteswap.h (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 17 17 100.0 %
Date: 2021-06-29 14:35:33 Functions: 3 3 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 0 0 -

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2014-2019 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_BYTESWAP_H
#       6                 :            : #define BITCOIN_COMPAT_BYTESWAP_H
#       7                 :            : 
#       8                 :            : #if defined(HAVE_CONFIG_H)
#       9                 :            : #include <config/bitcoin-config.h>
#      10                 :            : #endif
#      11                 :            : 
#      12                 :            : #include <stdint.h>
#      13                 :            : 
#      14                 :            : #if defined(HAVE_BYTESWAP_H)
#      15                 :            : #include <byteswap.h>
#      16                 :            : #endif
#      17                 :            : 
#      18                 :            : #if defined(MAC_OSX)
#      19                 :            : 
#      20                 :            : #include <libkern/OSByteOrder.h>
#      21                 :            : #define bswap_16(x) OSSwapInt16(x)
#      22                 :            : #define bswap_32(x) OSSwapInt32(x)
#      23                 :            : #define bswap_64(x) OSSwapInt64(x)
#      24                 :            : 
#      25                 :            : #else
#      26                 :            : // Non-MacOS / non-Darwin
#      27                 :            : 
#      28                 :            : #if HAVE_DECL_BSWAP_16 == 0
#      29                 :            : inline uint16_t bswap_16(uint16_t x)
#      30                 :          2 : {
#      31                 :          2 :     return (x >> 8) | (x << 8);
#      32                 :          2 : }
#      33                 :            : #endif // HAVE_DECL_BSWAP16 == 0
#      34                 :            : 
#      35                 :            : #if HAVE_DECL_BSWAP_32 == 0
#      36                 :            : inline uint32_t bswap_32(uint32_t x)
#      37                 :          2 : {
#      38                 :          2 :     return (((x & 0xff000000U) >> 24) | ((x & 0x00ff0000U) >>  8) |
#      39                 :          2 :             ((x & 0x0000ff00U) <<  8) | ((x & 0x000000ffU) << 24));
#      40                 :          2 : }
#      41                 :            : #endif // HAVE_DECL_BSWAP32 == 0
#      42                 :            : 
#      43                 :            : #if HAVE_DECL_BSWAP_64 == 0
#      44                 :            : inline uint64_t bswap_64(uint64_t x)
#      45                 :          2 : {
#      46                 :          2 :      return (((x & 0xff00000000000000ull) >> 56)
#      47                 :          2 :           | ((x & 0x00ff000000000000ull) >> 40)
#      48                 :          2 :           | ((x & 0x0000ff0000000000ull) >> 24)
#      49                 :          2 :           | ((x & 0x000000ff00000000ull) >> 8)
#      50                 :          2 :           | ((x & 0x00000000ff000000ull) << 8)
#      51                 :          2 :           | ((x & 0x0000000000ff0000ull) << 24)
#      52                 :          2 :           | ((x & 0x000000000000ff00ull) << 40)
#      53                 :          2 :           | ((x & 0x00000000000000ffull) << 56));
#      54                 :          2 : }
#      55                 :            : #endif // HAVE_DECL_BSWAP64 == 0
#      56                 :            : 
#      57                 :            : #endif // defined(MAC_OSX)
#      58                 :            : 
#      59                 :            : #endif // BITCOIN_COMPAT_BYTESWAP_H

Generated by: LCOV version 1.14