X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=src%2Fbasic%2Futil.h;h=75631c436bdc560edc0395246ada2f6814e96b33;hb=3602096276194365d3e9874b0899701baf3327de;hp=d9d2f72b750314afda0a039576a007b54512afa0;hpb=eaca07ccfdf5d7dabc50afc7e539c2413dd69d3e;p=elogind.git diff --git a/src/basic/util.h b/src/basic/util.h index d9d2f72b7..75631c436 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - #pragma once /*** @@ -22,6 +20,7 @@ ***/ #include +#include #include #include #include @@ -29,12 +28,15 @@ #include #include #include +#include #include #include +#include #include #include #include #include +#include #include #include #include @@ -59,14 +61,22 @@ static inline const char* one_zero(bool b) { return b ? "1" : "0"; } +static inline const char* enable_disable(bool b) { + return b ? "enable" : "disable"; +} + void execute_directories(const char* const* directories, usec_t timeout, char *argv[]); +#if 0 /// UNNEEDED by elogind bool plymouth_running(void); +#endif // 0 bool display_is_local(const char *display) _pure_; int socket_from_display(const char *display, char **path); +#if 0 /// UNNEEDED by elogind int block_get_whole_disk(dev_t d, dev_t *ret); +#endif // 0 #define NULSTR_FOREACH(i, l) \ for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1) @@ -77,17 +87,22 @@ int block_get_whole_disk(dev_t d, dev_t *ret); extern int saved_argc; extern char **saved_argv; +#if 0 /// UNNEEDED by elogind bool kexec_loaded(void); int prot_from_flags(int flags) _const_; +#endif // 0 int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...); bool in_initrd(void); +void in_initrd_force(bool value); +#if 0 /// UNNEEDED by elogind void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, int (*compar) (const void *, const void *, void *), void *arg); +#endif // 0 /** * Normal qsort requires base to be nonnull. Here were require @@ -101,7 +116,19 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size, comparison_ qsort(base, nmemb, size, compar); } +/** + * Normal memcpy requires src to be nonnull. We do nothing if n is 0. + */ +static inline void memcpy_safe(void *dst, const void *src, size_t n) { + if (n == 0) + return; + assert(src); + memcpy(dst, src, n); +} + +#if 0 /// UNNEEDED by elogind int on_ac_power(void); +#endif // 0 #define memzero(x,l) (memset((x), 0, (l))) #define zero(x) (memzero(&(x), sizeof(x))) @@ -163,15 +190,21 @@ static inline unsigned log2u_round_up(unsigned x) { return log2u(x - 1) + 1; } -bool id128_is_valid(const char *s) _pure_; - +#if 0 /// UNNEEDED by elogind +#endif // 0 int container_get_leader(const char *machine, pid_t *pid); int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *netns_fd, int *userns_fd, int *root_fd); int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int userns_fd, int root_fd); uint64_t physical_memory(void); +uint64_t physical_memory_scale(uint64_t v, uint64_t max); + +uint64_t system_tasks_max(void); +uint64_t system_tasks_max_scale(uint64_t v, uint64_t max); -int update_reboot_param_file(const char *param); +#if 0 /// UNNEEDED by elogind +#endif // 0 +int update_reboot_parameter_and_warn(const char *param); int version(void);