summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-getpagesize.c
diff options
context:
space:
mode:
authornicoo <nicoo@debian.org>2020-02-12 13:43:18 +0100
committerNicolas Braud-Santoni <nicolas@braud-santoni.eu>2020-02-12 13:43:18 +0100
commit88a8bdd35ca7fb0c1ce70abdd8262d958fedafc1 (patch)
treece42d9d46d371c05eed82d8bb1e8aa7b2522a769 /openbsd-compat/bsd-getpagesize.c
parent4e06e4554b69e678110563b1cf00a258a202dd7b (diff)
parentc79050aa44b8836d836c5dd22a383a073c28b74b (diff)
Merge upstream release 1.3.0 into debian/sid
Diffstat (limited to 'openbsd-compat/bsd-getpagesize.c')
-rw-r--r--openbsd-compat/bsd-getpagesize.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/openbsd-compat/bsd-getpagesize.c b/openbsd-compat/bsd-getpagesize.c
new file mode 100644
index 0000000..903bfc3
--- /dev/null
+++ b/openbsd-compat/bsd-getpagesize.c
@@ -0,0 +1,27 @@
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
12int
13getpagesize(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) */