LCOV - code coverage report
Current view: top level - basic - util.h (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 22 27 81.5 %
Date: 2019-08-22 15:41:25 Functions: 8 10 80.0 %

          Line data    Source code
       1             : /* SPDX-License-Identifier: LGPL-2.1+ */
       2             : #pragma once
       3             : 
       4             : #include <stdint.h>
       5             : 
       6             : #include "macro.h"
       7             : 
       8       17650 : static inline const char* yes_no(bool b) {
       9       17650 :         return b ? "yes" : "no";
      10             : }
      11             : 
      12           5 : static inline const char* true_false(bool b) {
      13           5 :         return b ? "true" : "false";
      14             : }
      15             : 
      16           0 : static inline const char* one_zero(bool b) {
      17           0 :         return b ? "1" : "0";
      18             : }
      19             : 
      20           0 : static inline const char* enable_disable(bool b) {
      21           0 :         return b ? "enable" : "disable";
      22             : }
      23             : 
      24             : extern int saved_argc;
      25             : extern char **saved_argv;
      26             : 
      27         282 : static inline void save_argc_argv(int argc, char **argv) {
      28         282 :         saved_argc = argc;
      29         282 :         saved_argv = argv;
      30         282 : }
      31             : 
      32             : bool kexec_loaded(void);
      33             : 
      34             : int prot_from_flags(int flags) _const_;
      35             : 
      36             : bool in_initrd(void);
      37             : void in_initrd_force(bool value);
      38             : 
      39             : int on_ac_power(void);
      40             : 
      41           7 : static inline unsigned u64log2(uint64_t n) {
      42             : #if __SIZEOF_LONG_LONG__ == 8
      43           7 :         return (n > 1) ? (unsigned) __builtin_clzll(n) ^ 63U : 0;
      44             : #else
      45             : #error "Wut?"
      46             : #endif
      47             : }
      48             : 
      49          11 : static inline unsigned u32ctz(uint32_t n) {
      50             : #if __SIZEOF_INT__ == 4
      51          11 :         return n != 0 ? __builtin_ctz(n) : 32;
      52             : #else
      53             : #error "Wut?"
      54             : #endif
      55             : }
      56             : 
      57           8 : static inline unsigned log2i(int x) {
      58           8 :         assert(x > 0);
      59             : 
      60           8 :         return __SIZEOF_INT__ * 8 - __builtin_clz(x) - 1;
      61             : }
      62             : 
      63       18331 : static inline unsigned log2u(unsigned x) {
      64       18331 :         assert(x > 0);
      65             : 
      66       18331 :         return sizeof(unsigned) * 8 - __builtin_clz(x) - 1;
      67             : }
      68             : 
      69       18331 : static inline unsigned log2u_round_up(unsigned x) {
      70       18331 :         assert(x > 0);
      71             : 
      72       18331 :         if (x == 1)
      73           0 :                 return 0;
      74             : 
      75       18331 :         return log2u(x - 1) + 1;
      76             : }
      77             : 
      78             : int container_get_leader(const char *machine, pid_t *pid);
      79             : 
      80             : int version(void);
      81             : 
      82             : int str_verscmp(const char *s1, const char *s2);
      83             : 
      84             : void disable_coredumps(void);

Generated by: LCOV version 1.14