LCOV - code coverage report
Current view: top level - src - portable.c (source / functions) Coverage Total Hit
Test: pino Coverage Report Lines: 100.0 % 6 6
Test Date: 2026-01-22 09:45:38 Functions: 100.0 % 3 3
Legend: Lines: hit not hit

            Line data    Source code
       1              : /*
       2              :  * libpino - portable.c
       3              :  *
       4              :  * This file is part of libpino.
       5              :  *
       6              :  * Author: Go Kudo <zeriyoshi@gmail.com>
       7              :  * SPDX-License-Identifier: MIT
       8              :  */
       9              : 
      10              : #include <pino/portable.h>
      11              : 
      12              : #if defined(_MSC_VER)
      13              : #include <stdlib.h>
      14              : #endif
      15              : 
      16          164 : extern uint16_t pino_bswap16(uint16_t x)
      17              : {
      18          164 :     return ((x & 0xff) << 8) | ((x & 0xff00) >> 8);
      19              : }
      20              : 
      21          184 : extern uint32_t pino_bswap32(uint32_t x)
      22              : {
      23              : #if defined(_MSC_VER)
      24              :     return _byteswap_ulong(x);
      25              : #elif defined(__GNUC__) || defined(__clang__)
      26          184 :     return __builtin_bswap32(x);
      27              : #else
      28              :     return ((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | ((x & 0xff000000) >> 24);
      29              : #endif
      30              : }
      31              : 
      32           78 : extern uint64_t pino_bswap64(uint64_t x)
      33              : {
      34              : #if defined(_MSC_VER)
      35              :     return _byteswap_uint64(x);
      36              : #elif defined(__GNUC__) || defined(__clang__)
      37           78 :     return __builtin_bswap64(x);
      38              : #else
      39              :     return ((x & 0xff) << 56) | ((x & 0xff00) << 40) | ((x & 0xff0000) << 24) | ((x & 0xff000000) << 8) |
      40              :            ((x & 0xff00000000ULL) >> 8) | ((x & 0xff0000000000ULL) >> 24) | ((x & 0xff000000000000ULL) >> 40) |
      41              :            ((x & 0xff00000000000000ULL) >> 56);
      42              : #endif
      43              : }
        

Generated by: LCOV version 2.0-1