[PATCH 3/5] Use sysconf(_SC_PAGESIZE) to determine PAGE_SIZE

Denys Vlasenko vda.linux at googlemail.com
Fri Jun 3 19:29:26 UTC 2011


On Friday 03 June 2011 20:47, Dan Fandrich wrote:
> On Fri, Jun 03, 2011 at 08:41:12PM +0200, Denys Vlasenko wrote:
> > I think this is not necessary: old code works too, right?
> 
> It works, IF you can find where PAGE_SIZE is defined. It takes including one
> of at least three different header files to get it, and on some systems
> it's apparently called PAGESIZE instead.

The code in question is:

/* Try to pull in PAGE_SIZE */
#ifdef __linux__
# include <sys/user.h>
#endif
#ifdef __GNU__ /* Hurd */
# include <mach/vm_param.h>
#endif
#ifndef PAGE_SIZE
# define PAGE_SIZE (4*1024) /* guess */
#endif

it already contains a fallback, so it will work even if previous includes
didn't find PAGER_SIZE.

Moreover, PAGE_SIZE is only used for 

        mallopt(M_TRIM_THRESHOLD, 2 * PAGE_SIZE);
        mallopt(M_MMAP_THRESHOLD, 8 * PAGE_SIZE - 256);

We can simply use fixed constants instead.

-- 
vda


More information about the busybox mailing list