chiark / gitweb /
Prep v228: With most functions split out, clean up the enormous includes list in...
authorSven Eden <yamakuzure@gmx.net>
Thu, 13 Apr 2017 05:43:39 +0000 (07:43 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 26 Apr 2017 10:59:13 +0000 (12:59 +0200)
src/basic/util.c
src/basic/util.h

index 1512adc2d722cdc06d0688ed066e182a8d6e3859..bfc6d046a32d86226b2eaf045549a339df398f31 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <grp.h>
-#include <langinfo.h>
-#include <libintl.h>
-#include <limits.h>
-#include <linux/magic.h>
-#include <linux/oom.h>
-#include <linux/sched.h>
-#include <locale.h>
-#include <poll.h>
-#include <pwd.h>
+//#include <ctype.h>
+//#include <dirent.h>
+//#include <errno.h>
+//#include <fcntl.h>
+//#include <grp.h>
+//#include <langinfo.h>
+//#include <libintl.h>
+//#include <limits.h>
+//#include <linux/magic.h>
+//#include <linux/oom.h>
+//#include <linux/sched.h>
+//#include <locale.h>
+//#include <poll.h>
+//#include <pwd.h>
 #include <sched.h>
 #include <sched.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/file.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <sys/personality.h>
+//#include <signal.h>
+//#include <stdarg.h>
+//#include <stdio.h>
+//#include <stdlib.h>
+//#include <string.h>
+//#include <sys/file.h>
+//#include <sys/ioctl.h>
+//#include <sys/mman.h>
+//#include <sys/mount.h>
+//#include <sys/personality.h>
 #include <sys/prctl.h>
 #include <sys/prctl.h>
-#include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
-#include <sys/vfs.h>
-#include <sys/wait.h>
-#include <syslog.h>
-#include <unistd.h>
+//#include <sys/stat.h>
+//#include <sys/statvfs.h>
+//#include <sys/time.h>
+//#include <sys/types.h>
+//#include <sys/utsname.h>
+//#include <sys/vfs.h>
+//#include <sys/wait.h>
+//#include <syslog.h>
+//#include <unistd.h>
 
 /* When we include libgen.h because we need dirname() we immediately
  * undefine basename() since libgen.h defines it as a macro to the
  * POSIX version which is really broken. We prefer GNU basename(). */
 
 /* When we include libgen.h because we need dirname() we immediately
  * undefine basename() since libgen.h defines it as a macro to the
  * POSIX version which is really broken. We prefer GNU basename(). */
-#include <libgen.h>
-#undef basename
+//#include <libgen.h>
+//#undef basename
 
 #ifdef HAVE_SYS_AUXV_H
 #include <sys/auxv.h>
 
 #ifdef HAVE_SYS_AUXV_H
 #include <sys/auxv.h>
 
 /* We include linux/fs.h as last of the system headers, as it
  * otherwise conflicts with sys/mount.h. Yay, Linux is great! */
 
 /* We include linux/fs.h as last of the system headers, as it
  * otherwise conflicts with sys/mount.h. Yay, Linux is great! */
-#include <linux/fs.h>
+//#include <linux/fs.h>
 
 #include "alloc-util.h"
 #include "build.h"
 
 #include "alloc-util.h"
 #include "build.h"
-#include "def.h"
+//#include "def.h"
 //#include "device-nodes.h"
 #include "dirent-util.h"
 //#include "env-util.h"
 //#include "device-nodes.h"
 #include "dirent-util.h"
 //#include "env-util.h"
-#include "escape.h"
+//#include "escape.h"
 //#include "exit-status.h"
 #include "fd-util.h"
 #include "fileio.h"
 //#include "exit-status.h"
 #include "fd-util.h"
 #include "fileio.h"
-#include "formats-util.h"
-#include "gunicode.h"
+//#include "formats-util.h"
+//#include "gunicode.h"
 #include "hashmap.h"
 #include "hashmap.h"
-#include "hexdecoct.h"
+//#include "hexdecoct.h"
 #include "hostname-util.h"
 //#include "ioprio.h"
 #include "hostname-util.h"
 //#include "ioprio.h"
-#include "log.h"
+//#include "log.h"
 #include "macro.h"
 #include "macro.h"
-#include "missing.h"
-#include "mkdir.h"
+//#include "missing.h"
+//#include "mkdir.h"
 #include "parse-util.h"
 #include "parse-util.h"
-#include "path-util.h"
+//#include "path-util.h"
 #include "process-util.h"
 #include "process-util.h"
-#include "random-util.h"
+//#include "random-util.h"
 #include "signal-util.h"
 #include "set.h"
 #include "signal-util.h"
 #include "set.h"
-#include "sparse-endian.h"
+//#include "sparse-endian.h"
 #include "stat-util.h"
 #include "stat-util.h"
-#include "string-table.h"
+//#include "string-table.h"
 #include "string-util.h"
 #include "strv.h"
 #include "string-util.h"
 #include "strv.h"
-#include "terminal-util.h"
+//#include "terminal-util.h"
 #include "user-util.h"
 #include "user-util.h"
-#include "utf8.h"
+//#include "utf8.h"
 #include "util.h"
 #include "util.h"
-#include "virt.h"
+//#include "virt.h"
 
 /* Put this test here for a lack of better place */
 assert_cc(EAGAIN == EWOULDBLOCK);
 
 /* Put this test here for a lack of better place */
 assert_cc(EAGAIN == EWOULDBLOCK);
@@ -266,9 +266,11 @@ void execute_directories(const char* const* directories, usec_t timeout, char *a
         wait_for_terminate_and_warn(name, executor_pid, true);
 }
 
         wait_for_terminate_and_warn(name, executor_pid, true);
 }
 
