From: Bruno Haible Date: Sun, 13 May 2018 16:28:35 +0000 (+0200) Subject: getpagesize: Fix compilation error on Android. X-Git-Tag: v1.0~5606 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=0cc0345974e41e79aa8041939f63f971b9bce335;p=gnulib.git getpagesize: Fix compilation error on Android. * m4/getpagesize.m4 (gl_CHECK_FUNC_GETPAGESIZE): New macro. (gl_FUNC_GETPAGESIZE): Invoke it instead of AC_CHECK_FUNC. * m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Don't invoke AC_CHECK_FUNC. Instead, invoke gl_CHECK_FUNC_GETPAGESIZE and define HAVE_GETPAGESIZE accordingly. * modules/getcwd (Files): Add m4/getpagesize.m4. --- diff --git a/ChangeLog b/ChangeLog index 8643efa423..611bdc501f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2018-05-13 Bruno Haible + + getpagesize: Fix compilation error on Android. + * m4/getpagesize.m4 (gl_CHECK_FUNC_GETPAGESIZE): New macro. + (gl_FUNC_GETPAGESIZE): Invoke it instead of AC_CHECK_FUNC. + * m4/getcwd-abort-bug.m4 (gl_FUNC_GETCWD_ABORT_BUG): Don't invoke + AC_CHECK_FUNC. Instead, invoke gl_CHECK_FUNC_GETPAGESIZE and define + HAVE_GETPAGESIZE accordingly. + * modules/getcwd (Files): Add m4/getpagesize.m4. + 2018-05-13 Bruno Haible tcgetsid: Fix compilation error on Android. diff --git a/m4/getcwd-abort-bug.m4 b/m4/getcwd-abort-bug.m4 index 3115d61466..8904360a2a 100644 --- a/m4/getcwd-abort-bug.m4 +++ b/m4/getcwd-abort-bug.m4 @@ -1,4 +1,4 @@ -# serial 8 +# serial 9 # Determine whether getcwd aborts when the length of the working directory # name is unusually large. Any length between 4k and 16k trigger the bug # when using glibc-2.4.90-9 or older. @@ -16,7 +16,13 @@ AC_DEFUN([gl_FUNC_GETCWD_ABORT_BUG], AC_CHECK_DECLS_ONCE([getcwd]) AC_CHECK_HEADERS_ONCE([unistd.h]) AC_REQUIRE([gl_PATHMAX_SNIPPET_PREREQ]) - AC_CHECK_FUNCS([getpagesize]) + + gl_CHECK_FUNC_GETPAGESIZE + if test $gl_cv_func_getpagesize = yes; then + AC_DEFINE_UNQUOTED([HAVE_GETPAGESIZE], [1], + [Define to 1 if the system has the 'getpagesize' function.]) + fi + AC_CACHE_CHECK([whether getcwd aborts when 4k < cwd_length < 16k], [gl_cv_func_getcwd_abort_bug], [# Remove any remnants of a previous test. diff --git a/m4/getpagesize.m4 b/m4/getpagesize.m4 index 6492c78da2..eb17d60d8e 100644 --- a/m4/getpagesize.m4 +++ b/m4/getpagesize.m4 @@ -1,4 +1,4 @@ -# getpagesize.m4 serial 9 +# getpagesize.m4 serial 10 dnl Copyright (C) 2002, 2004-2005, 2007, 2009-2018 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -9,8 +9,8 @@ AC_DEFUN([gl_FUNC_GETPAGESIZE], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) AC_REQUIRE([AC_CANONICAL_HOST]) - AC_CHECK_FUNCS([getpagesize]) - if test $ac_cv_func_getpagesize = no; then + gl_CHECK_FUNC_GETPAGESIZE + if test $gl_cv_func_getpagesize = no; then HAVE_GETPAGESIZE=0 AC_CHECK_HEADERS([OS.h]) if test $ac_cv_header_OS_h = yes; then @@ -30,3 +30,20 @@ AC_DEFUN([gl_FUNC_GETPAGESIZE], dnl mingw has getpagesize() in libgcc.a but doesn't declare it. AC_CHECK_DECL([getpagesize], , [HAVE_DECL_GETPAGESIZE=0]) ]) + +dnl Tests whether the function getpagesize() exists. +dnl Sets gl_cv_func_getpagesize. +AC_DEFUN([gl_CHECK_FUNC_GETPAGESIZE], +[ + dnl We can't use AC_CHECK_FUNC here, because getpagesize() is defined as a + dnl static inline function when compiling for Android 4.4 or older. + AC_CACHE_CHECK([for getpagesize], [gl_cv_func_getpagesize], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include ]], + [[return getpagesize();]]) + ], + [gl_cv_func_getpagesize=yes], + [gl_cv_func_getpagesize=no]) + ]) +]) diff --git a/modules/getcwd b/modules/getcwd index 77ad097ca3..628c4d1f6f 100644 --- a/modules/getcwd +++ b/modules/getcwd @@ -6,6 +6,7 @@ lib/getcwd.c m4/getcwd-abort-bug.m4 m4/getcwd-path-max.m4 m4/getcwd.m4 +m4/getpagesize.m4 m4/pathmax.m4 Depends-on: