From 67905e2d7c6ee273b753af22fb22de0ebec918c1 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 26 Jul 2011 13:42:12 +0200 Subject: [PATCH] *: work around sysinfo.h versus linux/*.h problems Signed-off-by: Denys Vlasenko --- include/libbb.h | 10 ++++++---- init/init.c | 3 ++- procps/free.c | 3 +++ procps/ps.c | 3 +++ procps/uptime.c | 4 ++++ 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/libbb.h b/include/libbb.h index 3d31ff225..63d041957 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -52,10 +52,12 @@ #ifdef HAVE_SYS_STATFS_H # include #endif -/* struct sysinfo is linux-specific */ -#ifdef __linux__ -# include -#endif +/* Don't do this here: + * #include + * 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 # include diff --git a/init/init.c b/init/init.c index ff9dc06a4..645f694c0 100644 --- a/init/init.c +++ b/init/init.c @@ -113,7 +113,8 @@ #include #include #ifdef __linux__ -#include +# include +# include #endif #include "reboot.h" /* reboot() constants */ diff --git a/procps/free.c b/procps/free.c index ca753134c..47f2fc3b2 100644 --- a/procps/free.c +++ b/procps/free.c @@ -22,6 +22,9 @@ //usage: "Total: 386144 257128 129016\n" #include "libbb.h" +#ifdef __linux__ +# include +#endif struct globals { unsigned mem_unit; diff --git a/procps/ps.c b/procps/ps.c index 7537118f6..dcc0f7bd4 100644 --- a/procps/ps.c +++ b/procps/ps.c @@ -62,6 +62,9 @@ enum { MAX_WIDTH = 2*1024 }; #if ENABLE_DESKTOP +#ifdef __linux__ +# include +#endif #include /* for times() */ #ifndef AT_CLKTCK # define AT_CLKTCK 17 diff --git a/procps/uptime.c b/procps/uptime.c index 1a7da46a3..74323625d 100644 --- a/procps/uptime.c +++ b/procps/uptime.c @@ -25,6 +25,10 @@ //usage: " 1:55pm up 2:30, load average: 0.09, 0.04, 0.00\n" #include "libbb.h" +#ifdef __linux__ +# include +#endif + #ifndef FSHIFT # define FSHIFT 16 /* nr of bits of precision */