LCOV - code coverage report
Current view: top level - basic - format-util.h (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 2 2 100.0 %
Date: 2019-08-22 15:41:25 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : #pragma once
       3             : 
       4             : #include <inttypes.h>
       5             : #include <net/if.h>
       6             : #include <stdbool.h>
       7             : 
       8             : #if SIZEOF_PID_T == 4
       9             : #  define PID_PRI PRIi32
      10             : #elif SIZEOF_PID_T == 2
      11             : #  define PID_PRI PRIi16
      12             : #else
      13             : #  error Unknown pid_t size
      14             : #endif
      15             : #define PID_FMT "%" PID_PRI
      16             : 
      17             : #if SIZEOF_UID_T == 4
      18             : #  define UID_FMT "%" PRIu32
      19             : #elif SIZEOF_UID_T == 2
      20             : #  define UID_FMT "%" PRIu16
      21             : #else
      22             : #  error Unknown uid_t size
      23             : #endif
      24             : 
      25             : #if SIZEOF_GID_T == 4
      26             : #  define GID_FMT "%" PRIu32
      27             : #elif SIZEOF_GID_T == 2
      28             : #  define GID_FMT "%" PRIu16
      29             : #else
      30             : #  error Unknown gid_t size
      31             : #endif
      32             : 
      33             : #if SIZEOF_TIME_T == 8
      34             : #  define PRI_TIME PRIi64
      35             : #elif SIZEOF_TIME_T == 4
      36             : #  define PRI_TIME "li"
      37             : #else
      38             : #  error Unknown time_t size
      39             : #endif
      40             : 
      41             : #if defined __x86_64__ && defined __ILP32__
      42             : #  define PRI_TIMEX PRIi64
      43             : #else
      44             : #  define PRI_TIMEX "li"
      45             : #endif
      46             : 
      47             : #if SIZEOF_RLIM_T == 8
      48             : #  define RLIM_FMT "%" PRIu64
      49             : #elif SIZEOF_RLIM_T == 4
      50             : #  define RLIM_FMT "%" PRIu32
      51             : #else
      52             : #  error Unknown rlim_t size
      53             : #endif
      54             : 
      55             : #if SIZEOF_DEV_T == 8
      56             : #  define DEV_FMT "%" PRIu64
      57             : #elif SIZEOF_DEV_T == 4
      58             : #  define DEV_FMT "%" PRIu32
      59             : #else
      60             : #  error Unknown dev_t size
      61             : #endif
      62             : 
      63             : #if SIZEOF_INO_T == 8
      64             : #  define INO_FMT "%" PRIu64
      65             : #elif SIZEOF_INO_T == 4
      66             : #  define INO_FMT "%" PRIu32
      67             : #else
      68             : #  error Unknown ino_t size
      69             : #endif
      70             : 
      71             : char *format_ifname(int ifindex, char buf[static IF_NAMESIZE + 1]);
      72             : 
      73             : typedef enum {
      74             :         FORMAT_BYTES_USE_IEC     = 1 << 0,
      75             :         FORMAT_BYTES_BELOW_POINT = 1 << 1,
      76             :         FORMAT_BYTES_TRAILING_B  = 1 << 2,
      77             : } FormatBytesFlag;
      78             : 
      79             : #define FORMAT_BYTES_MAX 8
      80             : char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag);
      81          49 : static inline char *format_bytes(char *buf, size_t l, uint64_t t) {
      82          49 :         return format_bytes_full(buf, l, t, FORMAT_BYTES_USE_IEC | FORMAT_BYTES_BELOW_POINT | FORMAT_BYTES_TRAILING_B);
      83             : }

Generated by: LCOV version 1.14