Compiling a testdir for Android 4.3, I get errors like these:

In file included from 
/ANDROID_SDK/ndk-bundle/sysroot/usr/include/stdlib.h:263:0,
                 from ../gllib/stdlib.h:36,
                 from macros.h:22,
                 from test-hypotl.c:29:
/ANDROID_SDK/ndk-bundle/sysroot/usr/include/android/legacy_stdlib_inlines.h:76:22:
 error: static declaration of 'random' follows non-static declaration
 static __inline long random(void) { return lrand48(); }
                      ^
In file included from test-hypotl.c:21:0:
../gllib/stdlib.h:1038:1: note: previous declaration of 'random' was here
 _GL_FUNCDECL_SYS (random, long, (void));
 ^
In file included from 
/ANDROID_SDK/ndk-bundle/sysroot/usr/include/stdlib.h:263:0,
                 from ../gllib/stdlib.h:36,
                 from macros.h:22,
                 from test-hypotl.c:29:
/ANDROID_SDK/ndk-bundle/sysroot/usr/include/android/legacy_stdlib_inlines.h:78:22:
 error: static declaration of 'srandom' follows non-static declaration
 static __inline void srandom(unsigned int __s) { srand48(__s); }
                      ^
In file included from test-hypotl.c:21:0:
../gllib/stdlib.h:1052:1: note: previous declaration of 'srandom' was here
 _GL_FUNCDECL_SYS (srandom, void, (unsigned int seed));
 ^
In file included from 
/ANDROID_SDK/ndk-bundle/sysroot/usr/include/stdlib.h:263:0,
                 from ../gllib/stdlib.h:36,
                 from macros.h:22,
                 from test-hypotl.c:29:
