]> Savannah Git Hosting - gnulib.git/commitdiff
getpagesize: Fix compilation error on Android.
authorBruno Haible <bruno@clisp.org>
Sun, 13 May 2018 16:28:35 +0000 (18:28 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 13 May 2018 16:28:35 +0000 (18:28 +0200)
* 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.

ChangeLog
m4/getcwd-abort-bug.m4
m4/getpagesize.m4
modules/getcwd

index 8643efa42385e32d5ccf22fd9a21777c86836b19..611bdc501fbf4aa5e9cd214bb3cab0bc8fdf78a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2018-05-13  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        tcgetsid: Fix compilation error on Android.
index 3115d614660f46fbc4a49931eb6aca9ef4633872..8904360a2a3a60a50c3398fb6402e8d7f483e5f9 100644 (file)
@@ -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.
index 6492c78da268238539ce4c727d9e811f35c7f8c1..eb17d60d8ea1ab77b3d77405649bec4fa3b5c30b 100644 (file)
@@ -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 <unistd.h>]],
+          [[return getpagesize();]])
+       ],
+       [gl_cv_func_getpagesize=yes],
+       [gl_cv_func_getpagesize=no])
+    ])
+])
index 77ad097ca38516b5648bc539ca7242c500e7d64e..628c4d1f6fcdf47e62adea787466e728e8a16837 100644 (file)
@@ -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: