]>
git.proxmox.com Git - systemd.git/blob - src/basic/util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
8 static inline const char* yes_no(bool b
) {
9 return b
? "yes" : "no";
12 static inline const char* true_false(bool b
) {
13 return b
? "true" : "false";
16 static inline const char* one_zero(bool b
) {
20 static inline const char* enable_disable(bool b
) {
21 return b
? "enable" : "disable";
24 extern int saved_argc
;
25 extern char **saved_argv
;
27 static inline void save_argc_argv(int argc
, char **argv
) {
32 bool kexec_loaded(void);
34 int prot_from_flags(int flags
) _const_
;
37 void in_initrd_force(bool value
);
39 int on_ac_power(void);
41 static inline unsigned u64log2(uint64_t n
) {
42 #if __SIZEOF_LONG_LONG__ == 8
43 return (n
> 1) ? (unsigned) __builtin_clzll(n
) ^ 63U : 0;
49 static inline unsigned u32ctz(uint32_t n
) {
50 #if __SIZEOF_INT__ == 4
51 return n
!= 0 ? __builtin_ctz(n
) : 32;
57 static inline unsigned log2i(int x
) {
60 return __SIZEOF_INT__
* 8 - __builtin_clz(x
) - 1;
63 static inline unsigned log2u(unsigned x
) {
66 return sizeof(unsigned) * 8 - __builtin_clz(x
) - 1;
69 static inline unsigned log2u_round_up(unsigned x
) {
75 return log2u(x
- 1) + 1;
78 int container_get_leader(const char *machine
, pid_t
*pid
);
82 int str_verscmp(const char *s1
, const char *s2
);
84 void disable_coredumps(void);