/ANDROID_SDK/ndk-bundle/sysroot/usr/include/android/legacy_stdlib_inlines.h:80:21:
 error: static declaration of 'grantpt' follows non-static declaration
 static __inline int grantpt(int __fd __attribute((unused))) {
                     ^
In file included from test-hypotl.c:21:0:
../gllib/stdlib.h:724:1: note: previous declaration of 'grantpt' was here
 _GL_FUNCDECL_SYS (grantpt, int, (int fd));
 ^

The reason  is that the Android headers define a number of system functions
through 'static inline'. This is the complete list:

./android/legacy_fenv_inlines_arm.h:static __inline int feclearexcept(int 
__excepts) {
./android/legacy_fenv_inlines_arm.h:static __inline int fedisableexcept(int 
__mask __unused) {
./android/legacy_fenv_inlines_arm.h:static __inline int feenableexcept(int 
__mask __unused) {
./android/legacy_fenv_inlines_arm.h:static __inline int fegetenv(fenv_t* 
__envp) {
./android/legacy_fenv_inlines_arm.h:static __inline int fegetexcept(void) {
./android/legacy_fenv_inlines_arm.h:static __inline int 
fegetexceptflag(fexcept_t* __flagp, int __excepts) {
./android/legacy_fenv_inlines_arm.h:static __inline int fegetround(void) {
./android/legacy_fenv_inlines_arm.h:static __inline int feholdexcept(fenv_t* 
__envp) {
./android/legacy_fenv_inlines_arm.h:static __inline int feraiseexcept(int 
__excepts) {
./android/legacy_fenv_inlines_arm.h:static __inline int fesetenv(const fenv_t* 
__envp) {
./android/legacy_fenv_inlines_arm.h:static __inline int fesetexceptflag(const 
fexcept_t* __flagp, int __excepts) {
./android/legacy_fenv_inlines_arm.h:static __inline int fesetround(int __round) 
{
./android/legacy_fenv_inlines_arm.h:static __inline int fetestexcept(int 
__excepts) {
./android/legacy_fenv_inlines_arm.h:static __inline int feupdateenv(const 
fenv_t* __envp) {
./android/legacy_signal_inlines.h:static __inline int sigaddset(sigset_t *set, 
int signum) {
./android/legacy_signal_inlines.h:static __inline int sigdelset(sigset_t *set, 
int signum) {
./android/legacy_signal_inlines.h:static __inline int sigemptyset(sigset_t 
*set) {
./android/legacy_signal_inlines.h:static __inline int sigfillset(sigset_t *set) 
{
./android/legacy_signal_inlines.h:static __inline int sigismember(const 
sigset_t *set, int signum) {
./android/legacy_signal_inlines.h:static __inline sighandler_t signal(int s, 
sighandler_t f) {
./android/legacy_stdlib_inlines.h:static __inline double atof(const char *nptr) 
{ return (strtod(nptr, NULL)); }
./android/legacy_stdlib_inlines.h:static __inline double strtod_l(const char* 
__s, char** __end_ptr, locale_t __l) {
./android/legacy_stdlib_inlines.h:static __inline float strtof(const char* 
nptr, char** endptr) {
./android/legacy_stdlib_inlines.h:static __inline float strtof_l(const char* 
__s, char** __end_ptr, locale_t __l) {
./android/legacy_stdlib_inlines.h:static __inline int abs(int __n) { return 
(__n < 0) ? -__n : __n; }
./android/legacy_stdlib_inlines.h:static __inline int grantpt(int __fd 
__attribute((unused))) {
./android/legacy_stdlib_inlines.h:static __inline int rand(void) { return 
(int)lrand48(); }
./android/legacy_stdlib_inlines.h:static __inline long labs(long __n) { return 
(__n < 0L) ? -__n : __n; }
./android/legacy_stdlib_inlines.h:static __inline long long llabs(long long 
__n) {
./android/legacy_stdlib_inlines.h:static __inline long random(void) { return 
lrand48(); }
./android/legacy_stdlib_inlines.h:static __inline long strtol_l(const char* 
__s, char** __end_ptr, int __base, locale_t __l) {
./android/legacy_stdlib_inlines.h:static __inline void srand(unsigned int __s) 
{ srand48(__s); }
./android/legacy_stdlib_inlines.h:static __inline void srandom(unsigned int 
__s) { srand48(__s); }
./android/legacy_strings_inlines.h:static __inline int ffs(int __n) { return 
__builtin_ffs(__n); }
./android/legacy_sys_stat_inlines.h:static __inline int mkfifo(const char* 
__path, mode_t __mode) {
./android/legacy_sys_wait_inlines.h:static __inline pid_t wait4(pid_t pid, int* 
status, int options, struct rusage* rusage) {
./bits/termios_inlines.h:static __inline speed_t cfgetspeed(const struct 
termios* s) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE speed_t cfgetispeed(const 
struct termios* s) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE speed_t cfgetospeed(const 
struct termios* s) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE void cfmakeraw(struct termios* 
s) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE int cfsetspeed(struct termios* 
s, speed_t speed) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE int cfsetispeed(struct 
termios* s, speed_t speed) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE int cfsetospeed(struct 
termios* s, speed_t speed) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE int tcdrain(int fd) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE int tcflow(int fd, int action) 
{
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE int tcflush(int fd, int queue) 
{
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE int tcgetattr(int fd, struct 
termios* s) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE pid_t tcgetsid(int fd) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE int tcsendbreak(int fd, int 
duration) {
./bits/termios_inlines.h:__BIONIC_TERMIOS_INLINE int tcsetattr(int fd, int 
optional_actions, const struct termios* s) {
./unistd.h:static __inline__ int getpagesize(void) {

A number of these are interacting with gnulib. I'm applying these fixes.


2018-05-13  Bruno Haible  <br...@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  <br...@clisp.org>

        tcgetsid: Fix compilation error on Android.
        * m4/tcgetsid.m4 (gl_FUNC_TCGETSID): Use AC_LINK_IFELSE instead of
        AC_CHECK_FUNC.

2018-05-13  Bruno Haible  <br...@clisp.org>

        getpass: Fix configure test for Android.
        * m4/getpass.m4 (gl_PREREQ_GETPASS): Use AC_LINK_IFELSE instead of
        AC_CHECK_FUNC.

2018-05-13  Bruno Haible  <br...@clisp.org>

        ffs: Fix compilation error on Android.
        * m4/ffs.m4 (gl_FUNC_FFS): Use AC_LINK_IFELSE instead of AC_CHECK_FUNC.

2018-05-13  Bruno Haible  <br...@clisp.org>

        mkfifo: Fix compilation error on Android.
        * m4/mkfifo.m4 (gl_FUNC_MKFIFO): Use AC_LINK_IFELSE instead of
        AC_CHECK_FUNC.

2018-05-13  Bruno Haible  <br...@clisp.org>

        c-strtod: Fix configure test for Android.
        * m4/c-strtod.m4 (gl_C_STRTOD): Use AC_LINK_IFELSE instead of
        AC_CHECK_FUNC.

2018-05-13  Bruno Haible  <br...@clisp.org>

        random: Fix compilation error on Android.
        * m4/random.m4 (gl_FUNC_RANDOM): Use AC_LINK_IFELSE instead of
        AC_CHECK_FUNC.

2018-05-13  Bruno Haible  <br...@clisp.org>

        grantpt: Fix compilation error on Android.
        * m4/grantpt.m4 (gl_FUNC_GRANTPT): Use AC_LINK_IFELSE instead of
        AC_CHECK_FUNC.

>From 052169efee500c4c8a8b9e0433f1cd703f99ea89 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 13 May 2018 15:31:48 +0200
Subject: [PATCH 1/9] grantpt: Fix compilation error on Android.

* m4/grantpt.m4 (gl_FUNC_GRANTPT): Use AC_LINK_IFELSE instead of
AC_CHECK_FUNC.
---
 ChangeLog     |  6 ++++++
 m4/grantpt.m4 | 16 +++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f4c0138..2c6eab8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2018-05-13  Bruno Haible  <br...@clisp.org>
 
+	grantpt: Fix compilation error on Android.
+	* m4/grantpt.m4 (gl_FUNC_GRANTPT): Use AC_LINK_IFELSE instead of
+	AC_CHECK_FUNC.
+
+2018-05-13  Bruno Haible  <br...@clisp.org>
+
 	stdioext: Fix compilation errors with newer Android headers.
 	* lib/stdio-impl.h (fp_, fp_ub): Define differently for Android.
 	(__SLBF, __SNBF, __SRD, __SWR, __SRW, __SEOF, __SERR, __SOFF): Define
diff --git a/m4/grantpt.m4 b/m4/grantpt.m4
index 7e2ee4a..91d8183 100644
--- a/m4/grantpt.m4
+++ b/m4/grantpt.m4
@@ -1,4 +1,4 @@
-# grantpt.m4 serial 2
+# grantpt.m4 serial 3
 dnl Copyright (C) 2010-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -11,8 +11,18 @@ AC_DEFUN([gl_FUNC_GRANTPT],
   dnl Persuade glibc <stdlib.h> to declare grantpt().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS([grantpt])
-  if test $ac_cv_func_grantpt = no; then
+  dnl We can't use AC_CHECK_FUNC here, because grantpt() is defined as a
+  dnl static inline function when compiling for Android 4.4 or older.
+  AC_CACHE_CHECK([for grantpt], [gl_cv_func_grantpt],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <stdlib.h>]],
+          [[return grantpt(0);]])
+       ],
+       [gl_cv_func_grantpt=yes],
+       [gl_cv_func_grantpt=no])
+    ])
+  if test $gl_cv_func_grantpt = no; then
     HAVE_GRANTPT=0
   fi
 ])
-- 
2.7.4

>From 3c82739c334a42470f2b3bbbada10138f04813b1 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 13 May 2018 15:49:40 +0200
Subject: [PATCH 2/9] random: Fix compilation error on Android.

* m4/random.m4 (gl_FUNC_RANDOM): Use AC_LINK_IFELSE instead of
AC_CHECK_FUNC.
---
 ChangeLog    |  6 ++++++
 m4/random.m4 | 16 +++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2c6eab8..908d4ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2018-05-13  Bruno Haible  <br...@clisp.org>
 
+	random: Fix compilation error on Android.
+	* m4/random.m4 (gl_FUNC_RANDOM): Use AC_LINK_IFELSE instead of
+	AC_CHECK_FUNC.
+
+2018-05-13  Bruno Haible  <br...@clisp.org>
+
 	grantpt: Fix compilation error on Android.
 	* m4/grantpt.m4 (gl_FUNC_GRANTPT): Use AC_LINK_IFELSE instead of
 	AC_CHECK_FUNC.
diff --git a/m4/random.m4 b/m4/random.m4
index ba9cf3b..dd4d6fe 100644
--- a/m4/random.m4
+++ b/m4/random.m4
@@ -1,4 +1,4 @@
-# random.m4 serial 2
+# random.m4 serial 3
 dnl Copyright (C) 2012-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,8 +8,18 @@ AC_DEFUN([gl_FUNC_RANDOM],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
 
-  AC_CHECK_FUNCS([random])
-  if test $ac_cv_func_random = no; then
+  dnl We can't use AC_CHECK_FUNC here, because random() is defined as a
+  dnl static inline function when compiling for Android 4.4 or older.
+  AC_CACHE_CHECK([for random], [gl_cv_func_random],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <stdlib.h>]],
+          [[return random() == 0;]])
+       ],
+       [gl_cv_func_random=yes],
+       [gl_cv_func_random=no])
+    ])
+  if test $gl_cv_func_random = no; then
     HAVE_RANDOM=0
   fi
 
-- 
2.7.4

>From da1c4df8732c2805a10ce6534d310642418c21ae Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 13 May 2018 16:03:03 +0200
Subject: [PATCH 3/9] c-strtod: Fix configure test for Android.

* m4/c-strtod.m4 (gl_C_STRTOD): Use AC_LINK_IFELSE instead of
AC_CHECK_FUNC.
---
 ChangeLog      |  6 ++++++
 m4/c-strtod.m4 | 31 +++++++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 908d4ea..bb1f4c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2018-05-13  Bruno Haible  <br...@clisp.org>
 
+	c-strtod: Fix configure test for Android.
+	* m4/c-strtod.m4 (gl_C_STRTOD): Use AC_LINK_IFELSE instead of
+	AC_CHECK_FUNC.
+
+2018-05-13  Bruno Haible  <br...@clisp.org>
+
 	random: Fix compilation error on Android.
 	* m4/random.m4 (gl_FUNC_RANDOM): Use AC_LINK_IFELSE instead of
 	AC_CHECK_FUNC.
diff --git a/m4/c-strtod.m4 b/m4/c-strtod.m4
index ccff0e6..9282cee 100644
--- a/m4/c-strtod.m4
+++ b/m4/c-strtod.m4
@@ -1,4 +1,4 @@
-# c-strtod.m4 serial 15
+# c-strtod.m4 serial 16
 
 # Copyright (C) 2004-2006, 2009-2018 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -37,7 +37,34 @@ dnl Prerequisites of lib/c-strtod.c.
 AC_DEFUN([gl_C_STRTOD],
 [
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_FUNCS([strtod_l])
+
+  AC_CHECK_HEADERS_ONCE([xlocale.h])
+  dnl We can't use AC_CHECK_FUNC here, because strtod_l() is defined as a
+  dnl static inline function when compiling for Android 7.1 or older.
+  AC_CACHE_CHECK([for strtod_l], [gl_cv_func_strtod_l],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <stdlib.h>
+            #include <locale.h>
+            #if HAVE_XLOCALE_H
+            # include <xlocale.h>
+            #endif
+            locale_t loc;
+          ]],
+          [[char *end;
+            return strtod_l("0",&end,loc) < 0.0;
+          ]])
+       ],
+       [gl_cv_func_strtod_l=yes],
+       [gl_cv_func_strtod_l=no])
+    ])
+  if test $gl_cv_func_strtod_l = yes; then
+    HAVE_STRTOD_L=1
+  else
+    HAVE_STRTOD_L=0
+  fi
+  AC_DEFINE_UNQUOTED([HAVE_STRTOD_L], [$HAVE_STRTOD_L],
+    [Define to 1 if the system has the 'strtod_l' function.])
 ])
 
 dnl Prerequisites of lib/c-strtold.c.
-- 
2.7.4

>From b24b6bbf9cf4cdc0d5d011b20dd74916507a6153 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 13 May 2018 16:08:56 +0200
Subject: [PATCH 4/9] mkfifo: Fix compilation error on Android.

* m4/mkfifo.m4 (gl_FUNC_MKFIFO): Use AC_LINK_IFELSE instead of
AC_CHECK_FUNC.
---
 ChangeLog    |  6 ++++++
 m4/mkfifo.m4 | 17 ++++++++++++++---
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index bb1f4c2..181a08c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2018-05-13  Bruno Haible  <br...@clisp.org>
 
+	mkfifo: Fix compilation error on Android.
+	* m4/mkfifo.m4 (gl_FUNC_MKFIFO): Use AC_LINK_IFELSE instead of
+	AC_CHECK_FUNC.
+
+2018-05-13  Bruno Haible  <br...@clisp.org>
+
 	c-strtod: Fix configure test for Android.
 	* m4/c-strtod.m4 (gl_C_STRTOD): Use AC_LINK_IFELSE instead of
 	AC_CHECK_FUNC.
diff --git a/m4/mkfifo.m4 b/m4/mkfifo.m4
index 13c5164..5dda67c 100644
--- a/m4/mkfifo.m4
+++ b/m4/mkfifo.m4
@@ -1,4 +1,4 @@
-# serial 5
+# serial 6
 # See if we need to provide mkfifo replacement.
 
 dnl Copyright (C) 2009-2018 Free Software Foundation, Inc.
@@ -12,8 +12,19 @@ AC_DEFUN([gl_FUNC_MKFIFO],
 [
   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CHECK_FUNCS_ONCE([mkfifo])
-  if test $ac_cv_func_mkfifo = no; then
+
+  dnl We can't use AC_CHECK_FUNC here, because mkfifo() is defined as a
+  dnl static inline function when compiling for Android 4.4 or older.
+  AC_CACHE_CHECK([for mkfifo], [gl_cv_func_mkfifo],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <sys/stat.h>]],
+          [[return mkfifo("/",0);]])
+       ],
+       [gl_cv_func_mkfifo=yes],
+       [gl_cv_func_mkfifo=no])
+    ])
+  if test $gl_cv_func_mkfifo = no; then
     HAVE_MKFIFO=0
   else
     dnl Check for Solaris 9 and FreeBSD bug with trailing slash.
-- 
2.7.4

>From 2afc250c6fae929b95e8b8915b17379cd9f2e450 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 13 May 2018 16:13:27 +0200
Subject: [PATCH 5/9] ffs: Fix compilation error on Android.

* m4/ffs.m4 (gl_FUNC_FFS): Use AC_LINK_IFELSE instead of AC_CHECK_FUNC.
---
 ChangeLog |  5 +++++
 m4/ffs.m4 | 19 ++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 181a08c..3943da8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2018-05-13  Bruno Haible  <br...@clisp.org>
 
+	ffs: Fix compilation error on Android.
+	* m4/ffs.m4 (gl_FUNC_FFS): Use AC_LINK_IFELSE instead of AC_CHECK_FUNC.
+
+2018-05-13  Bruno Haible  <br...@clisp.org>
+
 	mkfifo: Fix compilation error on Android.
 	* m4/mkfifo.m4 (gl_FUNC_MKFIFO): Use AC_LINK_IFELSE instead of
 	AC_CHECK_FUNC.
diff --git a/m4/ffs.m4 b/m4/ffs.m4
index 252e6f6..78b13ee 100644
--- a/m4/ffs.m4
+++ b/m4/ffs.m4
@@ -1,4 +1,4 @@
-# ffs.m4 serial 2
+# ffs.m4 serial 3
 dnl Copyright (C) 2011-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,8 +7,21 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_FFS],
 [
   AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS])
-  AC_CHECK_FUNCS_ONCE([ffs])
-  if test $ac_cv_func_ffs = no; then
+
+  dnl We can't use AC_CHECK_FUNC here, because ffs() is defined as a
+  dnl static inline function when compiling for Android 4.2 or older.
+  AC_CACHE_CHECK([for ffs], [gl_cv_func_ffs],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <strings.h>
+            int x;
+          ]],
+          [[return ffs(x);]])
+       ],
+       [gl_cv_func_ffs=yes],
+       [gl_cv_func_ffs=no])
+    ])
+  if test $gl_cv_func_ffs = no; then
     HAVE_FFS=0
   fi
 ])
-- 
2.7.4

>From 5d35c92b4a44edc4f5e3b6854230c652b85f4fed Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 13 May 2018 16:25:20 +0200
Subject: [PATCH 6/9] getpass: Fix configure test for Android.

* m4/getpass.m4 (gl_PREREQ_GETPASS): Use AC_LINK_IFELSE instead of
AC_CHECK_FUNC.
---
 ChangeLog     |  6 ++++++
 m4/getpass.m4 | 47 ++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3943da8..a2fa28b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2018-05-13  Bruno Haible  <br...@clisp.org>
 
+	getpass: Fix configure test for Android.
+	* m4/getpass.m4 (gl_PREREQ_GETPASS): Use AC_LINK_IFELSE instead of
+	AC_CHECK_FUNC.
+
+2018-05-13  Bruno Haible  <br...@clisp.org>
+
 	ffs: Fix compilation error on Android.
 	* m4/ffs.m4 (gl_FUNC_FFS): Use AC_LINK_IFELSE instead of AC_CHECK_FUNC.
 
diff --git a/m4/getpass.m4 b/m4/getpass.m4
index 8e502f0..7f3fc88 100644
--- a/m4/getpass.m4
+++ b/m4/getpass.m4
@@ -1,4 +1,4 @@
-# getpass.m4 serial 14
+# getpass.m4 serial 15
 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2018 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -43,7 +43,7 @@ AC_DEFUN([gl_FUNC_GETPASS_GNU],
 # Prerequisites of lib/getpass.c.
 AC_DEFUN([gl_PREREQ_GETPASS], [
   AC_CHECK_HEADERS_ONCE([stdio_ext.h termios.h])
-  AC_CHECK_FUNCS_ONCE([__fsetlocking tcgetattr tcsetattr])
+  AC_CHECK_FUNCS_ONCE([__fsetlocking])
   AC_CHECK_DECLS([__fsetlocking],,,
     [[#include <stdio.h>
       #if HAVE_STDIO_EXT_H
@@ -54,5 +54,46 @@ AC_DEFUN([gl_PREREQ_GETPASS], [
   AC_CHECK_DECLS_ONCE([fputs_unlocked])
   AC_CHECK_DECLS_ONCE([funlockfile])
   AC_CHECK_DECLS_ONCE([putc_unlocked])
-  :
+
+  dnl We can't use AC_CHECK_FUNC here, because tcgetattr() is defined as a
+  dnl static inline function when compiling for Android 4.4 or older.
+  AC_CACHE_CHECK([for tcgetattr], [gl_cv_func_tcgetattr],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <termios.h>
+            struct termios x;
+          ]],
+          [[return tcgetattr(0,&x);]])
+       ],
+       [gl_cv_func_tcgetattr=yes],
+       [gl_cv_func_tcgetattr=no])
+    ])
+  if test $gl_cv_func_tcgetattr = yes; then
+    HAVE_TCGETATTR=1
+  else
+    HAVE_TCGETATTR=0
+  fi
+  AC_DEFINE_UNQUOTED([HAVE_TCGETATTR], [$HAVE_TCGETATTR],
+    [Define to 1 if the system has the 'tcgetattr' function.])
+
+  dnl We can't use AC_CHECK_FUNC here, because tcsetattr() is defined as a
+  dnl static inline function when compiling for Android 4.4 or older.
+  AC_CACHE_CHECK([for tcsetattr], [gl_cv_func_tcsetattr],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <termios.h>
+            struct termios x;
+          ]],
+          [[return tcsetattr(0,0,&x);]])
+       ],
+       [gl_cv_func_tcsetattr=yes],
+       [gl_cv_func_tcsetattr=no])
+    ])
+  if test $gl_cv_func_tcsetattr = yes; then
+    HAVE_TCSETATTR=1
+  else
+    HAVE_TCSETATTR=0
+  fi
+  AC_DEFINE_UNQUOTED([HAVE_TCSETATTR], [$HAVE_TCSETATTR],
+    [Define to 1 if the system has the 'tcsetattr' function.])
 ])
