[PATCH] procps.c: Include sys/param.h

Shaun Jackman sjackman at gmail.com
Tue Apr 25 16:16:23 UTC 2006


On 4/24/06, Rich Felker <dalias at aerifal.cx> wrote:
...
> Actually neither is portable. What are you trying to get? As far as I
> know everything that could be obtained historically from sys/param.h
> is in limits.h, possibly with slightly different names.

You're correct. I was looking for a definition of PAGE_SHIFT, and I
found including sys/param.h worked on both glibc and newlib. However,
the standard definition is called PAGESIZE, with slightly different
semantics, and is defined in limits.h. My updated patch follows.

I removed the call to getpagesize, due to its being deprecated. If a
back up to PAGESIZE is still desired, sysconf(_SC_PAGESIZE) could be
used. I'm not sure this is necessary though. If it is, I'd rather move
this sort of magic to libbb.h with something like...

#if !defined PAGESIZE && defined _SC_PAGESIZE
# define PAGESIZE sysconf(_SC_PAGESIZE)
#endif

Cheers,
Shaun

2006-04-25  Shaun Jackman  <sjackman at gmail.com>

	* libbb/procps.c: Include limits.h instead of asm/page.h.
	(procps_scan): Use PAGESIZE instead of PAGE_SHIFT.

--- libbb/procps.c	c8e097bb0e4371fd78e2ea0b66ce2ef1b2689a46
+++ libbb/procps.c	0d98949da0241e1c3bd13ccaf77a002c75a2f248
@@ -9,11 +9,11 @@
  */

 #include <dirent.h>
+#include <fcntl.h>
+#include <limits.h>
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <asm/page.h>
-#include <fcntl.h>

  #include "libbb.h"

@@ -117,13 +117,8 @@
  			curstatus.state[2] = 'N';
 		else
  			curstatus.state[2] = ' ';
+		curstatus.rss *= (PAGESIZE >> 10); /* 2**10 = 1kb */

-#ifdef PAGE_SHIFT
-		curstatus.rss <<= (PAGE_SHIFT - 10);     /* 2**10 = 1kb */
-#else
-		curstatus.rss *= (getpagesize() >> 10);     /* 2**10 = 1kb */
-#endif
-
 		if(save_user_arg0) {
  			strcpy(status_tail, "/cmdline");
  			n = read_to_buf(status, buf);


More information about the busybox mailing list