Reportedly mingw-w64-gcc has mmap and getpagesize but does not provide
a declaration of getpagesize in any header files.  Check for a
getpagesize declaration, and declare it if necessary.  This is for PR
95012.  Bootstrapped and ran libbacktrace tests on
x86_64-pc-linux-gnu.  Committed to master.

Ian

2020-05-11  Ian Lance Taylor  <i...@golang.org>

PR libbacktrace/95012
* configure.ac: Check for getpagesize declaration.
* mmap.c: Declare getpagesize if necessary.
* mmapio.c: Likewise.
* configure: Regenerate.
* config.h.in: Regenerate.
* Makefile.in: Regenerate.
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index 6f241c5bac0..de9cf628b47 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -376,7 +376,7 @@ if test "$have_fcntl" = "yes"; then
            [Define to 1 if you have the fcntl function])
 fi
 
-AC_CHECK_DECLS(strnlen)
+AC_CHECK_DECLS(strnlen getpagesize)
 AC_CHECK_FUNCS(lstat readlink)
 
 # Check for getexecname function.
diff --git a/libbacktrace/mmap.c b/libbacktrace/mmap.c
index dd7d519cc56..6c8bd5d4a19 100644
--- a/libbacktrace/mmap.c
+++ b/libbacktrace/mmap.c
@@ -42,6 +42,10 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include "backtrace.h"
 #include "internal.h"
 
+#ifndef HAVE_DECL_GETPAGESIZE
+extern int getpagesize (void);
+#endif
+
 /* Memory allocation on systems that provide anonymous mmap.  This
    permits the backtrace functions to be invoked from a signal
    handler, assuming that mmap is async-signal safe.  */
diff --git a/libbacktrace/mmapio.c b/libbacktrace/mmapio.c
index 5dd39525ba1..69cd8065a49 100644
--- a/libbacktrace/mmapio.c
+++ b/libbacktrace/mmapio.c
@@ -40,6 +40,10 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include "backtrace.h"
 #include "internal.h"
 
+#ifndef HAVE_DECL_GETPAGESIZE
+extern int getpagesize (void);
+#endif
+
 #ifndef MAP_FAILED
 #define MAP_FAILED ((void *)-1)
 #endif

Reply via email to