-- 
2.7.4

>From 9f442cbb0bd8ed7398aee30c3a3944486a64a058 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 13 May 2018 16:45:11 +0200
Subject: [PATCH 7/9] tcgetsid: Fix compilation error on Android.

* m4/tcgetsid.m4 (gl_FUNC_TCGETSID): Use AC_LINK_IFELSE instead of
AC_CHECK_FUNC.
---
 ChangeLog      |  6 ++++++
 m4/tcgetsid.m4 | 16 +++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a2fa28b..8643efa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2018-05-13  Bruno Haible  <br...@clisp.org>
 
+	tcgetsid: Fix compilation error on Android.
+	* m4/tcgetsid.m4 (gl_FUNC_TCGETSID): Use AC_LINK_IFELSE instead of
+	AC_CHECK_FUNC.
+
+2018-05-13  Bruno Haible  <br...@clisp.org>
+
 	getpass: Fix configure test for Android.
 	* m4/getpass.m4 (gl_PREREQ_GETPASS): Use AC_LINK_IFELSE instead of
 	AC_CHECK_FUNC.
diff --git a/m4/tcgetsid.m4 b/m4/tcgetsid.m4
index 3a91836..bc8c50d 100644
--- a/m4/tcgetsid.m4
+++ b/m4/tcgetsid.m4
@@ -1,4 +1,4 @@
-# tcgetsid.m4 serial 4
+# tcgetsid.m4 serial 5
 dnl Copyright (C) 2010-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -16,8 +16,18 @@ AC_DEFUN([gl_FUNC_TCGETSID],
     HAVE_DECL_TCGETSID=0
   fi
 
-  AC_CHECK_FUNCS([tcgetsid])
-  if test $ac_cv_func_tcgetsid = yes; then
+  dnl We can't use AC_CHECK_FUNC here, because tcgetsid() is defined as a
+  dnl static inline function when compiling for Android 4.4 or older.
+  AC_CACHE_CHECK([for tcgetsid], [gl_cv_func_tcgetsid],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <termios.h>]],
+          [[return tcgetsid(0);]])
+       ],
+       [gl_cv_func_tcgetsid=yes],
+       [gl_cv_func_tcgetsid=no])
+    ])
+  if test $gl_cv_func_tcgetsid = yes; then
     HAVE_TCGETSID=1
   else
     HAVE_TCGETSID=0
-- 
2.7.4

>From 0cc0345974e41e79aa8041939f63f971b9bce335 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 13 May 2018 18:28:35 +0200
Subject: [PATCH 8/9] 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.
---
 ChangeLog              | 10 ++++++++++
 m4/getcwd-abort-bug.m4 | 10 ++++++++--
 m4/getpagesize.m4      | 23 ++++++++++++++++++++---
 modules/getcwd         |  1 +
 4 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8643efa..611bdc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2018-05-13  Bruno Haible  <br...@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  <br...@clisp.org>
+
 	tcgetsid: Fix compilation error on Android.
 	* m4/tcgetsid.m4 (gl_FUNC_TCGETSID): Use AC_LINK_IFELSE instead of
 	AC_CHECK_FUNC.
diff --git a/m4/getcwd-abort-bug.m4 b/m4/getcwd-abort-bug.m4
index 3115d61..8904360 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 6492c78..eb17d60 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 <unistd.h>]],
+          [[return getpagesize();]])
+       ],
+       [gl_cv_func_getpagesize=yes],
+       [gl_cv_func_getpagesize=no])
+    ])
+])
diff --git a/modules/getcwd b/modules/getcwd
index 77ad097..628c4d1 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:
-- 
2.7.4

Reply via email to