Cache pagesize.

This commit is contained in:
pk 1994-09-15 10:49:53 +00:00
parent 07dce62879
commit 9c216a1fb2
1 changed files with 4 additions and 1 deletions

View File

@ -41,13 +41,16 @@ static char sccsid[] = "@(#)getpagesize.c 8.1 (Berkeley) 6/4/93";
int
getpagesize()
{
static int pagsz;
int mib[2], value;
size_t size;
if (pagsz != 0)
return pagsz;
mib[0] = CTL_HW;
mib[1] = HW_PAGESIZE;
size = sizeof value;
if (sysctl(mib, 2, &value, &size, NULL, 0) == -1)
return (-1);
return (value);
return (pagsz = value);
}