+#if 0 /// UNNEEDED by elogind
 bool plymouth_running(void) {
         return access("/run/plymouth/pid", F_OK) >= 0;
 }
 bool plymouth_running(void) {
         return access("/run/plymouth/pid", F_OK) >= 0;
 }
+#endif // 0
 
 bool display_is_local(const char *display) {
         assert(display);
 
 bool display_is_local(const char *display) {
         assert(display);
@@ -304,6 +306,7 @@ int socket_from_display(const char *display, char **path) {
         return 0;
 }
 
         return 0;
 }
 
+#if 0 /// UNNEEDED by elogind
 int block_get_whole_disk(dev_t d, dev_t *ret) {
         char *p, *s;
         int r;
 int block_get_whole_disk(dev_t d, dev_t *ret) {
         char *p, *s;
         int r;
@@ -393,6 +396,7 @@ int prot_from_flags(int flags) {
                 return -EINVAL;
         }
 }
                 return -EINVAL;
         }
 }
+#endif // 0
 
 int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...) {
         bool stdout_is_tty, stderr_is_tty;
 
 int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...) {
         bool stdout_is_tty, stderr_is_tty;
@@ -520,6 +524,7 @@ bool in_initrd(void) {
         return saved;
 }
 
         return saved;
 }
 
+#if 0 /// UNNEEDED by elogind
 /* hey glibc, APIs with callbacks without a user pointer are so useless */
 void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
                  int (*compar) (const void *, const void *, void *), void *arg) {
 /* hey glibc, APIs with callbacks without a user pointer are so useless */
 void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
                  int (*compar) (const void *, const void *, void *), void *arg) {
@@ -659,6 +664,7 @@ bool id128_is_valid(const char *s) {
 
         return true;
 }
 
         return true;
 }
