]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
c2f1db8f | 2 | #pragma once |
60918275 | 3 | |
31885cd5 | 4 | #include <alloca.h> |
11c3a366 | 5 | #include <errno.h> |
370c860f | 6 | #include <fcntl.h> |
60918275 | 7 | #include <inttypes.h> |
f6c2284a LP |
8 | #include <limits.h> |
9 | #include <locale.h> | |
ec2002f8 | 10 | #include <stdarg.h> |
60918275 | 11 | #include <stdbool.h> |
f6c2284a | 12 | #include <stddef.h> |
11c3a366 | 13 | #include <stdint.h> |
80876c20 | 14 | #include <stdio.h> |
f6c2284a | 15 | #include <stdlib.h> |
11c3a366 | 16 | #include <string.h> |
f6c2284a | 17 | #include <sys/inotify.h> |
2c35d880 | 18 | #include <sys/socket.h> |
00dc5d76 | 19 | #include <sys/stat.h> |
c6878637 | 20 | #include <sys/statfs.h> |
27d13af7 | 21 | #include <sys/sysmacros.h> |
f6c2284a LP |
22 | #include <sys/types.h> |
23 | #include <time.h> | |
24 | #include <unistd.h> | |
60918275 | 25 | |
f97b34a6 | 26 | #include "format-util.h" |
a838e6a1 | 27 | #include "macro.h" |
9a98c7a1 | 28 | #include "time-util.h" |
871d7de4 | 29 | |
60918275 LP |
30 | static inline const char* yes_no(bool b) { |
31 | return b ? "yes" : "no"; | |
32 | } | |
33 | ||
5232c42e LS |
34 | static inline const char* true_false(bool b) { |
35 | return b ? "true" : "false"; | |
36 | } | |
37 | ||
769d324c LP |
38 | static inline const char* one_zero(bool b) { |
39 | return b ? "1" : "0"; | |
40 | } | |
41 | ||
2d37cd53 ZJS |
42 | static inline const char* enable_disable(bool b) { |
43 | return b ? "enable" : "disable"; | |
44 | } | |
45 | ||
9a0e6896 LP |
46 | extern int saved_argc; |
47 | extern char **saved_argv; | |
48 | ||
36fea155 LP |
49 | static inline void save_argc_argv(int argc, char **argv) { |
50 | saved_argc = argc; | |
51 | saved_argv = argv; | |
52 | } | |
53 | ||
65457142 FC |
54 | bool kexec_loaded(void); |
55 | ||
44a6b1b6 | 56 | int prot_from_flags(int flags) _const_; |
87d2c1ff | 57 | |
9be346c9 | 58 | bool in_initrd(void); |
dcd61450 | 59 | void in_initrd_force(bool value); |
069cfc85 | 60 | |
b5efdb8a LP |
61 | int on_ac_power(void); |
62 | ||
144e51ec | 63 | static inline unsigned u64log2(uint64_t n) { |
ec417ccc | 64 | #if __SIZEOF_LONG_LONG__ == 8 |
693eb9a2 | 65 | return (n > 1) ? (unsigned) __builtin_clzll(n) ^ 63U : 0; |
ec417ccc LP |
66 | #else |
67 | #error "Wut?" | |
68 | #endif | |
69 | } | |
70 | ||
71 | static inline unsigned u32ctz(uint32_t n) { | |
72 | #if __SIZEOF_INT__ == 4 | |
1a359852 | 73 | return n != 0 ? __builtin_ctz(n) : 32; |
ec417ccc LP |
74 | #else |
75 | #error "Wut?" | |
76 | #endif | |
144e51ec | 77 | } |
79d860fe | 78 | |
7d328b54 | 79 | static inline unsigned log2i(int x) { |
8fe90522 ZJS |
80 | assert(x > 0); |
81 | ||
82 | return __SIZEOF_INT__ * 8 - __builtin_clz(x) - 1; | |
83 | } | |
84 | ||
b5de6d98 MS |
85 | static inline unsigned log2u(unsigned x) { |
86 | assert(x > 0); | |
87 | ||
88 | return sizeof(unsigned) * 8 - __builtin_clz(x) - 1; | |
89 | } | |
90 | ||
91 | static inline unsigned log2u_round_up(unsigned x) { | |
92 | assert(x > 0); | |
93 | ||
94 | if (x == 1) | |
95 | return 0; | |
96 | ||
97 | return log2u(x - 1) + 1; | |
98 | } | |
99 | ||
bc9fd78c LP |
100 | int container_get_leader(const char *machine, pid_t *pid); |
101 | ||
3f6fd1ba | 102 | int version(void); |
68c58c67 LP |
103 | |
104 | int str_verscmp(const char *s1, const char *s2); | |
9ce17593 | 105 | |
e557b1a6 | 106 | void disable_coredumps(void); |