[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] busybox-1.00-pre3 "fix" procps/top.c when -O2 used on crisarch



Hi busybox developers!

When compiling busybox-1.00-pre3/ for the Axis developer board with it's
cris arch I can not compile busybox. As I found out this is because the
axis developer system adds "-O2" to the default extra cflags. Here's the
output of the compile:

gcc-cris  -isystem /home/fl/axis/devboard_82/target/cris-axis-linux-gnu/include -mlinux -I./include -Wall -Wstrict-prototypes -Wshadow -Os -fomit-frame-pointer -D_GNU_SOURCE -DNDEBUG  -Wall -Wshadow -O2 -g  -c -o procps/top.o procps/top.c
procps/top.c:378:1: directives may not be used inside a macro argument
procps/top.c:377:60: unterminated argument list invoking macro "printf"
procps/top.c: In function `display_status':
procps/top.c:381: parse error before "s"
make[1]: *** [procps/top.o] Fehler 1
make[1]: Leaving directory `/opt/develop/axis/devboard_82/apps/busybox/busybox-1.00-pre3'

# cris-gcc --version
cris-axis-elf-gcc (GCC) 3.2.1 Axis release R54/1.54
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

To fix this I had to make the changes below to the source of busybox
top. The problem is that the compile can not check the printf when
there are #ifdef's distributed across a call to printf. If this essentially
a bug of the supplied compiler or not is out of my knowledge.

--- busybox-1.00-pre3/procps/top.c.org	2003-12-07 21:12:23.000000000 +0100
+++ busybox-1.00-pre3/procps/top.c	2003-12-07 21:17:33.000000000 +0100
@@ -374,15 +374,14 @@
  		else
  			sprintf(rss_str_buf, "%7ld", s->rss);
  #ifdef FEATURE_CPU_USAGE_PERCENTAGE
-		printf("%5d %-8s %s  %s %5d %2d.%d %2u.%u ",
-#else
-		printf("%5d %-8s %s  %s %5d %2u.%u ",
-#endif
-			s->pid, s->user, s->state, rss_str_buf, s->ppid,
-#ifdef FEATURE_CPU_USAGE_PERCENTAGE
-			s->pcpu/10, s->pcpu%10,
+			printf("%5d %-8s %s  %s %5d %2d.%d %2u.%u ",
+				s->pid, s->user, s->state, rss_str_buf, s->ppid,
+				s->pcpu/10, s->pcpu%10, pmem/10, pmem%10);
+#else
+			printf("%5d %-8s %s  %s %5d %2u.%u ",
+				s->pid, s->user, s->state, rss_str_buf, s->ppid,
+				pmem/10, pmem%10);
  #endif
-			pmem/10, pmem%10);
  			if(strlen(namecmd) > col)
  				namecmd[col] = 0;
  			printf("%s\n", namecmd);


-- 
MfG / Regards
Friedrich Lobenstock