blob: 416a8d4cb72f19abce96e28fdeac386e920d0ef7 [file] [log] [blame]
Damien Miller151c6e42017-06-01 15:25:13 +10001/* Placed in the public domain */
2
Darren Tuckerf21455a2017-10-31 10:09:33 +11003#include "includes.h"
4
Damien Miller151c6e42017-06-01 15:25:13 +10005#ifndef HAVE_GETPAGESIZE
6
7#include <unistd.h>
8#include <limits.h>
9
10int
11getpagesize(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 */