From 151c6e433a5f5af761c78de87d7b5d30a453cf5e Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Thu, 1 Jun 2017 15:25:13 +1000 Subject: add recallocarray replacement and dependency recallocarray() needs getpagesize() so add a tiny replacement for that. --- openbsd-compat/bsd-getpagesize.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 openbsd-compat/bsd-getpagesize.c (limited to 'openbsd-compat/bsd-getpagesize.c') diff --git a/openbsd-compat/bsd-getpagesize.c b/openbsd-compat/bsd-getpagesize.c new file mode 100644 index 00000000..9daddfbd --- /dev/null +++ b/openbsd-compat/bsd-getpagesize.c @@ -0,0 +1,23 @@ +/* Placed in the public domain */ + +#ifndef HAVE_GETPAGESIZE + +#include +#include + +int +getpagesize(void) +{ +#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE) + long r = sysconf(_SC_PAGESIZE); + if (r > 0 && r < INT_MAX) + return (int)r; +#endif + /* + * This is at the lower end of common values and appropriate for + * our current use of getpagesize() in recallocarray(). + */ + return 4096; +} + +#endif /* HAVE_GETPAGESIZE */ -- cgit v1.2.3 From f21455a084f9cc3942cf1bde64055a4916849fed Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Tue, 31 Oct 2017 10:09:33 +1100 Subject: Include includes.h for HAVE_GETPAGESIZE. The configure script checks for getpagesize() and sets HAVE_GETPAGESIZE in config.h, but bsd-getpagesize.c forgot to include includes.h (which indirectly includes config.h) so the checks always fails, causing linker issues when linking statically on systems with getpagesize(). Patch from Peter Korsgaard --- openbsd-compat/bsd-getpagesize.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'openbsd-compat/bsd-getpagesize.c') diff --git a/openbsd-compat/bsd-getpagesize.c b/openbsd-compat/bsd-getpagesize.c index 9daddfbd..416a8d4c 100644 --- a/openbsd-compat/bsd-getpagesize.c +++ b/openbsd-compat/bsd-getpagesize.c @@ -1,5 +1,7 @@ /* Placed in the public domain */ +#include "includes.h" + #ifndef HAVE_GETPAGESIZE #include -- cgit v1.2.3