bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* More Android patches
       [not found] <87zgag6la4.fsf.ref@yahoo.com>
@ 2023-01-18 13:10 ` Po Lu
  2023-01-18 23:07   ` Bruno Haible
  0 siblings, 1 reply; 3+ messages in thread
From: Po Lu @ 2023-01-18 13:10 UTC (permalink / raw)
  To: bug-gnulib

With the NDK 16.1.4479499 and __ANDROID_API__ set to 8, utimensat and
ftruncate appear in libc.so but not in the system headers.  This patch
seems to fix the problem, except for one part: REPLACE_UTIMENSAT is not
defined.  Would adding:

     REPLACE_UTIMENSAT=1

to the "ac_cv_func_utimensat" = no branch be enough to fix that?

Thanks.

2023-01-18  Po Lu  <luangruo@yahoo.com>

	Fix uses of utimensat and ftruncate on Android API 8 or earlier.

	* m4/unistd_h.m4 (gl_UNISTD_H): Check that ftruncate is really
	there on Android.
	* m4/utimensat.m4: (gl_FUNC_UTIMENSAT): Check that utimensat is
	really present when cross compiling for Android.


diff --git a/m4/utimensat.m4 b/m4/utimensat.m4
index dd210fc989a..f3d1dd9efaa 100644
--- a/m4/utimensat.m4
+++ b/m4/utimensat.m4
@@ -14,6 +14,9 @@ AC_DEFUN
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_CHECK_FUNCS_ONCE([utimensat])
+  # This is necessary for cross-compiles, because otherwise utimensat
+  # will appear to work.
+  gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]])
   if test $ac_cv_func_utimensat = no; then
     HAVE_UTIMENSAT=0
   else
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index f4384027e37..dd799ae27db 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -50,6 +50,7 @@ AC_DEFUN_ONCE
     group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite
     readlink readlinkat rmdir sethostname sleep symlink symlinkat
     truncate ttyname_r unlink unlinkat usleep])
+  gl_CHECK_FUNCS_ANDROID([ftruncate], [[#include <unistd.h>]])
 
   AC_REQUIRE([AC_C_RESTRICT])
 


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: More Android patches
  2023-01-18 13:10 ` More Android patches Po Lu
@ 2023-01-18 23:07   ` Bruno Haible
  2023-01-19 21:02     ` Bruno Haible
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2023-01-18 23:07 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Po Lu

[-- Attachment #1: Type: text/plain, Size: 1476 bytes --]

Po Lu wrote:
> With the NDK 16.1.4479499 and __ANDROID_API__ set to 8, utimensat and
> ftruncate appear in libc.so but not in the system headers.

Thanks for the report. The problem, however, is much larger than these
two symbols. Previously I handled the __INTRODUCED_IN that I found in
the Termux /usr/include files. But you are right: Any developer can use
any NDK from 16b to 25b, since these are those than a developer can
currently download through Android Studio.

In a first step, I searched for the symbols marked with
  __INTRODUCED_IN(x)
or
  __INTRODUCED_IN_NO_GUARD_FOR_NDK(x)
for x = 2 ... 35. This gave me the symbol lists in the attached
android-introduced.zip.

In a second step, I looked for occurrences to AC_CHECK_FUNC[S]
or AC_CHECK_FUNCS_ONCE of these symbols. E.g.
  for s in `cat in-8.txt`; do grep -rw "$s" m4 modules | grep CHECK_FUNC; echo ; done
and replaced these with gl_CHECK_FUNCS_ANDROID invocations.

> REPLACE_UTIMENSAT is not defined.

For the moment, it appears OK to treat these symbols like absent
from the header files and from libc (i.e. HAVE_UTIMENSAT=0).

In theory, you are right: it will be better to mark them as REPLACEd,
so that Gnulib will define a function named 'rpl_utimensat' rather than
'utimensat'. But as this matters only for rare situations with shared
libraries (since on Android, everything links against libc.so, not libc.a),
it can wait a bit.

Here's my current work-in-progress; I'll continue with it tomorrow.


[-- Attachment #2: android-introduced.zip --]
[-- Type: application/zip, Size: 6524 bytes --]

[-- Attachment #3: 0001-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 1548 bytes --]

From bf80de33fe355df9944579416e38a48984b57091 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 18 Jan 2023 19:49:35 +0100
Subject: [PATCH 1/6] Fix warnings for functions introduced in Android API
 level 8.

* m4/ttyname_r.m4 (gl_FUNC_TTYNAME_R): Test for ttyname_r using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
---
 ChangeLog       | 6 ++++++
 m4/ttyname_r.m4 | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 854820e5cf..f314c07671 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-18  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 8.
+	* m4/ttyname_r.m4 (gl_FUNC_TTYNAME_R): Test for ttyname_r using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+
 2023-01-18  Bruno Haible  <bruno@clisp.org>
 
 	getcwd: Speed up on Linux. Add support for Android.
diff --git a/m4/ttyname_r.m4 b/m4/ttyname_r.m4
index 3f027da45a..4a76155469 100644
--- a/m4/ttyname_r.m4
+++ b/m4/ttyname_r.m4
@@ -1,4 +1,4 @@
-# ttyname_r.m4 serial 11
+# ttyname_r.m4 serial 12
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_TTYNAME_R],
     HAVE_DECL_TTYNAME_R=0
   fi
 
-  AC_CHECK_FUNCS([ttyname_r])
+  gl_CHECK_FUNCS_ANDROID([ttyname_r], [[#include <unistd.h>]])
   if test $ac_cv_func_ttyname_r = no; then
     HAVE_TTYNAME_R=0
   else
-- 
2.34.1


[-- Attachment #4: 0002-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 2447 bytes --]

From f321df595150d01f3e8f60da8c6ff8372a91c650 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 18 Jan 2023 20:05:11 +0100
Subject: [PATCH 2/6] Fix warnings for functions introduced in Android API
 level 9.

* m4/pipe2.m4 (gl_FUNC_PIPE2): Test for pipe2 using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Update comments.
---
 ChangeLog       | 7 +++++++
 m4/fdatasync.m4 | 3 ++-
 m4/pipe2.m4     | 4 ++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f314c07671..1b04e507fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-01-18  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 9.
+	* m4/pipe2.m4 (gl_FUNC_PIPE2): Test for pipe2 using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Update comments.
+
 2023-01-18  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 8.
diff --git a/m4/fdatasync.m4 b/m4/fdatasync.m4
index 8c5cc4fdaf..201d7ffb27 100644
--- a/m4/fdatasync.m4
+++ b/m4/fdatasync.m4
@@ -1,4 +1,4 @@
-# fdatasync.m4 serial 7
+# fdatasync.m4 serial 8
 dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,6 +17,7 @@ AC_DEFUN([gl_FUNC_FDATASYNC],
   if test $ac_cv_have_decl_fdatasync = no; then
     HAVE_DECL_FDATASYNC=0
     dnl Mac OS X 10.7 has fdatasync but does not declare it.
+    dnl Likewise Android with API level < 9. Cf. gl_CHECK_FUNCS_ANDROID.
     AC_CHECK_FUNCS([fdatasync])
     if test $ac_cv_func_fdatasync = no; then
       HAVE_FDATASYNC=0
diff --git a/m4/pipe2.m4 b/m4/pipe2.m4
index 501f3a4303..c7ec02e873 100644
--- a/m4/pipe2.m4
+++ b/m4/pipe2.m4
@@ -1,4 +1,4 @@
-# pipe2.m4 serial 2
+# pipe2.m4 serial 3
 dnl Copyright (C) 2009-2023 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,7 +11,7 @@ AC_DEFUN([gl_FUNC_PIPE2],
   dnl Persuade glibc <unistd.h> to declare pipe2().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([pipe2])
+  gl_CHECK_FUNCS_ANDROID([pipe2], [[#include <unistd.h>]])
   if test $ac_cv_func_pipe2 != yes; then
     HAVE_PIPE2=0
   fi
-- 
2.34.1


[-- Attachment #5: 0003-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 9438 bytes --]

From 88a444d933a2fc67e2c90df3bc6af5b1a95146ff Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 18 Jan 2023 20:41:48 +0100
Subject: [PATCH 3/6] Fix warnings for functions introduced in Android API
 level 12.

* m4/ftruncate.m4 (gl_FUNC_FTRUNCATE): Test for ftruncate using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/glob.m4 (gl_PREREQ_GLOB): Test for getpwnam_r using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/nproc.m4 (gl_PREREQ_NPROC): Test for sched_getaffinity using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/pread.m4 (gl_FUNC_PREAD): Test for pread using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/pwrite.m4 (gl_FUNC_PWRITE): Test for pwrite using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/thread.m4 (gl_THREAD): Test for pthread_atfork using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/timegm.m4 (gl_FUNC_TIMEGM): Test for timegm using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Test for utimensat using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/utimens.m4 (gl_UTIMENS): Likewise.
---
 ChangeLog       | 21 +++++++++++++++++++++
 m4/ftruncate.m4 |  4 ++--
 m4/glob.m4      |  4 ++--
 m4/nproc.m4     |  6 +++---
 m4/pread.m4     |  4 ++--
 m4/pwrite.m4    |  4 ++--
 m4/thread.m4    |  4 ++--
 m4/timegm.m4    |  4 ++--
 m4/utimens.m4   |  5 +++--
 m4/utimensat.m4 |  4 ++--
 10 files changed, 41 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1b04e507fa..738b2de22a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2023-01-18  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 12.
+	* m4/ftruncate.m4 (gl_FUNC_FTRUNCATE): Test for ftruncate using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/glob.m4 (gl_PREREQ_GLOB): Test for getpwnam_r using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/nproc.m4 (gl_PREREQ_NPROC): Test for sched_getaffinity using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/pread.m4 (gl_FUNC_PREAD): Test for pread using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/pwrite.m4 (gl_FUNC_PWRITE): Test for pwrite using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/thread.m4 (gl_THREAD): Test for pthread_atfork using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/timegm.m4 (gl_FUNC_TIMEGM): Test for timegm using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Test for utimensat using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/utimens.m4 (gl_UTIMENS): Likewise.
+
 2023-01-18  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 9.
diff --git a/m4/ftruncate.m4 b/m4/ftruncate.m4
index 74c347598d..f48126e856 100644
--- a/m4/ftruncate.m4
+++ b/m4/ftruncate.m4
@@ -1,4 +1,4 @@
-# serial 21
+# serial 22
 
 # See if we need to emulate a missing ftruncate function using _chsize.
 
@@ -10,7 +10,7 @@
 AC_DEFUN([gl_FUNC_FTRUNCATE],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
-  AC_CHECK_FUNCS_ONCE([ftruncate])
+  gl_CHECK_FUNCS_ANDROID([ftruncate], [[#include <unistd.h>]])
   if test $ac_cv_func_ftruncate = yes; then
     m4_ifdef([gl_LARGEFILE], [
       AC_REQUIRE([AC_CANONICAL_HOST])
diff --git a/m4/glob.m4 b/m4/glob.m4
index 354581b3be..847f88038f 100644
--- a/m4/glob.m4
+++ b/m4/glob.m4
@@ -1,4 +1,4 @@
-# glob.m4 serial 27
+# glob.m4 serial 28
 dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -126,5 +126,5 @@ AC_DEFUN([gl_PREREQ_GLOB],
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
   AC_CHECK_HEADERS_ONCE([unistd.h])
   gl_CHECK_FUNCS_ANDROID([getlogin_r], [[#include <unistd.h>]])
-  AC_CHECK_FUNCS_ONCE([getpwnam_r])
+  gl_CHECK_FUNCS_ANDROID([getpwnam_r], [[#include <pwd.h>]])
 ])
diff --git a/m4/nproc.m4 b/m4/nproc.m4
index 3065b7b9bf..c892ad74b7 100644
--- a/m4/nproc.m4
+++ b/m4/nproc.m4
@@ -1,4 +1,4 @@
-# nproc.m4 serial 5
+# nproc.m4 serial 6
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,8 +25,8 @@ AC_DEFUN([gl_PREREQ_NPROC],
      #endif
     ])
 
-  AC_CHECK_FUNCS([sched_getaffinity sched_getaffinity_np \
-                  pstat_getdynamic sysmp sysctl])
+  AC_CHECK_FUNCS([sched_getaffinity_np pstat_getdynamic sysmp sysctl])
+  gl_CHECK_FUNCS_ANDROID([sched_getaffinity], [[#include <sched.h>]])
 
   dnl Test whether sched_getaffinity has the expected declaration.
   dnl glibc 2.3.[0-2]:
diff --git a/m4/pread.m4 b/m4/pread.m4
index ac3c1b7d51..8031f910d4 100644
--- a/m4/pread.m4
+++ b/m4/pread.m4
@@ -1,4 +1,4 @@
-# pread.m4 serial 6
+# pread.m4 serial 7
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_PREAD],
   dnl Persuade glibc <unistd.h> to declare pread().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([pread])
+  gl_CHECK_FUNCS_ANDROID([pread], [[#include <unistd.h>]])
   if test $ac_cv_func_pread = yes; then
     dnl On HP-UX 11.11 with _FILE_OFFSET_BITS=64, pread() on a file returns 0
     dnl instead of a positive value.
diff --git a/m4/pwrite.m4 b/m4/pwrite.m4
index f77d4210d6..48c5255f30 100644
--- a/m4/pwrite.m4
+++ b/m4/pwrite.m4
@@ -1,4 +1,4 @@
-# pwrite.m4 serial 6
+# pwrite.m4 serial 7
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_PWRITE],
   dnl Persuade glibc <unistd.h> to declare pwrite().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([pwrite])
+  gl_CHECK_FUNCS_ANDROID([pwrite], [[#include <unistd.h>]])
   if test $ac_cv_func_pwrite = yes; then
     dnl On HP-UX 11.11 with _FILE_OFFSET_BITS=64, pwrite() on a file does not
     dnl fail when an invalid (negative) offset is passed and uses an arbitrary
diff --git a/m4/thread.m4 b/m4/thread.m4
index 12515f6a93..9c63df39da 100644
--- a/m4/thread.m4
+++ b/m4/thread.m4
@@ -1,4 +1,4 @@
-# thread.m4 serial 3
+# thread.m4 serial 4
 dnl Copyright (C) 2008-2023 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,7 +11,7 @@ AC_DEFUN([gl_THREAD],
   if test $gl_threads_api = posix; then
     gl_save_LIBS="$LIBS"
     LIBS="$LIBS $LIBMULTITHREAD"
-    AC_CHECK_FUNCS([pthread_atfork])
+    gl_CHECK_FUNCS_ANDROID([pthread_atfork], [[#include <pthread.h>]])
     LIBS="$gl_save_LIBS"
   fi
 ])
diff --git a/m4/timegm.m4 b/m4/timegm.m4
index 6079f1a39c..fa84e98db3 100644
--- a/m4/timegm.m4
+++ b/m4/timegm.m4
@@ -1,4 +1,4 @@
-# timegm.m4 serial 13
+# timegm.m4 serial 14
 dnl Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_TIMEGM],
   AC_REQUIRE([gl_TIME_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
   REPLACE_TIMEGM=0
-  AC_CHECK_FUNCS_ONCE([timegm])
+  gl_CHECK_FUNCS_ANDROID([timegm], [[#include <time.h>]])
   if test $ac_cv_func_timegm = yes; then
     if test "$gl_cv_func_working_mktime" != yes; then
       # Assume that timegm is buggy if mktime is.
diff --git a/m4/utimens.m4 b/m4/utimens.m4
index c5d9b69e6f..900b4f6aa3 100644
--- a/m4/utimens.m4
+++ b/m4/utimens.m4
@@ -3,7 +3,7 @@ dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-dnl serial 12
+dnl serial 13
 
 AC_DEFUN([gl_UTIMENS],
 [
@@ -11,9 +11,10 @@ AC_DEFUN([gl_UTIMENS],
   AC_REQUIRE([gl_FUNC_UTIMES])
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CHECK_FUNCS_ONCE([futimens utimensat lutimes])
+  AC_CHECK_FUNCS_ONCE([futimens lutimes])
   gl_CHECK_FUNCS_ANDROID([futimes], [[#include <sys/time.h>]])
   gl_CHECK_FUNCS_ANDROID([futimesat], [[#include <sys/time.h>]])
+  gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]])
 
   if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then
     dnl FreeBSD 8.0-rc2 mishandles futimesat(fd,NULL,time).  It is not
diff --git a/m4/utimensat.m4 b/m4/utimensat.m4
index dd210fc989..1d3db2efa2 100644
--- a/m4/utimensat.m4
+++ b/m4/utimensat.m4
@@ -1,4 +1,4 @@
-# serial 9
+# serial 10
 # See if we need to provide utimensat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -13,7 +13,7 @@ AC_DEFUN([gl_FUNC_UTIMENSAT],
   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CHECK_FUNCS_ONCE([utimensat])
+  gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]])
   if test $ac_cv_func_utimensat = no; then
     HAVE_UTIMENSAT=0
   else
-- 
2.34.1


[-- Attachment #6: 0004-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 5748 bytes --]

From 607dbad8e68c39992a87b98c8fe4d183d6bfe71a Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 18 Jan 2023 21:25:30 +0100
Subject: [PATCH 4/6] Fix warnings for functions introduced in Android API
 level 16.

* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Test for faccessat using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/canonicalize.m4 (gl_FUNC_CANONICALIZE_FILENAME_MODE,
gl_CANONICALIZE_LGPL_SEPARATE): Likewise.
* m4/euidaccess.m4 (gl_PREREQ_EUIDACCESS): Likewise.
* m4/tsearch.m4 (gl_FUNC_TSEARCH): Test for tsearch using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/setenv.m4 (gl_PREREQ_SETENV): Likewise.
---
 ChangeLog          | 12 ++++++++++++
 m4/canonicalize.m4 |  8 +++++---
 m4/euidaccess.m4   |  4 ++--
 m4/faccessat.m4    |  4 ++--
 m4/setenv.m4       |  4 ++--
 m4/tsearch.m4      |  5 +++--
 6 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 738b2de22a..ad6884812c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2023-01-18  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 16.
+	* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Test for faccessat using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/canonicalize.m4 (gl_FUNC_CANONICALIZE_FILENAME_MODE,
+	gl_CANONICALIZE_LGPL_SEPARATE): Likewise.
+	* m4/euidaccess.m4 (gl_PREREQ_EUIDACCESS): Likewise.
+	* m4/tsearch.m4 (gl_FUNC_TSEARCH): Test for tsearch using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/setenv.m4 (gl_PREREQ_SETENV): Likewise.
+
 2023-01-18  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 12.
diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4
index 03cb0aec93..d319645fd3 100644
--- a/m4/canonicalize.m4
+++ b/m4/canonicalize.m4
@@ -1,4 +1,4 @@
-# canonicalize.m4 serial 37
+# canonicalize.m4 serial 38
 
 dnl Copyright (C) 2003-2007, 2009-2023 Free Software Foundation, Inc.
 
@@ -12,7 +12,8 @@ AC_DEFUN([gl_FUNC_CANONICALIZE_FILENAME_MODE],
 [
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
-  AC_CHECK_FUNCS_ONCE([canonicalize_file_name faccessat])
+  AC_CHECK_FUNCS_ONCE([canonicalize_file_name])
+  gl_CHECK_FUNCS_ANDROID([faccessat], [[#include <unistd.h>]])
   AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
   AC_REQUIRE([gl_FUNC_REALPATH_WORKS])
   if test $ac_cv_func_canonicalize_file_name = no; then
@@ -58,7 +59,8 @@ AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE],
 [
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
-  AC_CHECK_FUNCS_ONCE([canonicalize_file_name faccessat])
+  AC_CHECK_FUNCS_ONCE([canonicalize_file_name])
+  gl_CHECK_FUNCS_ANDROID([faccessat], [[#include <unistd.h>]])
 
   dnl On native Windows, we use _getcwd(), regardless whether getcwd() is
   dnl available through the linker option '-loldnames'.
diff --git a/m4/euidaccess.m4 b/m4/euidaccess.m4
index f0eb5bde84..7429779c15 100644
--- a/m4/euidaccess.m4
+++ b/m4/euidaccess.m4
@@ -1,4 +1,4 @@
-# euidaccess.m4 serial 16
+# euidaccess.m4 serial 17
 dnl Copyright (C) 2002-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -32,7 +32,7 @@ AC_DEFUN([gl_FUNC_EUIDACCESS],
 # Prerequisites of lib/euidaccess.c.
 AC_DEFUN([gl_PREREQ_EUIDACCESS], [
   dnl Prefer POSIX faccessat over non-standard euidaccess.
-  AC_CHECK_FUNCS_ONCE([faccessat])
+  gl_CHECK_FUNCS_ANDROID([faccessat], [[#include <unistd.h>]])
   dnl Try various other non-standard fallbacks.
   AC_CHECK_HEADERS([libgen.h])
   AC_FUNC_GETGROUPS
diff --git a/m4/faccessat.m4 b/m4/faccessat.m4
index 934c1f4154..958c4978b7 100644
--- a/m4/faccessat.m4
+++ b/m4/faccessat.m4
@@ -1,4 +1,4 @@
-# serial 10
+# serial 11
 # See if we need to provide faccessat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -16,7 +16,7 @@ AC_DEFUN([gl_FUNC_FACCESSAT],
   dnl Persuade glibc <unistd.h> to declare faccessat().
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([faccessat])
+  gl_CHECK_FUNCS_ANDROID([faccessat], [[#include <unistd.h>]])
   if test $ac_cv_func_faccessat = no; then
     HAVE_FACCESSAT=0
   else
diff --git a/m4/setenv.m4 b/m4/setenv.m4
index 16f9eb5531..c0b7475606 100644
--- a/m4/setenv.m4
+++ b/m4/setenv.m4
@@ -1,4 +1,4 @@
-# setenv.m4 serial 30
+# setenv.m4 serial 31
 dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -155,7 +155,7 @@ AC_DEFUN([gl_PREREQ_SETENV],
   AC_REQUIRE([gl_ENVIRON])
   AC_CHECK_HEADERS_ONCE([unistd.h])
   AC_CHECK_HEADERS([search.h])
-  AC_CHECK_FUNCS([tsearch])
+  gl_CHECK_FUNCS_ANDROID([tsearch], [[#include <search.h>]])
 ])
 
 # Prerequisites of lib/unsetenv.c.
diff --git a/m4/tsearch.m4 b/m4/tsearch.m4
index d24b2ca4a5..8e6a894f83 100644
--- a/m4/tsearch.m4
+++ b/m4/tsearch.m4
@@ -1,4 +1,4 @@
-# tsearch.m4 serial 8
+# tsearch.m4 serial 9
 dnl Copyright (C) 2006-2023 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,7 +7,8 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_TSEARCH],
 [
   AC_REQUIRE([gl_SEARCH_H_DEFAULTS])
-  AC_CHECK_FUNCS([tsearch twalk])
+  AC_CHECK_FUNCS([twalk])
+  gl_CHECK_FUNCS_ANDROID([tsearch], [[#include <search.h>]])
   if test $ac_cv_func_tsearch = yes; then
     dnl On OpenBSD 4.0, the return value of tdelete() is incorrect.
     AC_REQUIRE([AC_PROG_CC])
-- 
2.34.1


[-- Attachment #7: 0005-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 4027 bytes --]

From 398231de226d2839cc60d5e0c825e99169aabfdc Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 18 Jan 2023 21:30:02 +0100
Subject: [PATCH 5/6] Fix warnings for functions introduced in Android API
 level 16 or 17.

* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN): Test for posix_memalign
using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/alignalloc.m4 (gl_ALIGNALLOC): Likewise.
* m4/pagealign_alloc.m4 (gl_PREREQ_PAGEALIGN_ALLOC): Likewise.
* modules/aligned-malloc (configure.ac): Likewise.
---
 ChangeLog              | 9 +++++++++
 m4/alignalloc.m4       | 3 ++-
 m4/pagealign_alloc.m4  | 4 ++--
 m4/posix_memalign.m4   | 4 ++--
 modules/aligned-malloc | 3 ++-
 5 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ad6884812c..366c85feec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-01-18  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 16 or 17.
+	* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN): Test for posix_memalign
+	using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/alignalloc.m4 (gl_ALIGNALLOC): Likewise.
+	* m4/pagealign_alloc.m4 (gl_PREREQ_PAGEALIGN_ALLOC): Likewise.
+	* modules/aligned-malloc (configure.ac): Likewise.
+
 2023-01-18  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 16.
diff --git a/m4/alignalloc.m4 b/m4/alignalloc.m4
index fa8fb7cd2b..ec199ed01c 100644
--- a/m4/alignalloc.m4
+++ b/m4/alignalloc.m4
@@ -1,3 +1,4 @@
+# alignalloc.m4 serial 1
 dnl Copyright 2022-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,5 +7,5 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_ALIGNALLOC],
 [
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_FUNCS_ONCE([posix_memalign])
+  gl_CHECK_FUNCS_ANDROID([posix_memalign], [[#include <stdlib.h>]])
 ])
diff --git a/m4/pagealign_alloc.m4 b/m4/pagealign_alloc.m4
index cdf2e182b4..1cfb3beca8 100644
--- a/m4/pagealign_alloc.m4
+++ b/m4/pagealign_alloc.m4
@@ -1,4 +1,4 @@
-#serial 6
+#serial 7
 dnl Copyright (C) 2005-2007, 2009-2023 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,6 +16,6 @@ AC_DEFUN([gl_PAGEALIGN_ALLOC],
 AC_DEFUN([gl_PREREQ_PAGEALIGN_ALLOC],
 [
   AC_REQUIRE([gl_FUNC_MMAP_ANON])
-  AC_CHECK_FUNCS_ONCE([posix_memalign])
+  gl_CHECK_FUNCS_ANDROID([posix_memalign], [[#include <stdlib.h>]])
   AC_CHECK_HEADERS_ONCE([unistd.h])
 ])
diff --git a/m4/posix_memalign.m4 b/m4/posix_memalign.m4
index b29f573adf..36d88e0323 100644
--- a/m4/posix_memalign.m4
+++ b/m4/posix_memalign.m4
@@ -1,4 +1,4 @@
-# posix_memalign.m4 serial 1
+# posix_memalign.m4 serial 2
 dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_POSIX_MEMALIGN],
   dnl Persuade glibc <stdlib.h> to declare posix_memalign().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([posix_memalign])
+  gl_CHECK_FUNCS_ANDROID([posix_memalign], [[#include <stdlib.h>]])
   if test $ac_cv_func_posix_memalign = yes; then
     dnl On OpenBSD 6.1, posix_memalign (&p, 32, 2406) returns a pointer
     dnl that is not a multiple of 32.
diff --git a/modules/aligned-malloc b/modules/aligned-malloc
index 1ef05d1b76..ce22972436 100644
--- a/modules/aligned-malloc
+++ b/modules/aligned-malloc
@@ -14,8 +14,9 @@ memalign
 configure.ac:
 gl_MALLOC_ALIGNMENT
 AC_REQUIRE([AC_C_INLINE])
-AC_CHECK_FUNCS_ONCE([posix_memalign memalign])
+AC_CHECK_FUNCS_ONCE([memalign])
 gl_CHECK_FUNCS_ANDROID([aligned_alloc], [[#include <stdlib.h>]])
+gl_CHECK_FUNCS_ANDROID([posix_memalign], [[#include <stdlib.h>]])
 
 Makefile.am:
 
-- 
2.34.1


[-- Attachment #8: 0006-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 5582 bytes --]

From f6993392af03040b7008c7f1c55be7a7e3b11a67 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Wed, 18 Jan 2023 21:48:51 +0100
Subject: [PATCH 6/6] Fix warnings for functions introduced in Android API
 level 18.

* m4/getdelim.m4 (gl_FUNC_GETDELIM): Test for getdelim using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/getline.m4 (gl_FUNC_GETLINE): Test for getline using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNC.
* m4/log2.m4 (gl_FUNC_LOG2): Test for log2 using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/log2f.m4 (gl_FUNC_LOG2F): Test for log2f using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/log2l.m4 (gl_FUNC_LOG2L): Test for log2l using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
---
 ChangeLog      | 14 ++++++++++++++
 m4/getdelim.m4 |  4 ++--
 m4/getline.m4  | 13 ++++++-------
 m4/log2.m4     |  4 ++--
 m4/log2f.m4    |  4 ++--
 m4/log2l.m4    |  4 ++--
 6 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 366c85feec..b830f5cea2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-01-18  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 18.
+	* m4/getdelim.m4 (gl_FUNC_GETDELIM): Test for getdelim using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/getline.m4 (gl_FUNC_GETLINE): Test for getline using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNC.
+	* m4/log2.m4 (gl_FUNC_LOG2): Test for log2 using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/log2f.m4 (gl_FUNC_LOG2F): Test for log2f using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/log2l.m4 (gl_FUNC_LOG2L): Test for log2l using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+
 2023-01-18  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 16 or 17.
diff --git a/m4/getdelim.m4 b/m4/getdelim.m4
index 9aaed202ab..bbd7c03bcb 100644
--- a/m4/getdelim.m4
+++ b/m4/getdelim.m4
@@ -1,4 +1,4 @@
-# getdelim.m4 serial 16
+# getdelim.m4 serial 17
 
 dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
 dnl
@@ -18,7 +18,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
 
   AC_CHECK_DECLS_ONCE([getdelim])
 
-  AC_CHECK_FUNCS_ONCE([getdelim])
+  gl_CHECK_FUNCS_ANDROID([getdelim], [[#include <stdio.h>]])
   if test $ac_cv_func_getdelim = yes; then
     HAVE_GETDELIM=1
     dnl Found it in some library.  Verify that it works.
diff --git a/m4/getline.m4 b/m4/getline.m4
index 03569f06b2..f68fa3a1ac 100644
--- a/m4/getline.m4
+++ b/m4/getline.m4
@@ -1,4 +1,4 @@
-# getline.m4 serial 30
+# getline.m4 serial 31
 
 dnl Copyright (C) 1998-2003, 2005-2007, 2009-2023 Free Software Foundation,
 dnl Inc.
@@ -23,12 +23,9 @@ AC_DEFUN([gl_FUNC_GETLINE],
 
   AC_CHECK_DECLS_ONCE([getline])
 
-  gl_getline_needs_run_time_check=no
-  AC_CHECK_FUNC([getline],
-                [dnl Found it in some library.  Verify that it works.
-                 gl_getline_needs_run_time_check=yes],
-                [am_cv_func_working_getline=no])
-  if test $gl_getline_needs_run_time_check = yes; then
+  gl_CHECK_FUNCS_ANDROID([getline], [[#include <stdio.h>]])
+  if test $ac_cv_func_getline = yes; then
+    dnl Found it in some library.  Verify that it works.
     AC_CACHE_CHECK([for working getline function],
       [am_cv_func_working_getline],
       [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
@@ -85,6 +82,8 @@ AC_DEFUN([gl_FUNC_GETLINE],
             ])
          ])
       ])
+  else
+    am_cv_func_working_getline=no
   fi
 
   if test $ac_cv_have_decl_getline = no; then
diff --git a/m4/log2.m4 b/m4/log2.m4
index acf092fed1..4e08f48fe8 100644
--- a/m4/log2.m4
+++ b/m4/log2.m4
@@ -1,4 +1,4 @@
-# log2.m4 serial 10
+# log2.m4 serial 11
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -18,7 +18,7 @@ AC_DEFUN([gl_FUNC_LOG2],
   dnl Test whether log2() exists.
   save_LIBS="$LIBS"
   LIBS="$LIBS $LOG2_LIBM"
-  AC_CHECK_FUNCS([log2])
+  gl_CHECK_FUNCS_ANDROID([log2], [[#include <math.h>]])
   LIBS="$save_LIBS"
   if test $ac_cv_func_log2 = yes; then
     HAVE_LOG2=1
diff --git a/m4/log2f.m4 b/m4/log2f.m4
index f9da22e097..b85993c2c2 100644
--- a/m4/log2f.m4
+++ b/m4/log2f.m4
@@ -1,4 +1,4 @@
-# log2f.m4 serial 10
+# log2f.m4 serial 11
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -19,7 +19,7 @@ AC_DEFUN([gl_FUNC_LOG2F],
   dnl Test whether log2f() exists.
   save_LIBS="$LIBS"
   LIBS="$LIBS $LOG2F_LIBM"
-  AC_CHECK_FUNCS([log2f])
+  gl_CHECK_FUNCS_ANDROID([log2f], [[#include <math.h>]])
   LIBS="$save_LIBS"
   if test $ac_cv_func_log2f = yes; then
     HAVE_LOG2F=1
diff --git a/m4/log2l.m4 b/m4/log2l.m4
index f65c00398e..e4810d5a94 100644
--- a/m4/log2l.m4
+++ b/m4/log2l.m4
@@ -1,4 +1,4 @@
-# log2l.m4 serial 3
+# log2l.m4 serial 4
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_LOG2L],
   dnl defined in the same library as log2().
   save_LIBS="$LIBS"
   LIBS="$LIBS $LOG2_LIBM"
-  AC_CHECK_FUNCS([log2l])
+  gl_CHECK_FUNCS_ANDROID([log2l], [[#include <math.h>]])
   LIBS="$save_LIBS"
   if test $ac_cv_func_log2l = yes; then
     LOG2L_LIBM="$LOG2_LIBM"
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: More Android patches
  2023-01-18 23:07   ` Bruno Haible
@ 2023-01-19 21:02     ` Bruno Haible
  0 siblings, 0 replies; 3+ messages in thread
From: Bruno Haible @ 2023-01-19 21:02 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Po Lu

[-- Attachment #1: Type: text/plain, Size: 352 bytes --]

I wrote:
> In a second step, I looked for occurrences to AC_CHECK_FUNC[S]
> or AC_CHECK_FUNCS_ONCE of these symbols. E.g.
>   for s in `cat in-8.txt`; do grep -rw "$s" m4 modules | grep CHECK_FUNC; echo ; done
> and replaced these with gl_CHECK_FUNCS_ANDROID invocations.

Having finished and regression-tested these changes, here's what I committed.


[-- Attachment #2: 0001-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 1525 bytes --]

From 6c4ed27dce71dc788efa6ef6430849d4bb5bf39d Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:10 +0100
Subject: [PATCH 01/15] Fix warnings for functions introduced in Android API
 level 8.

* m4/ttyname_r.m4 (gl_FUNC_TTYNAME_R): Test for ttyname_r using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
---
 ChangeLog       | 6 ++++++
 m4/ttyname_r.m4 | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5cbe84d1b1..72b816f990 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 8.
+	* m4/ttyname_r.m4 (gl_FUNC_TTYNAME_R): Test for ttyname_r using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	fts: Document this module.
diff --git a/m4/ttyname_r.m4 b/m4/ttyname_r.m4
index 3f027da45a..4a76155469 100644
--- a/m4/ttyname_r.m4
+++ b/m4/ttyname_r.m4
@@ -1,4 +1,4 @@
-# ttyname_r.m4 serial 11
+# ttyname_r.m4 serial 12
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_TTYNAME_R],
     HAVE_DECL_TTYNAME_R=0
   fi
 
-  AC_CHECK_FUNCS([ttyname_r])
+  gl_CHECK_FUNCS_ANDROID([ttyname_r], [[#include <unistd.h>]])
   if test $ac_cv_func_ttyname_r = no; then
     HAVE_TTYNAME_R=0
   else
-- 
2.34.1


[-- Attachment #3: 0002-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 2449 bytes --]

From 39bfcd72a808c3091b39d797c9576f26c197c3df Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:13 +0100
Subject: [PATCH 02/15] Fix warnings for functions introduced in Android API
 level 9.

* m4/pipe2.m4 (gl_FUNC_PIPE2): Test for pipe2 using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Update comments.
---
 ChangeLog       | 7 +++++++
 m4/fdatasync.m4 | 3 ++-
 m4/pipe2.m4     | 4 ++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 72b816f990..26c07501b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 9.
+	* m4/pipe2.m4 (gl_FUNC_PIPE2): Test for pipe2 using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Update comments.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 8.
diff --git a/m4/fdatasync.m4 b/m4/fdatasync.m4
index 8c5cc4fdaf..201d7ffb27 100644
--- a/m4/fdatasync.m4
+++ b/m4/fdatasync.m4
@@ -1,4 +1,4 @@
-# fdatasync.m4 serial 7
+# fdatasync.m4 serial 8
 dnl Copyright (C) 2008-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,6 +17,7 @@ AC_DEFUN([gl_FUNC_FDATASYNC],
   if test $ac_cv_have_decl_fdatasync = no; then
     HAVE_DECL_FDATASYNC=0
     dnl Mac OS X 10.7 has fdatasync but does not declare it.
+    dnl Likewise Android with API level < 9. Cf. gl_CHECK_FUNCS_ANDROID.
     AC_CHECK_FUNCS([fdatasync])
     if test $ac_cv_func_fdatasync = no; then
       HAVE_FDATASYNC=0
diff --git a/m4/pipe2.m4 b/m4/pipe2.m4
index 501f3a4303..c7ec02e873 100644
--- a/m4/pipe2.m4
+++ b/m4/pipe2.m4
@@ -1,4 +1,4 @@
-# pipe2.m4 serial 2
+# pipe2.m4 serial 3
 dnl Copyright (C) 2009-2023 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,7 +11,7 @@ AC_DEFUN([gl_FUNC_PIPE2],
   dnl Persuade glibc <unistd.h> to declare pipe2().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([pipe2])
+  gl_CHECK_FUNCS_ANDROID([pipe2], [[#include <unistd.h>]])
   if test $ac_cv_func_pipe2 != yes; then
     HAVE_PIPE2=0
   fi
-- 
2.34.1


[-- Attachment #4: 0003-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 9524 bytes --]

From 430cd900f19b62994c8cc1b6f1b560b4aed94025 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:15 +0100
Subject: [PATCH 03/15] Fix warnings for functions introduced in Android API
 level 12.

Reported by Po Lu <luangruo@yahoo.com>.

* m4/ftruncate.m4 (gl_FUNC_FTRUNCATE): Test for ftruncate using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/glob.m4 (gl_PREREQ_GLOB): Test for getpwnam_r using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/nproc.m4 (gl_PREREQ_NPROC): Test for sched_getaffinity using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/pread.m4 (gl_FUNC_PREAD): Test for pread using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/pwrite.m4 (gl_FUNC_PWRITE): Test for pwrite using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/thread.m4 (gl_THREAD): Test for pthread_atfork using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/timegm.m4 (gl_FUNC_TIMEGM): Test for timegm using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Test for utimensat using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/utimens.m4 (gl_UTIMENS): Likewise.
---
 ChangeLog       | 22 ++++++++++++++++++++++
 m4/ftruncate.m4 |  4 ++--
 m4/glob.m4      |  4 ++--
 m4/nproc.m4     |  6 +++---
 m4/pread.m4     |  4 ++--
 m4/pwrite.m4    |  4 ++--
 m4/thread.m4    |  4 ++--
 m4/timegm.m4    |  4 ++--
 m4/utimens.m4   |  5 +++--
 m4/utimensat.m4 |  4 ++--
 10 files changed, 42 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 26c07501b3..c29bd760ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 12.
+	Reported by Po Lu <luangruo@yahoo.com>.
+	* m4/ftruncate.m4 (gl_FUNC_FTRUNCATE): Test for ftruncate using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/glob.m4 (gl_PREREQ_GLOB): Test for getpwnam_r using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/nproc.m4 (gl_PREREQ_NPROC): Test for sched_getaffinity using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/pread.m4 (gl_FUNC_PREAD): Test for pread using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/pwrite.m4 (gl_FUNC_PWRITE): Test for pwrite using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/thread.m4 (gl_THREAD): Test for pthread_atfork using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/timegm.m4 (gl_FUNC_TIMEGM): Test for timegm using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Test for utimensat using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/utimens.m4 (gl_UTIMENS): Likewise.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 9.
diff --git a/m4/ftruncate.m4 b/m4/ftruncate.m4
index 74c347598d..f48126e856 100644
--- a/m4/ftruncate.m4
+++ b/m4/ftruncate.m4
@@ -1,4 +1,4 @@
-# serial 21
+# serial 22
 
 # See if we need to emulate a missing ftruncate function using _chsize.
 
@@ -10,7 +10,7 @@
 AC_DEFUN([gl_FUNC_FTRUNCATE],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
-  AC_CHECK_FUNCS_ONCE([ftruncate])
+  gl_CHECK_FUNCS_ANDROID([ftruncate], [[#include <unistd.h>]])
   if test $ac_cv_func_ftruncate = yes; then
     m4_ifdef([gl_LARGEFILE], [
       AC_REQUIRE([AC_CANONICAL_HOST])
diff --git a/m4/glob.m4 b/m4/glob.m4
index 354581b3be..847f88038f 100644
--- a/m4/glob.m4
+++ b/m4/glob.m4
@@ -1,4 +1,4 @@
-# glob.m4 serial 27
+# glob.m4 serial 28
 dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -126,5 +126,5 @@ AC_DEFUN([gl_PREREQ_GLOB],
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE])
   AC_CHECK_HEADERS_ONCE([unistd.h])
   gl_CHECK_FUNCS_ANDROID([getlogin_r], [[#include <unistd.h>]])
-  AC_CHECK_FUNCS_ONCE([getpwnam_r])
+  gl_CHECK_FUNCS_ANDROID([getpwnam_r], [[#include <pwd.h>]])
 ])
diff --git a/m4/nproc.m4 b/m4/nproc.m4
index 3065b7b9bf..c892ad74b7 100644
--- a/m4/nproc.m4
+++ b/m4/nproc.m4
@@ -1,4 +1,4 @@
-# nproc.m4 serial 5
+# nproc.m4 serial 6
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,8 +25,8 @@ AC_DEFUN([gl_PREREQ_NPROC],
      #endif
     ])
 
-  AC_CHECK_FUNCS([sched_getaffinity sched_getaffinity_np \
-                  pstat_getdynamic sysmp sysctl])
+  AC_CHECK_FUNCS([sched_getaffinity_np pstat_getdynamic sysmp sysctl])
+  gl_CHECK_FUNCS_ANDROID([sched_getaffinity], [[#include <sched.h>]])
 
   dnl Test whether sched_getaffinity has the expected declaration.
   dnl glibc 2.3.[0-2]:
diff --git a/m4/pread.m4 b/m4/pread.m4
index ac3c1b7d51..8031f910d4 100644
--- a/m4/pread.m4
+++ b/m4/pread.m4
@@ -1,4 +1,4 @@
-# pread.m4 serial 6
+# pread.m4 serial 7
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_PREAD],
   dnl Persuade glibc <unistd.h> to declare pread().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([pread])
+  gl_CHECK_FUNCS_ANDROID([pread], [[#include <unistd.h>]])
   if test $ac_cv_func_pread = yes; then
     dnl On HP-UX 11.11 with _FILE_OFFSET_BITS=64, pread() on a file returns 0
     dnl instead of a positive value.
diff --git a/m4/pwrite.m4 b/m4/pwrite.m4
index f77d4210d6..48c5255f30 100644
--- a/m4/pwrite.m4
+++ b/m4/pwrite.m4
@@ -1,4 +1,4 @@
-# pwrite.m4 serial 6
+# pwrite.m4 serial 7
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_PWRITE],
   dnl Persuade glibc <unistd.h> to declare pwrite().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([pwrite])
+  gl_CHECK_FUNCS_ANDROID([pwrite], [[#include <unistd.h>]])
   if test $ac_cv_func_pwrite = yes; then
     dnl On HP-UX 11.11 with _FILE_OFFSET_BITS=64, pwrite() on a file does not
     dnl fail when an invalid (negative) offset is passed and uses an arbitrary
diff --git a/m4/thread.m4 b/m4/thread.m4
index 12515f6a93..9c63df39da 100644
--- a/m4/thread.m4
+++ b/m4/thread.m4
@@ -1,4 +1,4 @@
-# thread.m4 serial 3
+# thread.m4 serial 4
 dnl Copyright (C) 2008-2023 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,7 +11,7 @@ AC_DEFUN([gl_THREAD],
   if test $gl_threads_api = posix; then
     gl_save_LIBS="$LIBS"
     LIBS="$LIBS $LIBMULTITHREAD"
-    AC_CHECK_FUNCS([pthread_atfork])
+    gl_CHECK_FUNCS_ANDROID([pthread_atfork], [[#include <pthread.h>]])
     LIBS="$gl_save_LIBS"
   fi
 ])
diff --git a/m4/timegm.m4 b/m4/timegm.m4
index 6079f1a39c..fa84e98db3 100644
--- a/m4/timegm.m4
+++ b/m4/timegm.m4
@@ -1,4 +1,4 @@
-# timegm.m4 serial 13
+# timegm.m4 serial 14
 dnl Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_TIMEGM],
   AC_REQUIRE([gl_TIME_H_DEFAULTS])
   AC_REQUIRE([gl_FUNC_MKTIME_WORKS])
   REPLACE_TIMEGM=0
-  AC_CHECK_FUNCS_ONCE([timegm])
+  gl_CHECK_FUNCS_ANDROID([timegm], [[#include <time.h>]])
   if test $ac_cv_func_timegm = yes; then
     if test "$gl_cv_func_working_mktime" != yes; then
       # Assume that timegm is buggy if mktime is.
diff --git a/m4/utimens.m4 b/m4/utimens.m4
index c5d9b69e6f..900b4f6aa3 100644
--- a/m4/utimens.m4
+++ b/m4/utimens.m4
@@ -3,7 +3,7 @@ dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-dnl serial 12
+dnl serial 13
 
 AC_DEFUN([gl_UTIMENS],
 [
@@ -11,9 +11,10 @@ AC_DEFUN([gl_UTIMENS],
   AC_REQUIRE([gl_FUNC_UTIMES])
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CHECK_FUNCS_ONCE([futimens utimensat lutimes])
+  AC_CHECK_FUNCS_ONCE([futimens lutimes])
   gl_CHECK_FUNCS_ANDROID([futimes], [[#include <sys/time.h>]])
   gl_CHECK_FUNCS_ANDROID([futimesat], [[#include <sys/time.h>]])
+  gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]])
 
   if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then
     dnl FreeBSD 8.0-rc2 mishandles futimesat(fd,NULL,time).  It is not
diff --git a/m4/utimensat.m4 b/m4/utimensat.m4
index dd210fc989..1d3db2efa2 100644
--- a/m4/utimensat.m4
+++ b/m4/utimensat.m4
@@ -1,4 +1,4 @@
-# serial 9
+# serial 10
 # See if we need to provide utimensat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -13,7 +13,7 @@ AC_DEFUN([gl_FUNC_UTIMENSAT],
   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CHECK_FUNCS_ONCE([utimensat])
+  gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]])
   if test $ac_cv_func_utimensat = no; then
     HAVE_UTIMENSAT=0
   else
-- 
2.34.1


[-- Attachment #5: 0004-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 5750 bytes --]

From 1f79d0e79a4402aaae3ab890420cd70d4308732a Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:17 +0100
Subject: [PATCH 04/15] Fix warnings for functions introduced in Android API
 level 16.

* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Test for faccessat using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/canonicalize.m4 (gl_FUNC_CANONICALIZE_FILENAME_MODE,
gl_CANONICALIZE_LGPL_SEPARATE): Likewise.
* m4/euidaccess.m4 (gl_PREREQ_EUIDACCESS): Likewise.
* m4/tsearch.m4 (gl_FUNC_TSEARCH): Test for tsearch using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/setenv.m4 (gl_PREREQ_SETENV): Likewise.
---
 ChangeLog          | 12 ++++++++++++
 m4/canonicalize.m4 |  8 +++++---
 m4/euidaccess.m4   |  4 ++--
 m4/faccessat.m4    |  4 ++--
 m4/setenv.m4       |  4 ++--
 m4/tsearch.m4      |  5 +++--
 6 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c29bd760ec..5d4ab35005 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 16.
+	* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Test for faccessat using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/canonicalize.m4 (gl_FUNC_CANONICALIZE_FILENAME_MODE,
+	gl_CANONICALIZE_LGPL_SEPARATE): Likewise.
+	* m4/euidaccess.m4 (gl_PREREQ_EUIDACCESS): Likewise.
+	* m4/tsearch.m4 (gl_FUNC_TSEARCH): Test for tsearch using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/setenv.m4 (gl_PREREQ_SETENV): Likewise.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 12.
diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4
index 03cb0aec93..d319645fd3 100644
--- a/m4/canonicalize.m4
+++ b/m4/canonicalize.m4
@@ -1,4 +1,4 @@
-# canonicalize.m4 serial 37
+# canonicalize.m4 serial 38
 
 dnl Copyright (C) 2003-2007, 2009-2023 Free Software Foundation, Inc.
 
@@ -12,7 +12,8 @@ AC_DEFUN([gl_FUNC_CANONICALIZE_FILENAME_MODE],
 [
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
-  AC_CHECK_FUNCS_ONCE([canonicalize_file_name faccessat])
+  AC_CHECK_FUNCS_ONCE([canonicalize_file_name])
+  gl_CHECK_FUNCS_ANDROID([faccessat], [[#include <unistd.h>]])
   AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
   AC_REQUIRE([gl_FUNC_REALPATH_WORKS])
   if test $ac_cv_func_canonicalize_file_name = no; then
@@ -58,7 +59,8 @@ AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE],
 [
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
-  AC_CHECK_FUNCS_ONCE([canonicalize_file_name faccessat])
+  AC_CHECK_FUNCS_ONCE([canonicalize_file_name])
+  gl_CHECK_FUNCS_ANDROID([faccessat], [[#include <unistd.h>]])
 
   dnl On native Windows, we use _getcwd(), regardless whether getcwd() is
   dnl available through the linker option '-loldnames'.
diff --git a/m4/euidaccess.m4 b/m4/euidaccess.m4
index f0eb5bde84..7429779c15 100644
--- a/m4/euidaccess.m4
+++ b/m4/euidaccess.m4
@@ -1,4 +1,4 @@
-# euidaccess.m4 serial 16
+# euidaccess.m4 serial 17
 dnl Copyright (C) 2002-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -32,7 +32,7 @@ AC_DEFUN([gl_FUNC_EUIDACCESS],
 # Prerequisites of lib/euidaccess.c.
 AC_DEFUN([gl_PREREQ_EUIDACCESS], [
   dnl Prefer POSIX faccessat over non-standard euidaccess.
-  AC_CHECK_FUNCS_ONCE([faccessat])
+  gl_CHECK_FUNCS_ANDROID([faccessat], [[#include <unistd.h>]])
   dnl Try various other non-standard fallbacks.
   AC_CHECK_HEADERS([libgen.h])
   AC_FUNC_GETGROUPS
diff --git a/m4/faccessat.m4 b/m4/faccessat.m4
index 934c1f4154..958c4978b7 100644
--- a/m4/faccessat.m4
+++ b/m4/faccessat.m4
@@ -1,4 +1,4 @@
-# serial 10
+# serial 11
 # See if we need to provide faccessat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -16,7 +16,7 @@ AC_DEFUN([gl_FUNC_FACCESSAT],
   dnl Persuade glibc <unistd.h> to declare faccessat().
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([faccessat])
+  gl_CHECK_FUNCS_ANDROID([faccessat], [[#include <unistd.h>]])
   if test $ac_cv_func_faccessat = no; then
     HAVE_FACCESSAT=0
   else
diff --git a/m4/setenv.m4 b/m4/setenv.m4
index 16f9eb5531..c0b7475606 100644
--- a/m4/setenv.m4
+++ b/m4/setenv.m4
@@ -1,4 +1,4 @@
-# setenv.m4 serial 30
+# setenv.m4 serial 31
 dnl Copyright (C) 2001-2004, 2006-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -155,7 +155,7 @@ AC_DEFUN([gl_PREREQ_SETENV],
   AC_REQUIRE([gl_ENVIRON])
   AC_CHECK_HEADERS_ONCE([unistd.h])
   AC_CHECK_HEADERS([search.h])
-  AC_CHECK_FUNCS([tsearch])
+  gl_CHECK_FUNCS_ANDROID([tsearch], [[#include <search.h>]])
 ])
 
 # Prerequisites of lib/unsetenv.c.
diff --git a/m4/tsearch.m4 b/m4/tsearch.m4
index d24b2ca4a5..8e6a894f83 100644
--- a/m4/tsearch.m4
+++ b/m4/tsearch.m4
@@ -1,4 +1,4 @@
-# tsearch.m4 serial 8
+# tsearch.m4 serial 9
 dnl Copyright (C) 2006-2023 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,7 +7,8 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_TSEARCH],
 [
   AC_REQUIRE([gl_SEARCH_H_DEFAULTS])
-  AC_CHECK_FUNCS([tsearch twalk])
+  AC_CHECK_FUNCS([twalk])
+  gl_CHECK_FUNCS_ANDROID([tsearch], [[#include <search.h>]])
   if test $ac_cv_func_tsearch = yes; then
     dnl On OpenBSD 4.0, the return value of tdelete() is incorrect.
     AC_REQUIRE([AC_PROG_CC])
-- 
2.34.1


[-- Attachment #6: 0005-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 4029 bytes --]

From dc4c5939bbcf0ba8e86be2246232f7012fcd25dd Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:20 +0100
Subject: [PATCH 05/15] Fix warnings for functions introduced in Android API
 level 16 or 17.

* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN): Test for posix_memalign
using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/alignalloc.m4 (gl_ALIGNALLOC): Likewise.
* m4/pagealign_alloc.m4 (gl_PREREQ_PAGEALIGN_ALLOC): Likewise.
* modules/aligned-malloc (configure.ac): Likewise.
---
 ChangeLog              | 9 +++++++++
 m4/alignalloc.m4       | 3 ++-
 m4/pagealign_alloc.m4  | 4 ++--
 m4/posix_memalign.m4   | 4 ++--
 modules/aligned-malloc | 3 ++-
 5 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5d4ab35005..0704164a25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 16 or 17.
+	* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN): Test for posix_memalign
+	using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/alignalloc.m4 (gl_ALIGNALLOC): Likewise.
+	* m4/pagealign_alloc.m4 (gl_PREREQ_PAGEALIGN_ALLOC): Likewise.
+	* modules/aligned-malloc (configure.ac): Likewise.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 16.
diff --git a/m4/alignalloc.m4 b/m4/alignalloc.m4
index fa8fb7cd2b..ec199ed01c 100644
--- a/m4/alignalloc.m4
+++ b/m4/alignalloc.m4
@@ -1,3 +1,4 @@
+# alignalloc.m4 serial 1
 dnl Copyright 2022-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,5 +7,5 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_ALIGNALLOC],
 [
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_FUNCS_ONCE([posix_memalign])
+  gl_CHECK_FUNCS_ANDROID([posix_memalign], [[#include <stdlib.h>]])
 ])
diff --git a/m4/pagealign_alloc.m4 b/m4/pagealign_alloc.m4
index cdf2e182b4..1cfb3beca8 100644
--- a/m4/pagealign_alloc.m4
+++ b/m4/pagealign_alloc.m4
@@ -1,4 +1,4 @@
-#serial 6
+#serial 7
 dnl Copyright (C) 2005-2007, 2009-2023 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,6 +16,6 @@ AC_DEFUN([gl_PAGEALIGN_ALLOC],
 AC_DEFUN([gl_PREREQ_PAGEALIGN_ALLOC],
 [
   AC_REQUIRE([gl_FUNC_MMAP_ANON])
-  AC_CHECK_FUNCS_ONCE([posix_memalign])
+  gl_CHECK_FUNCS_ANDROID([posix_memalign], [[#include <stdlib.h>]])
   AC_CHECK_HEADERS_ONCE([unistd.h])
 ])
diff --git a/m4/posix_memalign.m4 b/m4/posix_memalign.m4
index b29f573adf..36d88e0323 100644
--- a/m4/posix_memalign.m4
+++ b/m4/posix_memalign.m4
@@ -1,4 +1,4 @@
-# posix_memalign.m4 serial 1
+# posix_memalign.m4 serial 2
 dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_POSIX_MEMALIGN],
   dnl Persuade glibc <stdlib.h> to declare posix_memalign().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([posix_memalign])
+  gl_CHECK_FUNCS_ANDROID([posix_memalign], [[#include <stdlib.h>]])
   if test $ac_cv_func_posix_memalign = yes; then
     dnl On OpenBSD 6.1, posix_memalign (&p, 32, 2406) returns a pointer
     dnl that is not a multiple of 32.
diff --git a/modules/aligned-malloc b/modules/aligned-malloc
index 1ef05d1b76..ce22972436 100644
--- a/modules/aligned-malloc
+++ b/modules/aligned-malloc
@@ -14,8 +14,9 @@ memalign
 configure.ac:
 gl_MALLOC_ALIGNMENT
 AC_REQUIRE([AC_C_INLINE])
-AC_CHECK_FUNCS_ONCE([posix_memalign memalign])
+AC_CHECK_FUNCS_ONCE([memalign])
 gl_CHECK_FUNCS_ANDROID([aligned_alloc], [[#include <stdlib.h>]])
+gl_CHECK_FUNCS_ANDROID([posix_memalign], [[#include <stdlib.h>]])
 
 Makefile.am:
 
-- 
2.34.1


[-- Attachment #7: 0006-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 5584 bytes --]

From 909873441124b0f80b1427d55d02d8b6b5992890 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:23 +0100
Subject: [PATCH 06/15] Fix warnings for functions introduced in Android API
 level 18.

* m4/getdelim.m4 (gl_FUNC_GETDELIM): Test for getdelim using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/getline.m4 (gl_FUNC_GETLINE): Test for getline using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNC.
* m4/log2.m4 (gl_FUNC_LOG2): Test for log2 using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/log2f.m4 (gl_FUNC_LOG2F): Test for log2f using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/log2l.m4 (gl_FUNC_LOG2L): Test for log2l using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
---
 ChangeLog      | 14 ++++++++++++++
 m4/getdelim.m4 |  4 ++--
 m4/getline.m4  | 13 ++++++-------
 m4/log2.m4     |  4 ++--
 m4/log2f.m4    |  4 ++--
 m4/log2l.m4    |  4 ++--
 6 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0704164a25..7d80045e81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 18.
+	* m4/getdelim.m4 (gl_FUNC_GETDELIM): Test for getdelim using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/getline.m4 (gl_FUNC_GETLINE): Test for getline using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNC.
+	* m4/log2.m4 (gl_FUNC_LOG2): Test for log2 using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/log2f.m4 (gl_FUNC_LOG2F): Test for log2f using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/log2l.m4 (gl_FUNC_LOG2L): Test for log2l using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 16 or 17.
diff --git a/m4/getdelim.m4 b/m4/getdelim.m4
index 9aaed202ab..bbd7c03bcb 100644
--- a/m4/getdelim.m4
+++ b/m4/getdelim.m4
@@ -1,4 +1,4 @@
-# getdelim.m4 serial 16
+# getdelim.m4 serial 17
 
 dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
 dnl
@@ -18,7 +18,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
 
   AC_CHECK_DECLS_ONCE([getdelim])
 
-  AC_CHECK_FUNCS_ONCE([getdelim])
+  gl_CHECK_FUNCS_ANDROID([getdelim], [[#include <stdio.h>]])
   if test $ac_cv_func_getdelim = yes; then
     HAVE_GETDELIM=1
     dnl Found it in some library.  Verify that it works.
diff --git a/m4/getline.m4 b/m4/getline.m4
index 03569f06b2..f68fa3a1ac 100644
--- a/m4/getline.m4
+++ b/m4/getline.m4
@@ -1,4 +1,4 @@
-# getline.m4 serial 30
+# getline.m4 serial 31
 
 dnl Copyright (C) 1998-2003, 2005-2007, 2009-2023 Free Software Foundation,
 dnl Inc.
@@ -23,12 +23,9 @@ AC_DEFUN([gl_FUNC_GETLINE],
 
   AC_CHECK_DECLS_ONCE([getline])
 
-  gl_getline_needs_run_time_check=no
-  AC_CHECK_FUNC([getline],
-                [dnl Found it in some library.  Verify that it works.
-                 gl_getline_needs_run_time_check=yes],
-                [am_cv_func_working_getline=no])
-  if test $gl_getline_needs_run_time_check = yes; then
+  gl_CHECK_FUNCS_ANDROID([getline], [[#include <stdio.h>]])
+  if test $ac_cv_func_getline = yes; then
+    dnl Found it in some library.  Verify that it works.
     AC_CACHE_CHECK([for working getline function],
       [am_cv_func_working_getline],
       [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
@@ -85,6 +82,8 @@ AC_DEFUN([gl_FUNC_GETLINE],
             ])
          ])
       ])
+  else
+    am_cv_func_working_getline=no
   fi
 
   if test $ac_cv_have_decl_getline = no; then
diff --git a/m4/log2.m4 b/m4/log2.m4
index acf092fed1..4e08f48fe8 100644
--- a/m4/log2.m4
+++ b/m4/log2.m4
@@ -1,4 +1,4 @@
-# log2.m4 serial 10
+# log2.m4 serial 11
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -18,7 +18,7 @@ AC_DEFUN([gl_FUNC_LOG2],
   dnl Test whether log2() exists.
   save_LIBS="$LIBS"
   LIBS="$LIBS $LOG2_LIBM"
-  AC_CHECK_FUNCS([log2])
+  gl_CHECK_FUNCS_ANDROID([log2], [[#include <math.h>]])
   LIBS="$save_LIBS"
   if test $ac_cv_func_log2 = yes; then
     HAVE_LOG2=1
diff --git a/m4/log2f.m4 b/m4/log2f.m4
index f9da22e097..b85993c2c2 100644
--- a/m4/log2f.m4
+++ b/m4/log2f.m4
@@ -1,4 +1,4 @@
-# log2f.m4 serial 10
+# log2f.m4 serial 11
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -19,7 +19,7 @@ AC_DEFUN([gl_FUNC_LOG2F],
   dnl Test whether log2f() exists.
   save_LIBS="$LIBS"
   LIBS="$LIBS $LOG2F_LIBM"
-  AC_CHECK_FUNCS([log2f])
+  gl_CHECK_FUNCS_ANDROID([log2f], [[#include <math.h>]])
   LIBS="$save_LIBS"
   if test $ac_cv_func_log2f = yes; then
     HAVE_LOG2F=1
diff --git a/m4/log2l.m4 b/m4/log2l.m4
index f65c00398e..e4810d5a94 100644
--- a/m4/log2l.m4
+++ b/m4/log2l.m4
@@ -1,4 +1,4 @@
-# log2l.m4 serial 3
+# log2l.m4 serial 4
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_LOG2L],
   dnl defined in the same library as log2().
   save_LIBS="$LIBS"
   LIBS="$LIBS $LOG2_LIBM"
-  AC_CHECK_FUNCS([log2l])
+  gl_CHECK_FUNCS_ANDROID([log2l], [[#include <math.h>]])
   LIBS="$save_LIBS"
   if test $ac_cv_func_log2l = yes; then
     LOG2L_LIBM="$LOG2_LIBM"
-- 
2.34.1


[-- Attachment #8: 0007-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 4664 bytes --]

From 64044f7934922d347c578fa8b2c5b2305aed5ca5 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:25 +0100
Subject: [PATCH 07/15] Fix warnings for functions introduced in Android API
 level 19.

* m4/futimens.m4 (gl_FUNC_FUTIMENS): Test for futimens using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/utimens.m4 (gl_UTIMENS): Likewise.
* m4/imaxabs.m4 (gl_FUNC_IMAXABS): Test for imaxabs using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Test for imaxdiv using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
---
 ChangeLog      | 11 +++++++++++
 m4/futimens.m4 |  4 ++--
 m4/imaxabs.m4  |  4 ++--
 m4/imaxdiv.m4  |  4 ++--
 m4/utimens.m4  |  5 +++--
 5 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7d80045e81..33693bec9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 19.
+	* m4/futimens.m4 (gl_FUNC_FUTIMENS): Test for futimens using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/utimens.m4 (gl_UTIMENS): Likewise.
+	* m4/imaxabs.m4 (gl_FUNC_IMAXABS): Test for imaxabs using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Test for imaxdiv using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 18.
diff --git a/m4/futimens.m4 b/m4/futimens.m4
index 3aaa10a0b5..8e997d6ea6 100644
--- a/m4/futimens.m4
+++ b/m4/futimens.m4
@@ -1,4 +1,4 @@
-# serial 9
+# serial 10
 # See if we need to provide futimens replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -13,7 +13,7 @@ AC_DEFUN([gl_FUNC_FUTIMENS],
   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_FUNCS_ONCE([futimens])
+  gl_CHECK_FUNCS_ANDROID([futimens], [[#include <sys/stat.h>]])
   if test $ac_cv_func_futimens = no; then
     HAVE_FUTIMENS=0
   else
diff --git a/m4/imaxabs.m4 b/m4/imaxabs.m4
index 5fb2a6963f..504db4845c 100644
--- a/m4/imaxabs.m4
+++ b/m4/imaxabs.m4
@@ -1,4 +1,4 @@
-# imaxabs.m4 serial 4
+# imaxabs.m4 serial 5
 dnl Copyright (C) 2006, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_IMAXABS],
   AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
 
   dnl On OSF/1 5.1 with cc, this function is declared but not defined.
-  AC_CHECK_FUNCS_ONCE([imaxabs])
+  gl_CHECK_FUNCS_ANDROID([imaxabs], [[#include <inttypes.h>]])
   AC_CHECK_DECLS_ONCE([imaxabs])
   if test "$ac_cv_have_decl_imaxabs" != yes; then
     HAVE_DECL_IMAXABS=0
diff --git a/m4/imaxdiv.m4 b/m4/imaxdiv.m4
index 65d2c65cbb..7ad5da4ebf 100644
--- a/m4/imaxdiv.m4
+++ b/m4/imaxdiv.m4
@@ -1,4 +1,4 @@
-# imaxdiv.m4 serial 5
+# imaxdiv.m4 serial 6
 dnl Copyright (C) 2006, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_IMAXDIV],
   AC_REQUIRE([gl_INTTYPES_H_DEFAULTS])
 
   dnl On OSF/1 5.1 with cc, this function is declared but not defined.
-  AC_CHECK_FUNCS_ONCE([imaxdiv])
+  gl_CHECK_FUNCS_ANDROID([imaxdiv], [[#include <inttypes.h>]])
   AC_CHECK_DECLS_ONCE([imaxdiv])
   if test "$ac_cv_have_decl_imaxdiv" != yes; then
     HAVE_DECL_IMAXDIV=0
diff --git a/m4/utimens.m4 b/m4/utimens.m4
index 900b4f6aa3..ffd289e1c7 100644
--- a/m4/utimens.m4
+++ b/m4/utimens.m4
@@ -3,7 +3,7 @@ dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-dnl serial 13
+dnl serial 14
 
 AC_DEFUN([gl_UTIMENS],
 [
@@ -11,9 +11,10 @@ AC_DEFUN([gl_UTIMENS],
   AC_REQUIRE([gl_FUNC_UTIMES])
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CHECK_FUNCS_ONCE([futimens lutimes])
+  AC_CHECK_FUNCS_ONCE([lutimes])
   gl_CHECK_FUNCS_ANDROID([futimes], [[#include <sys/time.h>]])
   gl_CHECK_FUNCS_ANDROID([futimesat], [[#include <sys/time.h>]])
+  gl_CHECK_FUNCS_ANDROID([futimens], [[#include <sys/stat.h>]])
   gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]])
 
   if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then
-- 
2.34.1


[-- Attachment #9: 0008-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 44273 bytes --]

From 4e763315017dfffcde655329d3343fef35fb0537 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:27 +0100
Subject: [PATCH 08/15] Fix warnings for functions introduced in Android API
 level 21.

* m4/_Exit.m4 (gl_FUNC__EXIT): Test for _Exit using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/c-strtod.m4 (gl_C_STRTOLD): Test for strtold_l using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/c32rtomb.m4 (gl_FUNC_C32RTOMB): Test for c32rtomb like
gl_CHECK_FUNCS_ANDROID does.
* m4/dprintf.m4 (gl_FUNC_DPRINTF): Test for dprintf using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/dprintf-posix.m4 (gl_FUNC_DPRINTF_POSIX): Likewise.
* m4/dup3.m4 (gl_FUNC_DUP3): Test for dup3 using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Test for duplocale using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/execvpe.m4 (gl_FUNC_EXECVPE): Test for execvpe using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/fts.m4 (gl_FUNC_FTS_CORE): Test for fts_open using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNC.
* m4/getprogname.m4 (gl_FUNC_GETPROGNAME): Test for getprogname using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE): Test for uselocale using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/iswblank.m4 (gl_FUNC_ISWBLANK): Test for iswblank using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/libtextstyle-optional.m4 (gl_LIBTEXTSTYLE_OPTIONAL): Test for
tcdrain using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/linkat.m4 (gl_FUNC_LINKAT): Test for linkat using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/localename.m4 (gl_LOCALENAME): Test for newlocale, duplocale,
freelocale using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/mbrtoc32.m4 (gl_CHECK_FUNC_MBRTOC32): Test for mbrtoc32 like
gl_CHECK_FUNCS_ANDROID does.
* m4/mbsnrtowcs.m4 (gl_FUNC_MBSNRTOWCS): Test for mbsnrtowcs using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/mbtowc.m4 (gl_FUNC_MBTOWC): Test for mbtowc using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Test for mknodat using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/mountlist.m4 (gl_MOUNTLIST): Test for setmntent, endmntent using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/posix_openpt.m4 (gl_FUNC_POSIX_OPENPT): Test for posix_openpt using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/pty.m4 (gl_FUNC_OPENPTY): Test for posix_openpt using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/random.m4 (gl_FUNC_RANDOM): Test for initstate, setstate using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/stpcpy.m4 (gl_FUNC_STPCPY): Test for stpcpy using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/stpncpy.m4 (gl_FUNC_STPNCPY): Test for stpncpy using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Test for symlinkat using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/truncate.m4 (gl_FUNC_TRUNCATE): Test for truncate using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/tsearch.m4 (gl_FUNC_TSEARCH): Test for twalk using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/vdprintf.m4 (gl_FUNC_VDPRINTF): Test for vdprintf using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/vdprintf-posix.m4 (gl_FUNC_VDPRINTF_POSIX): Likewise.
* m4/wcsnrtombs.m4 (gl_FUNC_WCSNRTOMBS): Test for wcsnrtombs using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/readlinkat.m4 (gl_FUNC_READLINKAT): Test for readlinkat using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/fchmodat.m4 (gl_PREREQ_FCHMODAT): Likewise.
* modules/careadlinkat (configure.ac): Likewise.
* modules/ftoastr (configure.ac): Test for strtof using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* modules/duplocale-tests (configure.ac): Test for duplocale using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* modules/hard-locale-tests (configure.ac): Likewise.
* modules/locale-tests (configure.ac): Test for newlocale using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* modules/localename-tests (configure.ac): Likewise.
* modules/tsearch-tests (configure.ac): Test for initstate using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* modules/unistr/u8-stpcpy (configure.ac): Test for stpcpy using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.

* m4/tcgetattr.m4: New file, extracted from m4/getpass.m4.
* m4/getpass.m4 (gl_PREREQ_GETPASS): Remove code that tests for
tcgetattr. Invoke gl_HAVE_TCGETATTR instead.
* modules/getpass (Files): Add tcgetattr.m4.
* modules/getpass-gnu (Files): Add tcgetattr.m4.
* modules/term-style-control (Files): Add tcgetattr.m4.
(configure.ac): Remove code that tests for tcgetattr. Invoke
gl_HAVE_TCGETATTR instead.
---
 ChangeLog                   | 89 +++++++++++++++++++++++++++++++++++++
 m4/_Exit.m4                 |  4 +-
 m4/c-strtod.m4              |  4 +-
 m4/c32rtomb.m4              | 38 +++++++++-------
 m4/dprintf-posix.m4         |  4 +-
 m4/dprintf.m4               |  4 +-
 m4/dup3.m4                  |  5 ++-
 m4/duplocale.m4             |  4 +-
 m4/execvpe.m4               |  4 +-
 m4/fchmodat.m4              |  4 +-
 m4/fts.m4                   |  4 +-
 m4/getpass.m4               | 24 +---------
 m4/getprogname.m4           |  5 ++-
 m4/intl-thread-locale.m4    |  4 +-
 m4/iswblank.m4              |  4 +-
 m4/libtextstyle-optional.m4 |  4 +-
 m4/linkat.m4                |  5 ++-
 m4/localename.m4            |  6 ++-
 m4/mbrtoc32.m4              | 38 +++++++++-------
 m4/mbsnrtowcs.m4            |  4 +-
 m4/mbtowc.m4                |  4 +-
 m4/mkfifoat.m4              |  5 ++-
 m4/mountlist.m4             | 12 ++++-
 m4/posix_openpt.m4          |  4 +-
 m4/pty.m4                   |  5 ++-
 m4/random.m4                |  5 ++-
 m4/readlinkat.m4            |  4 +-
 m4/stpcpy.m4                |  4 +-
 m4/stpncpy.m4               |  4 +-
 m4/symlinkat.m4             |  4 +-
 m4/tcgetattr.m4             | 29 ++++++++++++
 m4/truncate.m4              |  4 +-
 m4/tsearch.m4               |  4 +-
 m4/vdprintf-posix.m4        |  4 +-
 m4/vdprintf.m4              |  4 +-
 m4/wcsnrtombs.m4            |  4 +-
 modules/careadlinkat        |  2 +-
 modules/duplocale-tests     |  3 +-
 modules/ftoastr             |  2 +-
 modules/getpass             |  1 +
 modules/getpass-gnu         |  1 +
 modules/hard-locale-tests   |  2 +-
 modules/locale-tests        |  2 +-
 modules/localename-tests    |  2 +-
 modules/term-style-control  |  3 +-
 modules/tsearch-tests       |  2 +-
 modules/unistr/u8-stpcpy    |  2 +-
 47 files changed, 255 insertions(+), 125 deletions(-)
 create mode 100644 m4/tcgetattr.m4

diff --git a/ChangeLog b/ChangeLog
index 33693bec9c..ae2fb8c5c9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,92 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 21.
+	* m4/_Exit.m4 (gl_FUNC__EXIT): Test for _Exit using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/c-strtod.m4 (gl_C_STRTOLD): Test for strtold_l using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/c32rtomb.m4 (gl_FUNC_C32RTOMB): Test for c32rtomb like
+	gl_CHECK_FUNCS_ANDROID does.
+	* m4/dprintf.m4 (gl_FUNC_DPRINTF): Test for dprintf using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/dprintf-posix.m4 (gl_FUNC_DPRINTF_POSIX): Likewise.
+	* m4/dup3.m4 (gl_FUNC_DUP3): Test for dup3 using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Test for duplocale using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/execvpe.m4 (gl_FUNC_EXECVPE): Test for execvpe using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/fts.m4 (gl_FUNC_FTS_CORE): Test for fts_open using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNC.
+	* m4/getprogname.m4 (gl_FUNC_GETPROGNAME): Test for getprogname using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/intl-thread-locale.m4 (gt_FUNC_USELOCALE): Test for uselocale using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/iswblank.m4 (gl_FUNC_ISWBLANK): Test for iswblank using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/libtextstyle-optional.m4 (gl_LIBTEXTSTYLE_OPTIONAL): Test for
+	tcdrain using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/linkat.m4 (gl_FUNC_LINKAT): Test for linkat using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/localename.m4 (gl_LOCALENAME): Test for newlocale, duplocale,
+	freelocale using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/mbrtoc32.m4 (gl_CHECK_FUNC_MBRTOC32): Test for mbrtoc32 like
+	gl_CHECK_FUNCS_ANDROID does.
+	* m4/mbsnrtowcs.m4 (gl_FUNC_MBSNRTOWCS): Test for mbsnrtowcs using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/mbtowc.m4 (gl_FUNC_MBTOWC): Test for mbtowc using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Test for mknodat using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/mountlist.m4 (gl_MOUNTLIST): Test for setmntent, endmntent using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/posix_openpt.m4 (gl_FUNC_POSIX_OPENPT): Test for posix_openpt using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/pty.m4 (gl_FUNC_OPENPTY): Test for posix_openpt using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/random.m4 (gl_FUNC_RANDOM): Test for initstate, setstate using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/stpcpy.m4 (gl_FUNC_STPCPY): Test for stpcpy using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/stpncpy.m4 (gl_FUNC_STPNCPY): Test for stpncpy using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Test for symlinkat using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/truncate.m4 (gl_FUNC_TRUNCATE): Test for truncate using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/tsearch.m4 (gl_FUNC_TSEARCH): Test for twalk using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/vdprintf.m4 (gl_FUNC_VDPRINTF): Test for vdprintf using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/vdprintf-posix.m4 (gl_FUNC_VDPRINTF_POSIX): Likewise.
+	* m4/wcsnrtombs.m4 (gl_FUNC_WCSNRTOMBS): Test for wcsnrtombs using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/readlinkat.m4 (gl_FUNC_READLINKAT): Test for readlinkat using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/fchmodat.m4 (gl_PREREQ_FCHMODAT): Likewise.
+	* modules/careadlinkat (configure.ac): Likewise.
+	* modules/ftoastr (configure.ac): Test for strtof using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* modules/duplocale-tests (configure.ac): Test for duplocale using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* modules/hard-locale-tests (configure.ac): Likewise.
+	* modules/locale-tests (configure.ac): Test for newlocale using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* modules/localename-tests (configure.ac): Likewise.
+	* modules/tsearch-tests (configure.ac): Test for initstate using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* modules/unistr/u8-stpcpy (configure.ac): Test for stpcpy using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+
+	* m4/tcgetattr.m4: New file, extracted from m4/getpass.m4.
+	* m4/getpass.m4 (gl_PREREQ_GETPASS): Remove code that tests for
+	tcgetattr. Invoke gl_HAVE_TCGETATTR instead.
+	* modules/getpass (Files): Add tcgetattr.m4.
+	* modules/getpass-gnu (Files): Add tcgetattr.m4.
+	* modules/term-style-control (Files): Add tcgetattr.m4.
+	(configure.ac): Remove code that tests for tcgetattr. Invoke
+	gl_HAVE_TCGETATTR instead.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 19.
diff --git a/m4/_Exit.m4 b/m4/_Exit.m4
index c4cf270eff..61e1f848b7 100644
--- a/m4/_Exit.m4
+++ b/m4/_Exit.m4
@@ -1,4 +1,4 @@
-# _Exit.m4 serial 2
+# _Exit.m4 serial 3
 dnl Copyright (C) 2010-2023 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,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC__EXIT],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
-  AC_CHECK_FUNCS([_Exit])
+  gl_CHECK_FUNCS_ANDROID([_Exit], [[#include <stdlib.h>]])
   if test $ac_cv_func__Exit = no; then
     HAVE__EXIT=0
   fi
diff --git a/m4/c-strtod.m4 b/m4/c-strtod.m4
index e92badad1c..746b39bb44 100644
--- a/m4/c-strtod.m4
+++ b/m4/c-strtod.m4
@@ -1,4 +1,4 @@
-# c-strtod.m4 serial 18
+# c-strtod.m4 serial 19
 
 # Copyright (C) 2004-2006, 2009-2023 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
@@ -47,5 +47,5 @@ AC_DEFUN([gl_C_STRTOLD],
 [
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([gt_FUNC_USELOCALE])
-  AC_CHECK_FUNCS([strtold_l])
+  gl_CHECK_FUNCS_ANDROID([strtold_l], [[#include <stdlib.h>]])
 ])
diff --git a/m4/c32rtomb.m4 b/m4/c32rtomb.m4
index 739d21d385..41c07e75c9 100644
--- a/m4/c32rtomb.m4
+++ b/m4/c32rtomb.m4
@@ -1,4 +1,4 @@
-# c32rtomb.m4 serial 3
+# c32rtomb.m4 serial 4
 dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,21 +10,27 @@ AC_DEFUN([gl_FUNC_C32RTOMB],
 
   AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
 
-  dnl We can't use AC_CHECK_FUNC here, because c32rtomb() is defined as a
-  dnl static inline function on Haiku 2020.
-  AC_CACHE_CHECK([for c32rtomb], [gl_cv_func_c32rtomb],
-    [AC_LINK_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[#include <stdlib.h>
-            #include <uchar.h>
-          ]],
-          [[char buf[8];
-            return c32rtomb (buf, 0, NULL) == 0;
-          ]])
-       ],
-       [gl_cv_func_c32rtomb=yes],
-       [gl_cv_func_c32rtomb=no])
-    ])
+  dnl Cf. gl_CHECK_FUNCS_ANDROID
+  AC_CHECK_DECL([c32rtomb], , , [[#include <uchar.h>]])
+  if test $ac_cv_have_decl_c32rtomb = yes; then
+    dnl We can't use AC_CHECK_FUNC here, because c32rtomb() is defined as a
+    dnl static inline function on Haiku 2020.
+    AC_CACHE_CHECK([for c32rtomb], [gl_cv_func_c32rtomb],
+      [AC_LINK_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <stdlib.h>
+              #include <uchar.h>
+            ]],
+            [[char buf[8];
+              return c32rtomb (buf, 0, NULL) == 0;
+            ]])
+         ],
+         [gl_cv_func_c32rtomb=yes],
+         [gl_cv_func_c32rtomb=no])
+      ])
+  else
+    gl_cv_func_c32rtomb=no
+  fi
   if test $gl_cv_func_c32rtomb = no; then
     HAVE_C32RTOMB=0
   else
diff --git a/m4/dprintf-posix.m4 b/m4/dprintf-posix.m4
index 4efd46cc7d..a25ef4164e 100644
--- a/m4/dprintf-posix.m4
+++ b/m4/dprintf-posix.m4
@@ -1,4 +1,4 @@
-# dprintf-posix.m4 serial 2
+# dprintf-posix.m4 serial 3
 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -21,7 +21,7 @@ AC_DEFUN([gl_FUNC_DPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_dprintf_posix=no
-  AC_CHECK_FUNCS_ONCE([dprintf])
+  gl_CHECK_FUNCS_ANDROID([dprintf], [[#include <stdio.h>]])
   if test $ac_cv_func_dprintf = yes; then
     case "$gl_cv_func_printf_sizes_c99" in
       *yes)
diff --git a/m4/dprintf.m4 b/m4/dprintf.m4
index 7e3ea0bbf6..54c186620b 100644
--- a/m4/dprintf.m4
+++ b/m4/dprintf.m4
@@ -1,4 +1,4 @@
-# dprintf.m4 serial 1
+# dprintf.m4 serial 2
 dnl Copyright (C) 2009-2023 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,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_DPRINTF],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  AC_CHECK_FUNCS_ONCE([dprintf])
+  gl_CHECK_FUNCS_ANDROID([dprintf], [[#include <stdio.h>]])
   if test $ac_cv_func_dprintf = no; then
     HAVE_DPRINTF=0
     gl_REPLACE_DPRINTF
diff --git a/m4/dup3.m4 b/m4/dup3.m4
index 93a1d78509..644a172006 100644
--- a/m4/dup3.m4
+++ b/m4/dup3.m4
@@ -1,4 +1,4 @@
-# dup3.m4 serial 5
+# dup3.m4 serial 6
 dnl Copyright (C) 2009-2023 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,7 +11,8 @@ AC_DEFUN([gl_FUNC_DUP3],
   dnl Persuade glibc <unistd.h> to declare dup3().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([dup3 setdtablesize])
+  AC_CHECK_FUNCS_ONCE([setdtablesize])
+  gl_CHECK_FUNCS_ANDROID([dup3], [[#include <unistd.h>]])
   if test $ac_cv_func_dup3 != yes; then
     HAVE_DUP3=0
   fi
diff --git a/m4/duplocale.m4 b/m4/duplocale.m4
index c1525e90f5..e97cf5c055 100644
--- a/m4/duplocale.m4
+++ b/m4/duplocale.m4
@@ -1,4 +1,4 @@
-# duplocale.m4 serial 14
+# duplocale.m4 serial 15
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_DUPLOCALE],
   AC_REQUIRE([gl_LOCALE_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
   AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
-  AC_CHECK_FUNCS_ONCE([duplocale])
+  gl_CHECK_FUNCS_ANDROID([duplocale], [[#include <locale.h>]])
   if test $ac_cv_func_duplocale = yes; then
     dnl Check against glibc bug where duplocale crashes.
     dnl See <https://sourceware.org/bugzilla/show_bug.cgi?id=10969>.
diff --git a/m4/execvpe.m4 b/m4/execvpe.m4
index 5ddc45d509..6c0a0e9b7d 100644
--- a/m4/execvpe.m4
+++ b/m4/execvpe.m4
@@ -1,4 +1,4 @@
-# execvpe.m4 serial 1
+# execvpe.m4 serial 2
 dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -15,7 +15,7 @@ AC_DEFUN([gl_FUNC_EXECVPE],
   case "$host_os" in
     mingw*) REPLACE_EXECVPE=1 ;;
     *)
-      AC_CHECK_FUNCS([execvpe])
+      gl_CHECK_FUNCS_ANDROID([execvpe], [[#include <unistd.h>]])
       if test $ac_cv_func_execvpe != yes; then
         HAVE_EXECVPE=0
       fi
diff --git a/m4/fchmodat.m4 b/m4/fchmodat.m4
index 7a3ee863e3..5356da40ba 100644
--- a/m4/fchmodat.m4
+++ b/m4/fchmodat.m4
@@ -1,4 +1,4 @@
-# fchmodat.m4 serial 7
+# fchmodat.m4 serial 8
 dnl Copyright (C) 2004-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -97,6 +97,6 @@ AC_DEFUN([gl_FUNC_FCHMODAT],
 # Prerequisites of lib/fchmodat.c.
 AC_DEFUN([gl_PREREQ_FCHMODAT],
 [
-  AC_CHECK_FUNCS_ONCE([readlinkat])
+  gl_CHECK_FUNCS_ANDROID([readlinkat], [[#include <unistd.h>]])
   :
 ])
diff --git a/m4/fts.m4 b/m4/fts.m4
index cdab461d45..eec034287c 100644
--- a/m4/fts.m4
+++ b/m4/fts.m4
@@ -1,4 +1,4 @@
-#serial 22
+#serial 23
 dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -29,7 +29,7 @@ AC_DEFUN([gl_FUNC_FTS_CORE],
     fi
   fi
 
-  AC_CHECK_FUNC([fts_open])
+  gl_CHECK_FUNCS_ANDROID([fts_open], [[#include <fts.h>]])
   if test $ac_cv_func_fts_open = yes; then
     dnl The system already has the symbols fts_open, etc.
     dnl Avoid conflicts between these symbols and ours at the linker level.
diff --git a/m4/getpass.m4 b/m4/getpass.m4
index 2dce1e0dfe..0e46edf64b 100644
--- a/m4/getpass.m4
+++ b/m4/getpass.m4
@@ -1,4 +1,4 @@
-# getpass.m4 serial 18
+# getpass.m4 serial 19
 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2023 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -64,27 +64,7 @@ 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.])
+  gl_HAVE_TCGETATTR
 
   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.
diff --git a/m4/getprogname.m4 b/m4/getprogname.m4
index b67c527cb6..7c306c80a9 100644
--- a/m4/getprogname.m4
+++ b/m4/getprogname.m4
@@ -5,12 +5,13 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# serial 5
 
 AC_DEFUN([gl_FUNC_GETPROGNAME],
 [
-  AC_CHECK_FUNCS_ONCE([getprogname getexecname])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  gl_CHECK_FUNCS_ANDROID([getprogname], [[#include <stdlib.h>]])
+  AC_CHECK_FUNCS_ONCE([getexecname])
   ac_found=0
   AC_CHECK_DECLS([program_invocation_name], [ac_found=1], [],
     [#include <errno.h>])
diff --git a/m4/intl-thread-locale.m4 b/m4/intl-thread-locale.m4
index c231899511..90bc3b1aa6 100644
--- a/m4/intl-thread-locale.m4
+++ b/m4/intl-thread-locale.m4
@@ -1,4 +1,4 @@
-# intl-thread-locale.m4 serial 9
+# intl-thread-locale.m4 serial 10
 dnl Copyright (C) 2015-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -171,7 +171,7 @@ AC_DEFUN([gt_FUNC_USELOCALE],
   dnl Persuade glibc and Solaris <locale.h> to define 'locale_t'.
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([uselocale])
+  gl_CHECK_FUNCS_ANDROID([uselocale], [[#include <locale.h>]])
 
   dnl On AIX 7.2, the uselocale() function is not documented and leads to
   dnl crashes in subsequent setlocale() invocations.
diff --git a/m4/iswblank.m4 b/m4/iswblank.m4
index ffb0d9bf30..f3f96bb784 100644
--- a/m4/iswblank.m4
+++ b/m4/iswblank.m4
@@ -1,4 +1,4 @@
-# iswblank.m4 serial 5
+# iswblank.m4 serial 6
 dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,7 +10,7 @@ AC_DEFUN([gl_FUNC_ISWBLANK],
   AC_REQUIRE([gl_WCTYPE_H])
   dnl Persuade glibc <wctype.h> to declare iswblank().
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_FUNCS_ONCE([iswblank])
+  gl_CHECK_FUNCS_ANDROID([iswblank], [[#include <wctype.h>]])
   AC_CHECK_DECLS([iswblank], , , [[
     #include <wchar.h>
     #include <wctype.h>
diff --git a/m4/libtextstyle-optional.m4 b/m4/libtextstyle-optional.m4
index 93bec70629..3101cf7e3a 100644
--- a/m4/libtextstyle-optional.m4
+++ b/m4/libtextstyle-optional.m4
@@ -1,4 +1,4 @@
-# libtextstyle-optional.m4 serial 4
+# libtextstyle-optional.m4 serial 5
 dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -27,7 +27,7 @@ AC_DEFUN([gl_LIBTEXTSTYLE_OPTIONAL],
   else
     GL_GENERATE_TEXTSTYLE_H=true
     AC_REQUIRE([AC_C_INLINE])
-    AC_CHECK_FUNCS_ONCE([tcdrain])
+    gl_CHECK_FUNCS_ANDROID([tcdrain], [[#include <termios.h>]])
   fi
 
   dnl Update the value of the TEXTSTYLE_H variable and the
diff --git a/m4/linkat.m4 b/m4/linkat.m4
index 29978b4608..9b35fc14e3 100644
--- a/m4/linkat.m4
+++ b/m4/linkat.m4
@@ -1,4 +1,4 @@
-# serial 14
+# serial 15
 # See if we need to provide linkat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -15,7 +15,8 @@ AC_DEFUN([gl_FUNC_LINKAT],
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CHECK_FUNCS_ONCE([linkat symlink])
+  AC_CHECK_FUNCS_ONCE([symlink])
+  gl_CHECK_FUNCS_ANDROID([linkat], [[#include <unistd.h>]])
   if test $ac_cv_func_linkat = no; then
     HAVE_LINKAT=0
   else
diff --git a/m4/localename.m4 b/m4/localename.m4
index 03cce48033..43725d8444 100644
--- a/m4/localename.m4
+++ b/m4/localename.m4
@@ -1,4 +1,4 @@
-# localename.m4 serial 8
+# localename.m4 serial 9
 dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,9 @@ AC_DEFUN([gl_LOCALENAME],
   AC_REQUIRE([gt_INTL_MACOSX])
   AC_CHECK_HEADERS_ONCE([langinfo.h])
   if test $HAVE_LOCALE_T = 1; then
-    AC_CHECK_FUNCS_ONCE([newlocale duplocale freelocale])
+    gl_CHECK_FUNCS_ANDROID([newlocale], [[#include <locale.h>]])
+    gl_CHECK_FUNCS_ANDROID([duplocale], [[#include <locale.h>]])
+    gl_CHECK_FUNCS_ANDROID([freelocale], [[#include <locale.h>]])
     gl_func_newlocale="$ac_cv_func_newlocale"
     gl_func_duplocale="$ac_cv_func_duplocale"
     gl_func_freelocale="$ac_cv_func_freelocale"
diff --git a/m4/mbrtoc32.m4 b/m4/mbrtoc32.m4
index 082497d2f1..f2de33aff6 100644
--- a/m4/mbrtoc32.m4
+++ b/m4/mbrtoc32.m4
@@ -1,4 +1,4 @@
-# mbrtoc32.m4 serial 9
+# mbrtoc32.m4 serial 10
 dnl Copyright (C) 2014-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -44,23 +44,29 @@ AC_DEFUN([gl_FUNC_MBRTOC32],
   fi
 ])
 
-dnl We can't use AC_CHECK_FUNC here, because mbrtoc32() is defined as a
-dnl static inline function on Haiku 2020.
 AC_DEFUN([gl_CHECK_FUNC_MBRTOC32],
 [
-  AC_CACHE_CHECK([for mbrtoc32], [gl_cv_func_mbrtoc32],
-    [AC_LINK_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[#include <stdlib.h>
-            #include <uchar.h>
-          ]],
-          [[char32_t c;
-            return mbrtoc32 (&c, "", 1, NULL) == 0;
-          ]])
-       ],
-       [gl_cv_func_mbrtoc32=yes],
-       [gl_cv_func_mbrtoc32=no])
-    ])
+  dnl Cf. gl_CHECK_FUNCS_ANDROID
+  AC_CHECK_DECL([mbrtoc32], , , [[#include <uchar.h>]])
+  if test $ac_cv_have_decl_mbrtoc32 = yes; then
+    dnl We can't use AC_CHECK_FUNC here, because mbrtoc32() is defined as a
+    dnl static inline function on Haiku 2020.
+    AC_CACHE_CHECK([for mbrtoc32], [gl_cv_func_mbrtoc32],
+      [AC_LINK_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <stdlib.h>
+              #include <uchar.h>
+            ]],
+            [[char32_t c;
+              return mbrtoc32 (&c, "", 1, NULL) == 0;
+            ]])
+         ],
+         [gl_cv_func_mbrtoc32=yes],
+         [gl_cv_func_mbrtoc32=no])
+      ])
+  else
+    gl_cv_func_mbrtoc32=no
+  fi
 ])
 
 AC_DEFUN([gl_MBRTOC32_EMPTY_INPUT],
diff --git a/m4/mbsnrtowcs.m4 b/m4/mbsnrtowcs.m4
index d36ba4797d..1b398c7ca7 100644
--- a/m4/mbsnrtowcs.m4
+++ b/m4/mbsnrtowcs.m4
@@ -1,4 +1,4 @@
-# mbsnrtowcs.m4 serial 6
+# mbsnrtowcs.m4 serial 7
 dnl Copyright (C) 2008, 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,7 @@ AC_DEFUN([gl_FUNC_MBSNRTOWCS],
   AC_REQUIRE([AC_TYPE_MBSTATE_T])
   gl_MBSTATE_T_BROKEN
 
-  AC_CHECK_FUNCS_ONCE([mbsnrtowcs])
+  gl_CHECK_FUNCS_ANDROID([mbsnrtowcs], [[#include <wchar.h>]])
   if test $ac_cv_func_mbsnrtowcs = no; then
     HAVE_MBSNRTOWCS=0
   else
diff --git a/m4/mbtowc.m4 b/m4/mbtowc.m4
index 7823be0e0c..88eb39a6de 100644
--- a/m4/mbtowc.m4
+++ b/m4/mbtowc.m4
@@ -1,4 +1,4 @@
-# mbtowc.m4 serial 3
+# mbtowc.m4 serial 4
 dnl Copyright (C) 2011-2023 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,7 +8,7 @@ AC_DEFUN([gl_FUNC_MBTOWC],
 [
   AC_REQUIRE([gl_STDLIB_H_DEFAULTS])
 
-  AC_CHECK_FUNCS([mbtowc])
+  gl_CHECK_FUNCS_ANDROID([mbtowc], [[#include <stdlib.h>]])
   if test $ac_cv_func_mbtowc = no; then
     HAVE_MBTOWC=0
   else
diff --git a/m4/mkfifoat.m4 b/m4/mkfifoat.m4
index cb324ff2a4..8bf5a227ee 100644
--- a/m4/mkfifoat.m4
+++ b/m4/mkfifoat.m4
@@ -1,4 +1,4 @@
-# serial 5
+# serial 6
 # See if we need to provide mkfifoat/mknodat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -18,7 +18,8 @@ AC_DEFUN([gl_FUNC_MKFIFOAT],
 
   AC_REQUIRE([gl_FUNC_OPENAT])
 
-  AC_CHECK_FUNCS_ONCE([mkfifoat mknodat])
+  gl_CHECK_FUNCS_ANDROID([mknodat], [[#include <sys/stat.h>]])
+  AC_CHECK_FUNCS_ONCE([mkfifoat])
   if test $ac_cv_func_mkfifoat = yes; then
     dnl Check for AIX 7.2 bug with trailing slash.
     AC_CACHE_CHECK([whether mkfifoat rejects trailing slashes],
diff --git a/m4/mountlist.m4 b/m4/mountlist.m4
index a9b4edb9f0..343017d354 100644
--- a/m4/mountlist.m4
+++ b/m4/mountlist.m4
@@ -1,4 +1,4 @@
-# serial 15
+# serial 16
 dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -106,7 +106,15 @@ $ac_includes_default
           [Define if there is a function named getmntent for reading the list
            of mounted file systems, and that function takes a single argument.
            (4.3BSD, SunOS, HP-UX, Irix)])
-        AC_CHECK_FUNCS([setmntent endmntent hasmntopt])
+        AC_CHECK_FUNCS([hasmntopt])
+        gl_CHECK_FUNCS_ANDROID([setmntent],
+          [[#include <stdio.h>
+            #include <mntent.h>
+          ]])
+        gl_CHECK_FUNCS_ANDROID([endmntent],
+          [[#include <stdio.h>
+            #include <mntent.h>
+          ]])
       fi
     fi
 
diff --git a/m4/posix_openpt.m4 b/m4/posix_openpt.m4
index 6ab66f5abf..f5912a12bb 100644
--- a/m4/posix_openpt.m4
+++ b/m4/posix_openpt.m4
@@ -1,4 +1,4 @@
-# posix_openpt.m4 serial 2
+# posix_openpt.m4 serial 3
 dnl Copyright (C) 2011-2023 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,7 +11,7 @@ AC_DEFUN([gl_FUNC_POSIX_OPENPT],
   dnl Persuade Solaris <stdlib.h> to declare posix_openpt().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([posix_openpt])
+  gl_CHECK_FUNCS_ANDROID([posix_openpt], [[#include <stdlib.h>]])
   if test $ac_cv_func_posix_openpt != yes; then
     dnl The system does not have posix_openpt.
     HAVE_POSIX_OPENPT=0
diff --git a/m4/pty.m4 b/m4/pty.m4
index 794678eb7a..ac4ac2651a 100644
--- a/m4/pty.m4
+++ b/m4/pty.m4
@@ -1,4 +1,4 @@
-# pty.m4 serial 14
+# pty.m4 serial 15
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -145,7 +145,8 @@ AC_DEFUN([gl_FUNC_OPENPTY],
     dnl The system does not have openpty.
     HAVE_OPENPTY=0
     dnl Prerequisites of lib/openpty.c in this case.
-    AC_CHECK_FUNCS([_getpty posix_openpt])
+    AC_CHECK_FUNCS([_getpty])
+    gl_CHECK_FUNCS_ANDROID([posix_openpt], [[#include <stdlib.h>]])
   fi
 ])
 
diff --git a/m4/random.m4 b/m4/random.m4
index 939a844029..b99603cf9a 100644
--- a/m4/random.m4
+++ b/m4/random.m4
@@ -1,4 +1,4 @@
-# random.m4 serial 4
+# random.m4 serial 5
 dnl Copyright (C) 2012-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -24,7 +24,8 @@ AC_DEFUN([gl_FUNC_RANDOM],
     HAVE_INITSTATE=0
     HAVE_SETSTATE=0
   else
-    AC_CHECK_FUNCS([initstate setstate])
+    gl_CHECK_FUNCS_ANDROID([initstate], [[#include <stdlib.h>]])
+    gl_CHECK_FUNCS_ANDROID([setstate], [[#include <stdlib.h>]])
     if test $ac_cv_func_initstate = no; then
       HAVE_INITSTATE=0
     fi
diff --git a/m4/readlinkat.m4 b/m4/readlinkat.m4
index ffd0b8e9bc..416f9c0d64 100644
--- a/m4/readlinkat.m4
+++ b/m4/readlinkat.m4
@@ -1,4 +1,4 @@
-# serial 6
+# serial 7
 # See if we need to provide readlinkat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_READLINKAT],
 [
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_FUNCS_ONCE([readlinkat])
+  gl_CHECK_FUNCS_ANDROID([readlinkat], [[#include <unistd.h>]])
   AC_REQUIRE([gl_FUNC_READLINK])
   if test $ac_cv_func_readlinkat = no; then
     HAVE_READLINKAT=0
diff --git a/m4/stpcpy.m4 b/m4/stpcpy.m4
index e8a76bc34f..462f511d25 100644
--- a/m4/stpcpy.m4
+++ b/m4/stpcpy.m4
@@ -1,4 +1,4 @@
-# stpcpy.m4 serial 9
+# stpcpy.m4 serial 10
 dnl Copyright (C) 2002, 2007, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,7 @@ AC_DEFUN([gl_FUNC_STPCPY],
   AC_REQUIRE([AC_C_RESTRICT])
 
   AC_REQUIRE([gl_STRING_H_DEFAULTS])
-  AC_CHECK_FUNCS([stpcpy])
+  gl_CHECK_FUNCS_ANDROID([stpcpy], [[#include <string.h>]])
   if test $ac_cv_func_stpcpy = no; then
     HAVE_STPCPY=0
   fi
diff --git a/m4/stpncpy.m4 b/m4/stpncpy.m4
index 7238329dc1..c321093b66 100644
--- a/m4/stpncpy.m4
+++ b/m4/stpncpy.m4
@@ -1,4 +1,4 @@
-# stpncpy.m4 serial 19
+# stpncpy.m4 serial 20
 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -28,7 +28,7 @@ AC_DEFUN([gl_FUNC_STPNCPY],
   dnl Only the glibc return value is useful in practice.
 
   AC_CHECK_DECLS_ONCE([stpncpy])
-  AC_CHECK_FUNCS_ONCE([stpncpy])
+  gl_CHECK_FUNCS_ANDROID([stpncpy], [[#include <string.h>]])
   if test $ac_cv_func_stpncpy = yes; then
     AC_CACHE_CHECK([for working stpncpy], [gl_cv_func_stpncpy], [
       AC_RUN_IFELSE(
diff --git a/m4/symlinkat.m4 b/m4/symlinkat.m4
index 24fa7685c4..d12f91997c 100644
--- a/m4/symlinkat.m4
+++ b/m4/symlinkat.m4
@@ -1,4 +1,4 @@
-# serial 10
+# serial 11
 # See if we need to provide symlinkat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -14,7 +14,7 @@ AC_DEFUN([gl_FUNC_SYMLINKAT],
   AC_REQUIRE([gl_FUNC_OPENAT])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CHECK_FUNCS_ONCE([symlinkat])
+  gl_CHECK_FUNCS_ANDROID([symlinkat], [[#include <unistd.h>]])
   if test $ac_cv_func_symlinkat = no; then
     HAVE_SYMLINKAT=0
   else
diff --git a/m4/tcgetattr.m4 b/m4/tcgetattr.m4
new file mode 100644
index 0000000000..2d55805b26
--- /dev/null
+++ b/m4/tcgetattr.m4
@@ -0,0 +1,29 @@
+# tcgetattr.m4 serial 1
+dnl Copyright (C) 2002-2023 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_HAVE_TCGETATTR],
+[
+  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.])
+])
diff --git a/m4/truncate.m4 b/m4/truncate.m4
index 312d0d6864..b047af34c9 100644
--- a/m4/truncate.m4
+++ b/m4/truncate.m4
@@ -1,4 +1,4 @@
-# truncate.m4 serial 3   -*- Autoconf -*-
+# truncate.m4 serial 4   -*- Autoconf -*-
 dnl Copyright (C) 2017-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_TRUNCATE],
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
 
-  AC_CHECK_FUNCS_ONCE([truncate])
+  gl_CHECK_FUNCS_ANDROID([truncate], [[#include <unistd.h>]])
   dnl AC_CHECK_FUNC is not enough here, because when compiling for Android 4.4
   dnl or older with _FILE_OFFSET_BITS=64, truncate() is not declared.  There
   dnl is a function 'truncate' in libc, but it is unsuitable, because it takes
diff --git a/m4/tsearch.m4 b/m4/tsearch.m4
index 8e6a894f83..d78da9b198 100644
--- a/m4/tsearch.m4
+++ b/m4/tsearch.m4
@@ -1,4 +1,4 @@
-# tsearch.m4 serial 9
+# tsearch.m4 serial 10
 dnl Copyright (C) 2006-2023 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,8 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_TSEARCH],
 [
   AC_REQUIRE([gl_SEARCH_H_DEFAULTS])
-  AC_CHECK_FUNCS([twalk])
   gl_CHECK_FUNCS_ANDROID([tsearch], [[#include <search.h>]])
+  gl_CHECK_FUNCS_ANDROID([twalk], [[#include <search.h>]])
   if test $ac_cv_func_tsearch = yes; then
     dnl On OpenBSD 4.0, the return value of tdelete() is incorrect.
     AC_REQUIRE([AC_PROG_CC])
diff --git a/m4/vdprintf-posix.m4 b/m4/vdprintf-posix.m4
index a873cbe003..47914cd177 100644
--- a/m4/vdprintf-posix.m4
+++ b/m4/vdprintf-posix.m4
@@ -1,4 +1,4 @@
-# vdprintf-posix.m4 serial 2
+# vdprintf-posix.m4 serial 3
 dnl Copyright (C) 2007-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -21,7 +21,7 @@ AC_DEFUN([gl_FUNC_VDPRINTF_POSIX],
   AC_REQUIRE([gl_PRINTF_PRECISION])
   AC_REQUIRE([gl_PRINTF_ENOMEM])
   gl_cv_func_vdprintf_posix=no
-  AC_CHECK_FUNCS_ONCE([vdprintf])
+  gl_CHECK_FUNCS_ANDROID([vdprintf], [[#include <stdio.h>]])
   if test $ac_cv_func_vdprintf = yes; then
     case "$gl_cv_func_printf_sizes_c99" in
       *yes)
diff --git a/m4/vdprintf.m4 b/m4/vdprintf.m4
index eeea4b7c7d..1420efdb51 100644
--- a/m4/vdprintf.m4
+++ b/m4/vdprintf.m4
@@ -1,4 +1,4 @@
-# vdprintf.m4 serial 1
+# vdprintf.m4 serial 2
 dnl Copyright (C) 2009-2023 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,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_VDPRINTF],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  AC_CHECK_FUNCS_ONCE([vdprintf])
+  gl_CHECK_FUNCS_ANDROID([vdprintf], [[#include <stdio.h>]])
   if test $ac_cv_func_vdprintf = no; then
     HAVE_VDPRINTF=0
     gl_REPLACE_VDPRINTF
diff --git a/m4/wcsnrtombs.m4 b/m4/wcsnrtombs.m4
index e31d72cc97..af6d26c78d 100644
--- a/m4/wcsnrtombs.m4
+++ b/m4/wcsnrtombs.m4
@@ -1,4 +1,4 @@
-# wcsnrtombs.m4 serial 7
+# wcsnrtombs.m4 serial 8
 dnl Copyright (C) 2008-2023 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,7 +11,7 @@ AC_DEFUN([gl_FUNC_WCSNRTOMBS],
   AC_REQUIRE([AC_TYPE_MBSTATE_T])
   gl_MBSTATE_T_BROKEN
 
-  AC_CHECK_FUNCS_ONCE([wcsnrtombs])
+  gl_CHECK_FUNCS_ANDROID([wcsnrtombs], [[#include <wchar.h>]])
   if test $ac_cv_func_wcsnrtombs = no; then
     HAVE_WCSNRTOMBS=0
   else
diff --git a/modules/careadlinkat b/modules/careadlinkat
index b3375a9b20..700a89bdb5 100644
--- a/modules/careadlinkat
+++ b/modules/careadlinkat
@@ -14,7 +14,7 @@ unistd
 
 configure.ac:
 AC_REQUIRE([AC_C_RESTRICT])
-AC_CHECK_FUNCS_ONCE([readlinkat])
+gl_CHECK_FUNCS_ANDROID([readlinkat], [[#include <unistd.h>]])
 
 Makefile.am:
 lib_SOURCES += careadlinkat.c
diff --git a/modules/duplocale-tests b/modules/duplocale-tests
index 01df43bf84..0cb7af4703 100644
--- a/modules/duplocale-tests
+++ b/modules/duplocale-tests
@@ -8,7 +8,8 @@ Depends-on:
 langinfo
 
 configure.ac:
-AC_CHECK_FUNCS_ONCE([duplocale strfmon_l snprintf_l nl_langinfo_l])
+AC_CHECK_FUNCS_ONCE([strfmon_l snprintf_l nl_langinfo_l])
+gl_CHECK_FUNCS_ANDROID([duplocale], [[#include <locale.h>]])
 AC_CHECK_HEADERS_ONCE([monetary.h])
 gt_FUNC_USELOCALE
 
diff --git a/modules/ftoastr b/modules/ftoastr
index 0088db160e..9d62add472 100644
--- a/modules/ftoastr
+++ b/modules/ftoastr
@@ -10,7 +10,7 @@ extensions
 intprops
 
 configure.ac:
-AC_CHECK_FUNCS_ONCE([strtof])
+gl_CHECK_FUNCS_ANDROID([strtof], [[#include <stdlib.h>]])
 
 Makefile.am:
 lib_SOURCES += ftoastr.c
diff --git a/modules/getpass b/modules/getpass
index 74d781aff2..e7eefa4c98 100644
--- a/modules/getpass
+++ b/modules/getpass
@@ -5,6 +5,7 @@ Files:
 lib/getpass.h
 lib/getpass.c
 m4/getpass.m4
+m4/tcgetattr.m4
 
 Depends-on:
 unistd
diff --git a/modules/getpass-gnu b/modules/getpass-gnu
index d968af7e33..e939cf2617 100644
--- a/modules/getpass-gnu
+++ b/modules/getpass-gnu
@@ -5,6 +5,7 @@ Files:
 lib/getpass.h
 lib/getpass.c
 m4/getpass.m4
+m4/tcgetattr.m4
 
 Depends-on:
 getpass
diff --git a/modules/hard-locale-tests b/modules/hard-locale-tests
index b37fc39289..e4bc65a256 100644
--- a/modules/hard-locale-tests
+++ b/modules/hard-locale-tests
@@ -8,7 +8,7 @@ Depends-on:
 configure.ac:
 gl_MUSL_LIBC
 dnl Distinguish OpenBSD >= 6.2 from OpenBSD < 6.2.
-AC_CHECK_FUNCS_ONCE([duplocale])
+gl_CHECK_FUNCS_ANDROID([duplocale], [[#include <locale.h>]])
 
 Makefile.am:
 TESTS += test-hard-locale
diff --git a/modules/locale-tests b/modules/locale-tests
index 11b840da9a..5c7c032fa8 100644
--- a/modules/locale-tests
+++ b/modules/locale-tests
@@ -6,7 +6,7 @@ assert-h
 locale-c++-tests
 
 configure.ac:
-AC_CHECK_FUNCS_ONCE([newlocale])
+gl_CHECK_FUNCS_ANDROID([newlocale], [[#include <locale.h>]])
 
 Makefile.am:
 TESTS += test-locale
diff --git a/modules/localename-tests b/modules/localename-tests
index af9ee464da..f90d82da0d 100644
--- a/modules/localename-tests
+++ b/modules/localename-tests
@@ -10,7 +10,7 @@ setlocale
 strdup
 
 configure.ac:
-AC_CHECK_FUNCS_ONCE([newlocale])
+gl_CHECK_FUNCS_ANDROID([newlocale], [[#include <locale.h>]])
 
 Makefile.am:
 TESTS += test-localename
diff --git a/modules/term-style-control b/modules/term-style-control
index 85d748d75e..9bc9f5e7b9 100644
--- a/modules/term-style-control
+++ b/modules/term-style-control
@@ -4,6 +4,7 @@ Terminal control for outputting styled text to a terminal.
 Files:
 lib/term-style-control.h
 lib/term-style-control.c
+m4/tcgetattr.m4
 
 Depends-on:
 stdbool
@@ -17,7 +18,7 @@ xalloc-die
 
 configure.ac:
 AC_REQUIRE([AC_C_INLINE])
-AC_CHECK_FUNCS_ONCE([tcgetattr])
+gl_HAVE_TCGETATTR
 
 Makefile.am:
 lib_SOURCES += term-style-control.c
diff --git a/modules/tsearch-tests b/modules/tsearch-tests
index 2612b72c4a..95f9d00386 100644
--- a/modules/tsearch-tests
+++ b/modules/tsearch-tests
@@ -20,7 +20,7 @@ AC_LINK_IFELSE(
   [],
   [TEST_TSEARCH_LIBM=-lm])
 AC_SUBST([TEST_TSEARCH_LIBM])
-AC_CHECK_FUNCS_ONCE([initstate])
+gl_CHECK_FUNCS_ANDROID([initstate], [[#include <stdlib.h>]])
 
 Makefile.am:
 TESTS += test-tsearch.sh
diff --git a/modules/unistr/u8-stpcpy b/modules/unistr/u8-stpcpy
index 8831b2e643..7f22851283 100644
--- a/modules/unistr/u8-stpcpy
+++ b/modules/unistr/u8-stpcpy
@@ -9,7 +9,7 @@ Depends-on:
 unistr/base
 
 configure.ac:
-AC_CHECK_FUNCS_ONCE([stpcpy])
+gl_CHECK_FUNCS_ANDROID([stpcpy], [[#include <string.h>]])
 gl_LIBUNISTRING_MODULE([0.9], [unistr/u8-stpcpy])
 
 Makefile.am:
-- 
2.34.1


[-- Attachment #10: 0009-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 13698 bytes --]

From bf3b90e898ca373873ac57df8c9f992eeab3bd03 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:29 +0100
Subject: [PATCH 09/15] Fix warnings for functions introduced in Android API
 level 23.

* m4/fbufmode.m4 (gl_FUNC_FBUFMODE): Test for __flbf, __fbufsize using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/filenamecat.m4 (gl_FILE_NAME_CONCAT_LGPL): Test for mempcpy using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/fpurge.m4 (gl_FUNC_FPURGE): Test for __fpurge using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/freadable.m4 (gl_FUNC_FREADABLE): Test for __freadable using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/fwritable.m4 (gl_FUNC_FWRITABLE): Test for __fwritable using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/getpass.m4 (gl_FUNC_GETPASS_GNU): Test for __fsetlocking using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/mempcpy.m4 (gl_FUNC_MEMPCPY): Test for mempcpy using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Test for mkfifoat using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/mkostemp.m4 (gl_FUNC_MKOSTEMP): Test for mkostemp using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/mkostemps.m4 (gl_FUNC_MKOSTEMPS): Test for mkostemps using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/pty.m4 (gl_FUNC_LOGIN_TTY): Test for login_tty using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/sethostname.m4 (gl_FUNC_SETHOSTNAME): Test for sethostname using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS): Test for strerror_r using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/wmempcpy.m4 (gl_FUNC_WMEMPCPY): Test for wmempcpy using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
---
 ChangeLog         | 32 ++++++++++++++++++++++++++++++++
 m4/fbufmode.m4    |  5 +++--
 m4/filenamecat.m4 |  4 ++--
 m4/fpurge.m4      |  4 ++--
 m4/freadable.m4   |  4 ++--
 m4/fwritable.m4   |  4 ++--
 m4/getpass.m4     |  4 ++--
 m4/mempcpy.m4     |  4 ++--
 m4/mkfifoat.m4    |  4 ++--
 m4/mkostemp.m4    |  4 ++--
 m4/mkostemps.m4   |  4 ++--
 m4/pty.m4         |  4 ++--
 m4/sethostname.m4 |  4 ++--
 m4/strerror_r.m4  |  2 +-
 m4/wmempcpy.m4    |  4 ++--
 15 files changed, 60 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ae2fb8c5c9..66e71304c8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 23.
+	* m4/fbufmode.m4 (gl_FUNC_FBUFMODE): Test for __flbf, __fbufsize using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/filenamecat.m4 (gl_FILE_NAME_CONCAT_LGPL): Test for mempcpy using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/fpurge.m4 (gl_FUNC_FPURGE): Test for __fpurge using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/freadable.m4 (gl_FUNC_FREADABLE): Test for __freadable using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/fwritable.m4 (gl_FUNC_FWRITABLE): Test for __fwritable using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/getpass.m4 (gl_FUNC_GETPASS_GNU): Test for __fsetlocking using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/mempcpy.m4 (gl_FUNC_MEMPCPY): Test for mempcpy using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Test for mkfifoat using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/mkostemp.m4 (gl_FUNC_MKOSTEMP): Test for mkostemp using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/mkostemps.m4 (gl_FUNC_MKOSTEMPS): Test for mkostemps using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/pty.m4 (gl_FUNC_LOGIN_TTY): Test for login_tty using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/sethostname.m4 (gl_FUNC_SETHOSTNAME): Test for sethostname using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS): Test for strerror_r using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/wmempcpy.m4 (gl_FUNC_WMEMPCPY): Test for wmempcpy using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 21.
diff --git a/m4/fbufmode.m4 b/m4/fbufmode.m4
index 843a51b2ff..c408584192 100644
--- a/m4/fbufmode.m4
+++ b/m4/fbufmode.m4
@@ -1,4 +1,4 @@
-# fbufmode.m4 serial 3
+# fbufmode.m4 serial 4
 dnl Copyright (C) 2007, 2009-2023 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,5 +8,6 @@ AC_DEFUN([gl_FUNC_FBUFMODE],
 [
   dnl Prerequisites of lib/fbufmode.c.
   AC_CHECK_HEADERS_ONCE([stdio_ext.h])
-  AC_CHECK_FUNCS_ONCE([__flbf __fbufsize])
+  gl_CHECK_FUNCS_ANDROID([__flbf], [[#include <stdio_ext.h>]])
+  gl_CHECK_FUNCS_ANDROID([__fbufsize], [[#include <stdio_ext.h>]])
 ])
diff --git a/m4/filenamecat.m4 b/m4/filenamecat.m4
index d09b125cb0..3dab236d1a 100644
--- a/m4/filenamecat.m4
+++ b/m4/filenamecat.m4
@@ -1,4 +1,4 @@
-# filenamecat.m4 serial 11
+# filenamecat.m4 serial 12
 dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,5 +12,5 @@ AC_DEFUN([gl_FILE_NAME_CONCAT],
 AC_DEFUN([gl_FILE_NAME_CONCAT_LGPL],
 [
   dnl Prerequisites of lib/filenamecat-lgpl.c.
-  AC_CHECK_FUNCS_ONCE([mempcpy])
+  gl_CHECK_FUNCS_ANDROID([mempcpy], [[#include <string.h>]])
 ])
diff --git a/m4/fpurge.m4 b/m4/fpurge.m4
index b365409d05..8208250ee5 100644
--- a/m4/fpurge.m4
+++ b/m4/fpurge.m4
@@ -1,4 +1,4 @@
-# fpurge.m4 serial 12
+# fpurge.m4 serial 13
 dnl Copyright (C) 2007, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,7 +10,7 @@ AC_DEFUN([gl_FUNC_FPURGE],
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_CHECK_HEADERS_ONCE([stdio_ext.h])
   AC_CHECK_FUNCS_ONCE([fpurge])
-  AC_CHECK_FUNCS_ONCE([__fpurge])
+  gl_CHECK_FUNCS_ANDROID([__fpurge], [[#include <stdio_ext.h>]])
   AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]])
   if test "x$ac_cv_func_fpurge" = xyes; then
     HAVE_FPURGE=1
diff --git a/m4/freadable.m4 b/m4/freadable.m4
index a86fdcbcb3..fce67810e9 100644
--- a/m4/freadable.m4
+++ b/m4/freadable.m4
@@ -1,4 +1,4 @@
-# freadable.m4 serial 3
+# freadable.m4 serial 4
 dnl Copyright (C) 2007, 2009-2023 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,5 +7,5 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_FREADABLE],
 [
   AC_CHECK_HEADERS_ONCE([stdio_ext.h])
-  AC_CHECK_FUNCS_ONCE([__freadable])
+  gl_CHECK_FUNCS_ANDROID([__freadable], [[#include <stdio_ext.h>]])
 ])
diff --git a/m4/fwritable.m4 b/m4/fwritable.m4
index 5452c29095..0c4dc20149 100644
--- a/m4/fwritable.m4
+++ b/m4/fwritable.m4
@@ -1,4 +1,4 @@
-# fwritable.m4 serial 3
+# fwritable.m4 serial 4
 dnl Copyright (C) 2007, 2009-2023 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,5 +7,5 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_FWRITABLE],
 [
   AC_CHECK_HEADERS_ONCE([stdio_ext.h])
-  AC_CHECK_FUNCS_ONCE([__fwritable])
+  gl_CHECK_FUNCS_ANDROID([__fwritable], [[#include <stdio_ext.h>]])
 ])
diff --git a/m4/getpass.m4 b/m4/getpass.m4
index 0e46edf64b..27a31f80b9 100644
--- a/m4/getpass.m4
+++ b/m4/getpass.m4
@@ -1,4 +1,4 @@
-# getpass.m4 serial 19
+# getpass.m4 serial 20
 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2023 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -53,7 +53,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])
+  gl_CHECK_FUNCS_ANDROID([__fsetlocking], [[#include <stdio_ext.h>]])
   AC_CHECK_DECLS([__fsetlocking],,,
     [[#include <stdio.h>
       #if HAVE_STDIO_EXT_H
diff --git a/m4/mempcpy.m4 b/m4/mempcpy.m4
index 55bee2ab7a..d663b67174 100644
--- a/m4/mempcpy.m4
+++ b/m4/mempcpy.m4
@@ -1,4 +1,4 @@
-# mempcpy.m4 serial 12
+# mempcpy.m4 serial 13
 dnl Copyright (C) 2003-2004, 2006-2007, 2009-2023 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -14,7 +14,7 @@ AC_DEFUN([gl_FUNC_MEMPCPY],
   AC_REQUIRE([AC_C_RESTRICT])
 
   AC_REQUIRE([gl_STRING_H_DEFAULTS])
-  AC_CHECK_FUNCS([mempcpy])
+  gl_CHECK_FUNCS_ANDROID([mempcpy], [[#include <string.h>]])
   if test $ac_cv_func_mempcpy = no; then
     HAVE_MEMPCPY=0
   fi
diff --git a/m4/mkfifoat.m4 b/m4/mkfifoat.m4
index 8bf5a227ee..e9ed962415 100644
--- a/m4/mkfifoat.m4
+++ b/m4/mkfifoat.m4
@@ -1,4 +1,4 @@
-# serial 6
+# serial 7
 # See if we need to provide mkfifoat/mknodat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -19,7 +19,7 @@ AC_DEFUN([gl_FUNC_MKFIFOAT],
   AC_REQUIRE([gl_FUNC_OPENAT])
 
   gl_CHECK_FUNCS_ANDROID([mknodat], [[#include <sys/stat.h>]])
-  AC_CHECK_FUNCS_ONCE([mkfifoat])
+  gl_CHECK_FUNCS_ANDROID([mkfifoat], [[#include <sys/stat.h>]])
   if test $ac_cv_func_mkfifoat = yes; then
     dnl Check for AIX 7.2 bug with trailing slash.
     AC_CACHE_CHECK([whether mkfifoat rejects trailing slashes],
diff --git a/m4/mkostemp.m4 b/m4/mkostemp.m4
index a7cfac4cb8..9424f85f43 100644
--- a/m4/mkostemp.m4
+++ b/m4/mkostemp.m4
@@ -1,4 +1,4 @@
-# mkostemp.m4 serial 2
+# mkostemp.m4 serial 3
 dnl Copyright (C) 2009-2023 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,7 +11,7 @@ AC_DEFUN([gl_FUNC_MKOSTEMP],
   dnl Persuade glibc <stdlib.h> to declare mkostemp().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([mkostemp])
+  gl_CHECK_FUNCS_ANDROID([mkostemp], [[#include <stdlib.h>]])
   if test $ac_cv_func_mkostemp != yes; then
     HAVE_MKOSTEMP=0
   fi
diff --git a/m4/mkostemps.m4 b/m4/mkostemps.m4
index 5af22ac831..fdf6971496 100644
--- a/m4/mkostemps.m4
+++ b/m4/mkostemps.m4
@@ -1,4 +1,4 @@
-# mkostemps.m4 serial 2
+# mkostemps.m4 serial 3
 dnl Copyright (C) 2009-2023 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,7 +11,7 @@ AC_DEFUN([gl_FUNC_MKOSTEMPS],
   dnl Persuade glibc <stdlib.h> to declare mkostemps().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
-  AC_CHECK_FUNCS_ONCE([mkostemps])
+  gl_CHECK_FUNCS_ANDROID([mkostemps], [[#include <stdlib.h>]])
   if test $ac_cv_func_mkostemps != yes; then
     HAVE_MKOSTEMPS=0
   fi
diff --git a/m4/pty.m4 b/m4/pty.m4
index ac4ac2651a..54523fdac0 100644
--- a/m4/pty.m4
+++ b/m4/pty.m4
@@ -1,4 +1,4 @@
-# pty.m4 serial 15
+# pty.m4 serial 16
 dnl Copyright (C) 2010-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -156,6 +156,6 @@ AC_DEFUN([gl_FUNC_LOGIN_TTY],
 
   gl_saved_libs="$LIBS"
   LIBS="$LIBS $PTY_LIB"
-  AC_CHECK_FUNCS([login_tty])
+  gl_CHECK_FUNCS_ANDROID([login_tty], [[#include <utmp.h>]])
   LIBS="$gl_saved_LIBS"
 ])
diff --git a/m4/sethostname.m4 b/m4/sethostname.m4
index 8bb9b5cce0..8f3cd18c6c 100644
--- a/m4/sethostname.m4
+++ b/m4/sethostname.m4
@@ -1,4 +1,4 @@
-# sethostname.m4 serial 1
+# sethostname.m4 serial 2
 dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,7 +13,7 @@ AC_DEFUN([gl_FUNC_SETHOSTNAME],
 
   gl_PREREQ_HOST_NAME_MAX
 
-  AC_CHECK_FUNCS([sethostname])
+  gl_CHECK_FUNCS_ANDROID([sethostname], [[#include <unistd.h>]])
   if test $ac_cv_func_sethostname = no; then
     HAVE_SETHOSTNAME=0
   fi
diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4
index fb4ae6b600..a56f80087d 100644
--- a/m4/strerror_r.m4
+++ b/m4/strerror_r.m4
@@ -57,7 +57,7 @@ AC_DEFUN([gl_FUNC_STRERROR_R_WORKS],
 
   AC_REQUIRE([gl_FUNC_STRERROR_0])
 
-  AC_CHECK_FUNCS_ONCE([strerror_r])
+  gl_CHECK_FUNCS_ANDROID([strerror_r], [[#include <string.h>]])
   if test $ac_cv_func_strerror_r = yes; then
     if test "$GL_GENERATE_ERRNO_H:$REPLACE_STRERROR_0" = false:0; then
       dnl The POSIX prototype is:  int strerror_r (int, char *, size_t);
diff --git a/m4/wmempcpy.m4 b/m4/wmempcpy.m4
index 40fbb0d7ff..729128cab7 100644
--- a/m4/wmempcpy.m4
+++ b/m4/wmempcpy.m4
@@ -1,4 +1,4 @@
-# wmempcpy.m4 serial 1
+# wmempcpy.m4 serial 2
 dnl Copyright (C) 2020-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,7 @@ AC_DEFUN([gl_FUNC_WMEMPCPY],
   dnl The wmempcpy() declaration in lib/wchar.in.h uses 'restrict'.
   AC_REQUIRE([AC_C_RESTRICT])
 
-  AC_CHECK_FUNCS_ONCE([wmempcpy])
+  gl_CHECK_FUNCS_ANDROID([wmempcpy], [[#include <wchar.h>]])
   if test $ac_cv_func_wmempcpy = no; then
     HAVE_WMEMPCPY=0
   fi
-- 
2.34.1


[-- Attachment #11: 0010-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 1622 bytes --]

From 785007effef488985101ef72cc67311235289699 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:32 +0100
Subject: [PATCH 10/15] Fix warnings for functions introduced in Android API
 level 24.

* m4/strchrnul.m4 (gl_FUNC_STRCHRNUL): Test for strchrnul using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
---
 ChangeLog       | 6 ++++++
 m4/strchrnul.m4 | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 66e71304c8..eebfd2bd67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 24.
+	* m4/strchrnul.m4 (gl_FUNC_STRCHRNUL): Test for strchrnul using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 23.
diff --git a/m4/strchrnul.m4 b/m4/strchrnul.m4
index 73e0649609..a38e78531e 100644
--- a/m4/strchrnul.m4
+++ b/m4/strchrnul.m4
@@ -1,4 +1,4 @@
-# strchrnul.m4 serial 10
+# strchrnul.m4 serial 11
 dnl Copyright (C) 2003, 2007, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -10,7 +10,7 @@ AC_DEFUN([gl_FUNC_STRCHRNUL],
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
   AC_REQUIRE([gl_STRING_H_DEFAULTS])
-  AC_CHECK_FUNCS([strchrnul])
+  gl_CHECK_FUNCS_ANDROID([strchrnul], [[#include <string.h>]])
   if test $ac_cv_func_strchrnul = no; then
     HAVE_STRCHRNUL=0
   else
-- 
2.34.1


[-- Attachment #12: 0011-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 10397 bytes --]

From b92393eff2274b6c6be19a44a12798c3b93f2bbd Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:35 +0100
Subject: [PATCH 11/15] Fix warnings for functions introduced in Android API
 level 26.

* m4/mountlist.m4 (gl_MOUNTLIST): Test for hasmntopt using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Test for nl_langinfo using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/strtod.m4 (gl_PREREQ_STRTOD): Test for nl_langinfo using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
* m4/strtold.m4 (gl_PREREQ_STRTOLD): Likewise.
* m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_DIRECTIVE_A): Likewise.
* m4/strerror_r.m4 (gl_PREREQ_STRERROR_R): Test for catgets using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/utimens.m4 (gl_UTIMENS): Test for lutimes using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Test for nl_langinfo_l using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* modules/duplocale-tests (configure.ac): Likewise.
* m4/getdomainname.m4 (gl_FUNC_GETDOMAINNAME): Update comment.
---
 ChangeLog               | 20 ++++++++++++++++++++
 m4/duplocale.m4         |  5 +++--
 m4/getdomainname.m4     |  3 ++-
 m4/mountlist.m4         |  7 +++++--
 m4/nl_langinfo.m4       |  4 ++--
 m4/strerror_r.m4        |  4 ++--
 m4/strtod.m4            |  4 ++--
 m4/strtold.m4           |  4 ++--
 m4/utimens.m4           |  4 ++--
 m4/vasnprintf.m4        |  4 ++--
 modules/duplocale-tests |  3 ++-
 11 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eebfd2bd67..a39cb4c603 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 26.
+	* m4/mountlist.m4 (gl_MOUNTLIST): Test for hasmntopt using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Test for nl_langinfo using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/strtod.m4 (gl_PREREQ_STRTOD): Test for nl_langinfo using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+	* m4/strtold.m4 (gl_PREREQ_STRTOLD): Likewise.
+	* m4/vasnprintf.m4 (gl_PREREQ_VASNPRINTF_DIRECTIVE_A): Likewise.
+	* m4/strerror_r.m4 (gl_PREREQ_STRERROR_R): Test for catgets using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/utimens.m4 (gl_UTIMENS): Test for lutimes using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Test for nl_langinfo_l using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* modules/duplocale-tests (configure.ac): Likewise.
+	* m4/getdomainname.m4 (gl_FUNC_GETDOMAINNAME): Update comment.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 24.
diff --git a/m4/duplocale.m4 b/m4/duplocale.m4
index e97cf5c055..22b4bf80bd 100644
--- a/m4/duplocale.m4
+++ b/m4/duplocale.m4
@@ -1,4 +1,4 @@
-# duplocale.m4 serial 15
+# duplocale.m4 serial 17
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -19,7 +19,8 @@ AC_DEFUN([gl_FUNC_DUPLOCALE],
     dnl corresponds to the C locale.
     AC_REQUIRE([gl_LOCALE_H])
     if test $HAVE_LOCALE_T = 1; then
-      AC_CHECK_FUNCS_ONCE([snprintf_l nl_langinfo_l])
+      AC_CHECK_FUNCS_ONCE([snprintf_l])
+      gl_CHECK_FUNCS_ANDROID([nl_langinfo_l], [[#include <langinfo.h>]])
       AC_CACHE_CHECK([whether duplocale(LC_GLOBAL_LOCALE) works],
         [gl_cv_func_duplocale_works],
         [AC_RUN_IFELSE(
diff --git a/m4/getdomainname.m4 b/m4/getdomainname.m4
index 1510a66163..8b118bafe7 100644
--- a/m4/getdomainname.m4
+++ b/m4/getdomainname.m4
@@ -1,4 +1,4 @@
-# getdomainname.m4 serial 11
+# getdomainname.m4 serial 12
 dnl Copyright (C) 2002-2003, 2008-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -85,6 +85,7 @@ AC_DEFUN([gl_FUNC_GETDOMAINNAME],
     HAVE_DECL_GETDOMAINNAME=0
   fi
 
+  dnl TODO Android, cf. gl_CHECK_FUNCS_ANDROID.
   if { test $ac_cv_func_getdomainname = yes \
        && test $gl_cv_decl_getdomainname_argtype2 != size_t; \
      } \
diff --git a/m4/mountlist.m4 b/m4/mountlist.m4
index 343017d354..80b4aa4239 100644
--- a/m4/mountlist.m4
+++ b/m4/mountlist.m4
@@ -1,4 +1,4 @@
-# serial 16
+# serial 17
 dnl Copyright (C) 2002-2006, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -106,7 +106,6 @@ $ac_includes_default
           [Define if there is a function named getmntent for reading the list
            of mounted file systems, and that function takes a single argument.
            (4.3BSD, SunOS, HP-UX, Irix)])
-        AC_CHECK_FUNCS([hasmntopt])
         gl_CHECK_FUNCS_ANDROID([setmntent],
           [[#include <stdio.h>
             #include <mntent.h>
@@ -115,6 +114,10 @@ $ac_includes_default
           [[#include <stdio.h>
             #include <mntent.h>
           ]])
+        gl_CHECK_FUNCS_ANDROID([hasmntopt],
+          [[#include <stdio.h>
+            #include <mntent.h>
+          ]])
       fi
     fi
 
diff --git a/m4/nl_langinfo.m4 b/m4/nl_langinfo.m4
index f3192f30d1..c7146ace03 100644
--- a/m4/nl_langinfo.m4
+++ b/m4/nl_langinfo.m4
@@ -1,4 +1,4 @@
-# nl_langinfo.m4 serial 9
+# nl_langinfo.m4 serial 10
 dnl Copyright (C) 2009-2023 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,7 +8,7 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
 [
   AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
   AC_REQUIRE([gl_LANGINFO_H])
-  AC_CHECK_FUNCS_ONCE([nl_langinfo])
+  gl_CHECK_FUNCS_ANDROID([nl_langinfo], [[#include <langinfo.h>]])
   AC_REQUIRE([AC_CANONICAL_HOST])
   AC_REQUIRE([gl_FUNC_SETLOCALE_NULL])
   AC_REQUIRE([gl_PTHREADLIB])
diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4
index a56f80087d..358fc07bfd 100644
--- a/m4/strerror_r.m4
+++ b/m4/strerror_r.m4
@@ -1,4 +1,4 @@
-# strerror_r.m4 serial 24
+# strerror_r.m4 serial 25
 dnl Copyright (C) 2002, 2007-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -40,7 +40,7 @@ AC_DEFUN([gl_PREREQ_STRERROR_R], [
   AC_REQUIRE([AC_FUNC_STRERROR_R])
   dnl glibc >= 2.3.4 and cygwin 1.7.9 have a function __xpg_strerror_r.
   AC_CHECK_FUNCS_ONCE([__xpg_strerror_r])
-  AC_CHECK_FUNCS_ONCE([catgets])
+  gl_CHECK_FUNCS_ANDROID([catgets], [[#include <nl_types.h>]])
   AC_CHECK_FUNCS_ONCE([snprintf])
 ])
 
diff --git a/m4/strtod.m4 b/m4/strtod.m4
index 4440cbaa47..e4e0f06dfb 100644
--- a/m4/strtod.m4
+++ b/m4/strtod.m4
@@ -1,4 +1,4 @@
-# strtod.m4 serial 26
+# strtod.m4 serial 27
 dnl Copyright (C) 2002-2003, 2006-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -140,5 +140,5 @@ AC_DEFUN([gl_PREREQ_STRTOD], [
     AC_DEFINE([HAVE_LDEXP_IN_LIBC], [1],
       [Define if the ldexp function is available in libc.])
   fi
-  AC_CHECK_FUNCS([nl_langinfo])
+  gl_CHECK_FUNCS_ANDROID([nl_langinfo], [[#include <langinfo.h>]])
 ])
diff --git a/m4/strtold.m4 b/m4/strtold.m4
index 5556aa7413..08a722b199 100644
--- a/m4/strtold.m4
+++ b/m4/strtold.m4
@@ -1,4 +1,4 @@
-# strtold.m4 serial 7
+# strtold.m4 serial 8
 dnl Copyright (C) 2002-2003, 2006-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -145,5 +145,5 @@ AC_DEFUN([gl_PREREQ_STRTOLD], [
     AC_DEFINE([HAVE_LDEXPL_IN_LIBC], [1],
       [Define if the ldexpl function is available in libc.])
   fi
-  AC_CHECK_FUNCS([nl_langinfo])
+  gl_CHECK_FUNCS_ANDROID([nl_langinfo], [[#include <langinfo.h>]])
 ])
diff --git a/m4/utimens.m4 b/m4/utimens.m4
index ffd289e1c7..5f8606167a 100644
--- a/m4/utimens.m4
+++ b/m4/utimens.m4
@@ -3,7 +3,7 @@ dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
-dnl serial 14
+dnl serial 15
 
 AC_DEFUN([gl_UTIMENS],
 [
@@ -11,9 +11,9 @@ AC_DEFUN([gl_UTIMENS],
   AC_REQUIRE([gl_FUNC_UTIMES])
   AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  AC_CHECK_FUNCS_ONCE([lutimes])
   gl_CHECK_FUNCS_ANDROID([futimes], [[#include <sys/time.h>]])
   gl_CHECK_FUNCS_ANDROID([futimesat], [[#include <sys/time.h>]])
+  gl_CHECK_FUNCS_ANDROID([lutimes], [[#include <sys/time.h>]])
   gl_CHECK_FUNCS_ANDROID([futimens], [[#include <sys/stat.h>]])
   gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]])
 
diff --git a/m4/vasnprintf.m4 b/m4/vasnprintf.m4
index 6361c8436c..fda90c402b 100644
--- a/m4/vasnprintf.m4
+++ b/m4/vasnprintf.m4
@@ -1,4 +1,4 @@
-# vasnprintf.m4 serial 38
+# vasnprintf.m4 serial 39
 dnl Copyright (C) 2002-2004, 2006-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -152,7 +152,7 @@ AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
       AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
         [Define if the vasnprintf implementation needs special code for
          the 'a' and 'A' directives.])
-      AC_CHECK_FUNCS([nl_langinfo])
+      gl_CHECK_FUNCS_ANDROID([nl_langinfo], [[#include <langinfo.h>]])
       ;;
   esac
 ])
diff --git a/modules/duplocale-tests b/modules/duplocale-tests
index 0cb7af4703..77295bb38a 100644
--- a/modules/duplocale-tests
+++ b/modules/duplocale-tests
@@ -8,8 +8,9 @@ Depends-on:
 langinfo
 
 configure.ac:
-AC_CHECK_FUNCS_ONCE([strfmon_l snprintf_l nl_langinfo_l])
+AC_CHECK_FUNCS_ONCE([strfmon_l snprintf_l])
 gl_CHECK_FUNCS_ANDROID([duplocale], [[#include <locale.h>]])
+gl_CHECK_FUNCS_ANDROID([nl_langinfo_l], [[#include <langinfo.h>]])
 AC_CHECK_HEADERS_ONCE([monetary.h])
 gt_FUNC_USELOCALE
 
-- 
2.34.1


[-- Attachment #13: 0012-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 1531 bytes --]

From a1a659eee27760b047a8fb8b2f605290e1154a99 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:37 +0100
Subject: [PATCH 12/15] Fix warnings for functions introduced in Android API
 level 28.

* m4/glob.m4 (gl_GLOB): Test for glob using gl_CHECK_FUNCS_ANDROID
instead of AC_CHECK_FUNCS_ONCE.
---
 ChangeLog  | 6 ++++++
 m4/glob.m4 | 5 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a39cb4c603..081efd1494 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 28.
+	* m4/glob.m4 (gl_GLOB): Test for glob using gl_CHECK_FUNCS_ANDROID
+	instead of AC_CHECK_FUNCS_ONCE.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 26.
diff --git a/m4/glob.m4 b/m4/glob.m4
index 847f88038f..9365f3362d 100644
--- a/m4/glob.m4
+++ b/m4/glob.m4
@@ -1,4 +1,4 @@
-# glob.m4 serial 28
+# glob.m4 serial 29
 dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,7 +12,8 @@ AC_DEFUN([gl_GLOB],
 [
   AC_REQUIRE([gl_GLOB_H])
 
-  AC_CHECK_FUNCS_ONCE([glob glob_pattern_p])
+  AC_CHECK_FUNCS_ONCE([glob_pattern_p])
+  gl_CHECK_FUNCS_ANDROID([glob], [[#include <glob.h>]])
   if test $ac_cv_func_glob = no; then
     HAVE_GLOB=0
   else
-- 
2.34.1


[-- Attachment #14: 0013-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 2167 bytes --]

From de6c4c2e06f19df6789d94f52c26b7caa58cb711 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:39 +0100
Subject: [PATCH 13/15] Fix warnings for functions introduced in Android API
 level 29.

* m4/getloadavg.m4 (gl_GETLOADAVG): Test for getloadavg using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNC.
---
 ChangeLog        |  6 ++++++
 m4/getloadavg.m4 | 10 ++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 081efd1494..cae9026535 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 29.
+	* m4/getloadavg.m4 (gl_GETLOADAVG): Test for getloadavg using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNC.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 28.
diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4
index 79e420baae..067f142abc 100644
--- a/m4/getloadavg.m4
+++ b/m4/getloadavg.m4
@@ -7,7 +7,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-#serial 10
+#serial 11
 
 # Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent.
 # New applications should use gl_GETLOADAVG instead.
@@ -25,8 +25,9 @@ gl_save_LIBS=$LIBS
 # getloadavg is present in libc on glibc >= 2.2, Mac OS X, FreeBSD >= 2.0,
 # NetBSD >= 0.9, OpenBSD >= 2.0, Solaris >= 7.
 HAVE_GETLOADAVG=1
-AC_CHECK_FUNC([getloadavg], [],
-  [gl_func_getloadavg_done=no
+gl_CHECK_FUNCS_ANDROID([getloadavg], [[#include <stdlib.h>]])
+if test $ac_cv_func_getloadavg != yes; then
+   gl_func_getloadavg_done=no
 
    # Some systems with -lutil have (and need) -lkvm as well, some do not.
    # On Solaris, -lkvm requires nlist from -lelf, so check that first
@@ -73,7 +74,8 @@ AC_CHECK_FUNC([getloadavg], [],
           AC_DEFINE([DGUX], [1], [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
           AC_CHECK_LIB([dgc], [dg_sys_info])])
      fi
-   fi])
+   fi
+fi
 
 if test "x$gl_save_LIBS" = x; then
   GETLOADAVG_LIBS=$LIBS
-- 
2.34.1


[-- Attachment #15: 0014-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 1766 bytes --]

From aae82bb323fd030587d3e2a5a43f3239c96c8e1a Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:42 +0100
Subject: [PATCH 14/15] Fix warnings for functions introduced in Android API
 level 30.

* m4/threadlib.m4 (gl_STDTHREADLIB_BODY): Test for thrd_create using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
---
 ChangeLog       | 6 ++++++
 m4/threadlib.m4 | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cae9026535..b5181afca2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 30.
+	* m4/threadlib.m4 (gl_STDTHREADLIB_BODY): Test for thrd_create using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 29.
diff --git a/m4/threadlib.m4 b/m4/threadlib.m4
index 332491d42f..48ced460b3 100644
--- a/m4/threadlib.m4
+++ b/m4/threadlib.m4
@@ -1,4 +1,4 @@
-# threadlib.m4 serial 33
+# threadlib.m4 serial 34
 dnl Copyright (C) 2005-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -352,7 +352,7 @@ AC_DEFUN([gl_STDTHREADLIB_BODY],
           dnl on libpthread (for the symbol 'pthread_mutexattr_gettype').
           dnl glibc >= 2.34, AIX >= 7.1, and Solaris >= 11.4 have thrd_create in
           dnl libc.
-          AC_CHECK_FUNCS([thrd_create])
+          gl_CHECK_FUNCS_ANDROID([thrd_create], [[#include <threads.h>]])
           if test $ac_cv_func_thrd_create = yes; then
             LIBSTDTHREAD=
           else
-- 
2.34.1


[-- Attachment #16: 0015-Fix-warnings-for-functions-introduced-in-Android-API.patch --]
[-- Type: text/x-patch, Size: 1348 bytes --]

From 3d9249fe2ce5226792b218ae2a1154bbc2108c8f Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Thu, 19 Jan 2023 21:55:45 +0100
Subject: [PATCH 15/15] Fix warnings for functions introduced in Android API
 level 34.

* modules/execute-tests (configure.ac): Test for close_range using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
---
 ChangeLog             | 6 ++++++
 modules/execute-tests | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index b5181afca2..ddd9e2b1aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-19  Bruno Haible  <bruno@clisp.org>
+
+	Fix warnings for functions introduced in Android API level 34.
+	* modules/execute-tests (configure.ac): Test for close_range using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS.
+
 2023-01-19  Bruno Haible  <bruno@clisp.org>
 
 	Fix warnings for functions introduced in Android API level 30.
diff --git a/modules/execute-tests b/modules/execute-tests
index 14d48676c5..fc0816fd17 100644
--- a/modules/execute-tests
+++ b/modules/execute-tests
@@ -21,7 +21,7 @@ unistd
 
 configure.ac:
 dnl Test for Linux system call close_range(), declared in <unistd.h>.
-AC_CHECK_FUNCS([close_range])
+gl_CHECK_FUNCS_ANDROID([close_range], [[#include <unistd.h>]])
 
 Makefile.am:
 TESTS += test-execute.sh
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-19 21:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87zgag6la4.fsf.ref@yahoo.com>
2023-01-18 13:10 ` More Android patches Po Lu
2023-01-18 23:07   ` Bruno Haible
2023-01-19 21:02     ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).