From 47f4703c33c4936fd423c2a1180b2de144115d3d Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 11 May 2020 10:51:21 -0700 Subject: [PATCH] libbacktrace: declare getpagesize if necessary libbacktrace/ PR libbacktrace/95012 * configure.ac: Check for getpagesize declaration. * mmap.c: Declare getpagesize if necessary. * mmapio.c: Likewise. --- libbacktrace/ChangeLog | 10 ++++++++++ libbacktrace/Makefile.in | 2 +- libbacktrace/config.h.in | 4 ++++ libbacktrace/configure | 10 ++++++++++ libbacktrace/configure.ac | 2 +- libbacktrace/mmap.c | 4 ++++ libbacktrace/mmapio.c | 4 ++++ 7 files changed, 34 insertions(+), 2 deletions(-) diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index 88dee9983d3..37678526893 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -1,3 +1,13 @@ +2020-05-11 Ian Lance Taylor + + 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. + 2020-05-09 Roland McGrath * elf.c (elf_add): Bail early if there are no section headers at all. diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in index 9381adebebc..3fbbb05a100 100644 --- a/libbacktrace/Makefile.in +++ b/libbacktrace/Makefile.in @@ -2266,7 +2266,7 @@ uninstall-am: @HAVE_DSYMUTIL_TRUE@%.dSYM: % -@HAVE_DSYMUTIL_TRUE@ $(DSYMUTIL) %< +@HAVE_DSYMUTIL_TRUE@ $(DSYMUTIL) $< @HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@elf_for_test.c: elf.c @HAVE_ELF_TRUE@@HAVE_OBJCOPY_DEBUGLINK_TRUE@@NATIVE_TRUE@ SEARCH='^#define SYSTEM_BUILD_ID_DIR.*$$'; \ diff --git a/libbacktrace/config.h.in b/libbacktrace/config.h.in index f6e3cba18d0..2303880b9b8 100644 --- a/libbacktrace/config.h.in +++ b/libbacktrace/config.h.in @@ -12,6 +12,10 @@ /* Define to 1 if you have the `clock_gettime' function. */ #undef HAVE_CLOCK_GETTIME +/* Define to 1 if you have the declaration of `getpagesize', and to 0 if you + don't. */ +#undef HAVE_DECL_GETPAGESIZE + /* Define to 1 if you have the declaration of `strnlen', and to 0 if you don't. */ #undef HAVE_DECL_STRNLEN diff --git a/libbacktrace/configure b/libbacktrace/configure index 980c9d2bf89..f6e35c2edee 100755 --- a/libbacktrace/configure +++ b/libbacktrace/configure @@ -13166,6 +13166,16 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_STRNLEN $ac_have_decl _ACEOF +ac_fn_c_check_decl "$LINENO" "getpagesize" "ac_cv_have_decl_getpagesize" "$ac_includes_default" +if test "x$ac_cv_have_decl_getpagesize" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_GETPAGESIZE $ac_have_decl +_ACEOF for ac_func in lstat readlink do : diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac index 6f241c5bac0..7c073facbd8 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 -- 2.30.2