xref: /original-bsd/lib/libc/gen/getpagesize.c (revision 48611f03)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)getpagesize.c	5.1 (Berkeley) 04/04/93";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <sys/param.h>
13 #include <sys/sysctl.h>
14 
15 #if __STDC__
16 int
17 getpagesize(void)
18 #else
19 int
20 getpagesize()
21 #endif
22 {
23 	int mib[2], size, value;
24 
25 	mib[0] = CTL_HW;
26 	mib[1] = HW_PAGESIZE;
27 	size = sizeof value;
28 	if (sysctl(mib, 2, &value, &size, NULL, 0) == -1)
29 		return (-1);
30 	return (value);
31 }
32