*: work around sysinfo.h versus linux/*.h problems
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 26 Jul 2011 11:42:12 +0000 (13:42 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 26 Jul 2011 11:42:12 +0000 (13:42 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
include/libbb.h
init/init.c
procps/free.c
procps/ps.c
procps/uptime.c

index 3d31ff225ba6d5b049d44f0f60bc62ac482eda96..63d0419576afe73d694bbcb52db86f23ace94e00 100644 (file)
 #ifdef HAVE_SYS_STATFS_H
 # include <sys/statfs.h>
 #endif
-/* struct sysinfo is linux-specific */
-#ifdef __linux__
-# include <sys/sysinfo.h>
-#endif
+/* Don't do this here:
+ * #include <sys/sysinfo.h>
+ * Some linux/ includes pull in conflicting definition
+ * of struct sysinfo (only in some toolchanins), which breaks build.
+ * Include sys/sysinfo.h only in those files which need it.
+ */
 #if ENABLE_SELINUX
 # include <selinux/selinux.h>
 # include <selinux/context.h>
index ff9dc06a4cb376f55ee8302c425adc6aa37c2e47..645f694c0cc80b2a2ce7a5470a9722a1318fa485 100644 (file)
 #include <paths.h>
 #include <sys/resource.h>
 #ifdef __linux__
-#include <linux/vt.h>
+# include <linux/vt.h>
+# include <sys/sysinfo.h>
 #endif
 #include "reboot.h" /* reboot() constants */
 
index ca753134c102c6aab8a48f8b33bf8cad5e16bcc6..47f2fc3b2597eb3f23b4cda2e899cf41a3802afd 100644 (file)
@@ -22,6 +22,9 @@
 //usage:       "Total:       386144       257128       129016\n"
 
 #include "libbb.h"
+#ifdef __linux__
+# include <sys/sysinfo.h>
+#endif
 
 struct globals {
        unsigned mem_unit;
index 7537118f64a33ce8d989b56713945a2d76e97234..dcc0f7bd45475759163340c72c9a9be9eb93b94f 100644 (file)
@@ -62,6 +62,9 @@ enum { MAX_WIDTH = 2*1024 };
 
 #if ENABLE_DESKTOP
 
+#ifdef __linux__
+# include <sys/sysinfo.h>
+#endif
 #include <sys/times.h> /* for times() */
 #ifndef AT_CLKTCK
 # define AT_CLKTCK 17
index 1a7da46a361769371c04ffc8e8f33d5fd4872abc..74323625db0f4e9c3a2f6ab761509ed80d6d9ea1 100644 (file)
 //usage:       "  1:55pm  up  2:30, load average: 0.09, 0.04, 0.00\n"
 
 #include "libbb.h"
+#ifdef __linux__
+# include <sys/sysinfo.h>
+#endif
+
 
 #ifndef FSHIFT
 # define FSHIFT 16              /* nr of bits of precision */