diff options
Diffstat (limited to 'openbsd-compat/bsd-getpagesize.c')
-rw-r--r-- | openbsd-compat/bsd-getpagesize.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/openbsd-compat/bsd-getpagesize.c b/openbsd-compat/bsd-getpagesize.c new file mode 100644 index 000000000..9daddfbd3 --- /dev/null +++ b/openbsd-compat/bsd-getpagesize.c | |||
@@ -0,0 +1,23 @@ | |||
1 | /* Placed in the public domain */ | ||
2 | |||
3 | #ifndef HAVE_GETPAGESIZE | ||
4 | |||
5 | #include <unistd.h> | ||
6 | #include <limits.h> | ||
7 | |||
8 | int | ||
9 | getpagesize(void) | ||
10 | { | ||
11 | #if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) | ||
12 | long r = sysconf(_SC_PAGESIZE); | ||
13 | if (r > 0 && r < INT_MAX) | ||
14 | return (int)r; | ||
15 | #endif | ||
16 | /* | ||
17 | * This is at the lower end of common values and appropriate for | ||
18 | * our current use of getpagesize() in recallocarray(). | ||
19 | */ | ||
20 | return 4096; | ||
21 | } | ||
22 | |||
23 | #endif /* HAVE_GETPAGESIZE */ | ||