2020-11-09 05:23:58 +01:00
|
|
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
2012-07-18 19:07:51 +02:00
|
|
|
#pragma once
|
2009-11-18 00:42:52 +01:00
|
|
|
|
2015-11-30 21:43:37 +01:00
|
|
|
#include <stdint.h>
|
2019-03-27 11:32:41 +01:00
|
|
|
|
2010-06-23 19:46:29 +02:00
|
|
|
#include "macro.h"
|
2010-05-24 01:45:54 +02:00
|
|
|
|
2011-06-30 04:16:10 +02:00
|
|
|
extern int saved_argc;
|
|
|
|
extern char **saved_argv;
|
|
|
|
|
2019-03-15 10:46:54 +01:00
|
|
|
static inline void save_argc_argv(int argc, char **argv) {
|
|
|
|
saved_argc = argc;
|
|
|
|
saved_argv = argv;
|
|
|
|
}
|
|
|
|
|
2011-08-22 14:58:50 +02:00
|
|
|
bool kexec_loaded(void);
|
|
|
|
|
2013-05-03 04:51:50 +02:00
|
|
|
int prot_from_flags(int flags) _const_;
|
2011-10-07 21:06:39 +02:00
|
|
|
|
2012-05-16 14:22:40 +02:00
|
|
|
bool in_initrd(void);
|
2016-06-13 16:28:42 +02:00
|
|
|
void in_initrd_force(bool value);
|
2012-05-30 15:01:51 +02:00
|
|
|
|
2015-10-27 03:01:06 +01:00
|
|
|
int on_ac_power(void);
|
|
|
|
|
2013-04-05 01:09:50 +02:00
|
|
|
static inline unsigned u64log2(uint64_t n) {
|
2014-01-30 16:46:48 +01:00
|
|
|
#if __SIZEOF_LONG_LONG__ == 8
|
2013-12-25 17:46:45 +01:00
|
|
|
return (n > 1) ? (unsigned) __builtin_clzll(n) ^ 63U : 0;
|
2014-01-30 16:46:48 +01:00
|
|
|
#else
|
|
|
|
#error "Wut?"
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned u32ctz(uint32_t n) {
|
|
|
|
#if __SIZEOF_INT__ == 4
|
2018-12-13 19:59:46 +01:00
|
|
|
return n != 0 ? __builtin_ctz(n) : 32;
|
2014-01-30 16:46:48 +01:00
|
|
|
#else
|
|
|
|
#error "Wut?"
|
|
|
|
#endif
|
2013-04-05 01:09:50 +02:00
|
|
|
}
|
2013-03-26 11:36:31 +01:00
|
|
|
|
2015-02-01 21:26:46 +01:00
|
|
|
static inline unsigned log2i(int x) {
|
2014-03-15 02:43:56 +01:00
|
|
|
assert(x > 0);
|
|
|
|
|
|
|
|
return __SIZEOF_INT__ * 8 - __builtin_clz(x) - 1;
|
|
|
|
}
|
|
|
|
|
2014-10-15 01:28:54 +02:00
|
|
|
static inline unsigned log2u(unsigned x) {
|
|
|
|
assert(x > 0);
|
|
|
|
|
|
|
|
return sizeof(unsigned) * 8 - __builtin_clz(x) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned log2u_round_up(unsigned x) {
|
|
|
|
assert(x > 0);
|
|
|
|
|
|
|
|
if (x == 1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return log2u(x - 1) + 1;
|
|
|
|
}
|
|
|
|
|
2013-12-13 22:02:47 +01:00
|
|
|
int container_get_leader(const char *machine, pid_t *pid);
|
|
|
|
|
2015-09-23 03:01:06 +02:00
|
|
|
int version(void);
|
2017-12-23 15:02:58 +01:00
|
|
|
|
|
|
|
int str_verscmp(const char *s1, const char *s2);
|
2018-01-10 10:36:14 +01:00
|
|
|
|
2018-01-10 18:37:54 +01:00
|
|
|
void disable_coredumps(void);
|