xref: /freebsd/crypto/openssh/openbsd-compat/bsd-getpagesize.c (revision a134ebd6e63f658f2d3d04ac0c60d23bcaa86dd7)
1 /* Placed in the public domain */
2 
3 #include "includes.h"
4 
5 #ifndef HAVE_GETPAGESIZE
6 
7 #include <unistd.h>
8 #include <limits.h>
9 
10 int
11 getpagesize(void)
12 {
13 #if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
14 	long r = sysconf(_SC_PAGESIZE);
15 	if (r > 0 && r < INT_MAX)
16 		return (int)r;
17 #endif
18 	/*
19 	 * This is at the lower end of common values and appropriate for
20 	 * our current use of getpagesize() in recallocarray().
21 	 */
22 	return 4096;
23 }
24 
25 #endif /* HAVE_GETPAGESIZE */
26