diff options
author | Damien Miller <djm@mindrot.org> | 2017-06-01 15:25:13 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-06-01 15:25:13 +1000 |
commit | 151c6e433a5f5af761c78de87d7b5d30a453cf5e (patch) | |
tree | 77cdffcee99995b20821a8f2a957504e861475d5 /openbsd-compat/bsd-getpagesize.c | |
parent | 01e6f78924da308447e71e9a32c8a6104ef4e888 (diff) |
add recallocarray replacement and dependency
recallocarray() needs getpagesize() so add a tiny replacement for that.
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 */ | ||