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