xref: /freebsd/crypto/openssh/openbsd-compat/bsd-getpagesize.c (revision cddbc3b40812213ff00041f79174cac0be360a2a)
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