+#endif // 0
 
 int container_get_leader(const char *machine, pid_t *pid) {
         _cleanup_free_ char *s = NULL, *class = NULL;
 
 int container_get_leader(const char *machine, pid_t *pid) {
         _cleanup_free_ char *s = NULL, *class = NULL;
@@ -821,6 +827,7 @@ uint64_t physical_memory(void) {
         return (uint64_t) mem * (uint64_t) page_size();
 }
 
         return (uint64_t) mem * (uint64_t) page_size();
 }
 
+#if 0 /// UNNEEDED by elogind
 int update_reboot_param_file(const char *param) {
         int r = 0;
 
 int update_reboot_param_file(const char *param) {
         int r = 0;
 
@@ -833,6 +840,7 @@ int update_reboot_param_file(const char *param) {
 
         return 0;
 }
 
         return 0;
 }
+#endif // 0
 
 int version(void) {
         puts(PACKAGE_STRING "\n"
 
 int version(void) {
         puts(PACKAGE_STRING "\n"
index d9d2f72b750314afda0a039576a007b54512afa0..d88337126f27e130367eddc4766efc28063e05ab 100644 (file)
@@ -61,12 +61,16 @@ static inline const char* one_zero(bool b) {
 
 void execute_directories(const char* const* directories, usec_t timeout, char *argv[]);
 
 
 void execute_directories(const char* const* directories, usec_t timeout, char *argv[]);
 
+#if 0 /// UNNEEDED by elogind
 bool plymouth_running(void);
 bool plymouth_running(void);
+#endif // 0
 
 bool display_is_local(const char *display) _pure_;
 int socket_from_display(const char *display, char **path);
 
 
 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);
 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)
 
 #define NULSTR_FOREACH(i, l)                                    \
         for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)
@@ -77,17 +81,21 @@ int block_get_whole_disk(dev_t d, dev_t *ret);
 extern int saved_argc;
 extern char **saved_argv;
 
 extern int saved_argc;
 extern char **saved_argv;
 
+#if 0 /// UNNEEDED by elogind
 bool kexec_loaded(void);
 
 int prot_from_flags(int flags) _const_;
 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);
 
 
 int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *path, ...);
 
 bool in_initrd(void);
 
+#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);
 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
 
 /**
  * Normal qsort requires base to be nonnull. Here were require
@@ -101,7 +109,9 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size, comparison_
         qsort(base, nmemb, size, compar);
 }
 
         qsort(base, nmemb, size, compar);
 }
 
+#if 0 /// UNNEEDED by elogind
 int on_ac_power(void);
 int on_ac_power(void);
+#endif // 0
 
 #define memzero(x,l) (memset((x), 0, (l)))
 #define zero(x) (memzero(&(x), sizeof(x)))
 
 #define memzero(x,l) (memset((x), 0, (l)))
 #define zero(x) (memzero(&(x), sizeof(x)))
@@ -117,6 +127,7 @@ static inline void _reset_errno_(int *saved_errno) {
 
 #define PROTECT_ERRNO _cleanup_(_reset_errno_) __attribute__((unused)) int _saved_errno_ = errno
 
 
 #define PROTECT_ERRNO _cleanup_(_reset_errno_) __attribute__((unused)) int _saved_errno_ = errno
 
+#if 0 /// UNNEEDED by elogind
 static inline int negative_errno(void) {
         /* This helper should be used to shut up gcc if you know 'errno' is
          * negative. Instead of "return -errno;", use "return negative_errno();"
 static inline int negative_errno(void) {
         /* This helper should be used to shut up gcc if you know 'errno' is
          * negative. Instead of "return -errno;", use "return negative_errno();"
@@ -125,6 +136,7 @@ static inline int negative_errno(void) {
         assert_return(errno > 0, -EINVAL);
         return -errno;
 }
         assert_return(errno > 0, -EINVAL);
         return -errno;
 }
+#endif // 0
 
 static inline unsigned u64log2(uint64_t n) {
 #if __SIZEOF_LONG_LONG__ == 8
 
 static inline unsigned u64log2(uint64_t n) {
 #if __SIZEOF_LONG_LONG__ == 8
@@ -163,7 +175,9 @@ static inline unsigned log2u_round_up(unsigned x) {
         return log2u(x - 1) + 1;
 }
 
         return log2u(x - 1) + 1;
 }
 
+#if 0 /// UNNEEDED by elogind
 bool id128_is_valid(const char *s) _pure_;
 bool id128_is_valid(const char *s) _pure_;
+#endif // 0
 
 int container_get_leader(const char *machine, pid_t *pid);
 
 
 int container_get_leader(const char *machine, pid_t *pid);
 
@@ -172,6 +186,8 @@ int namespace_enter(int pidns_fd, int mntns_fd, int netns_fd, int userns_fd, int
 
 uint64_t physical_memory(void);
 
 
 uint64_t physical_memory(void);
 
+#if 0 /// UNNEEDED by elogind
 int update_reboot_param_file(const char *param);
 int update_reboot_param_file(const char *param);
+#endif // 0
 
 int version(void);
 
 int version(void);