pageshift?

Jack Howarth howarth@bromo.med.uc.edu
Sat Oct 21 09:29:00 GMT 2000


Hi,
    On ppc our maintainer Paul Mackerras <paulus@linuxcare.com>
for Linux 2.4 has decided to place tight wrappers around our
asm-ppc kernel headers of the form...

#ifdef __KERNEL__

#endif /* __KERNEL__ */

While the breakage of userland programs incorrectly using
kernel headers isn't as bad as I feared,  I have found that
procps from Redhat 7.0 has a sprinkling of PAGE_SIZE and 
PAGE_SHIFT obtained from asm/page.h.
I believe they should be able to get PAGE_SIZE from
the _getpagesize() call declared in sys/shm.h however I am
unclear how to back calculate PAGE_SHIFT. The asm/page.h header
contains...

#define PAGE_SHIFT	12
#define PAGE_SIZE	(1UL << PAGE_SHIFT)

...and since PAGE_SHIFT can calculate PAGE_SIZE I assume I can do
the inverse. Below is the test code I have written so far...

-----------------------------------------

#include <stdio.h>
#include <sys/shm.h>

#define PAGE_SHIFT	12
#define PAGE_SIZE	(1UL << PAGE_SHIFT)

int pagesize;

main()
{
pagesize=__getpagesize();
printf("pagesize is %d\n",pagesize);
printf("pagesize is %d\n",PAGE_SIZE);
}

---------------------------------------------    

I am also concerned if I have to pass a parameter to __getpagesize or
if my approach of passing no parameters is valid.
                  Thanks in advance for any help.
                            Jack Howarth


More information about the Libc-alpha mailing list