bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: Resolve conflicts for functions introduced later in Android
Date: Sun, 22 Jan 2023 15:59:48 +0100	[thread overview]
Message-ID: <4608453.guUeLoCLYh@nimes> (raw)

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

This series of patches implements the REPLACE_* logic for symbols that do
not exist in the *minimum* Android version on which the compiled binaries
should run, but *do* exist in some later Android version (in which the
compiled binaries should also run).

The problem description is at
https://lists.gnu.org/archive/html/bug-gnulib/2023-01/msg00167.html


2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 29.

	* m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY): Conditionally set
	REPLACE_REALLOCARRAY.
	* lib/stdlib.in.h (reallocarray): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* lib/stdlib.in.h (getloadavg): Consider REPLACE_GETLOADAVG. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_GETLOADAVG.
	* modules/stdlib (Makefile.am): Substitute REPLACE_GETLOADAVG.
	* m4/getloadavg.m4 (gl_GETLOADAVG): Conditionally set
	REPLACE_GETLOADAVG.
	* modules/getloadavg (Depends-on, configure.ac): Consider
	REPLACE_GETLOADAVG.

	* lib/time.in.h (timespec_get): Consider REPLACE_TIMESPEC_GET. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	* m4/time_h.m4 (gl_TIME_H_DEFAULTS): Initialize REPLACE_TIMESPEC_GET.
	* modules/time (Makefile.am): Substitute REPLACE_TIMESPEC_GET.
	* m4/gettime.m4 (gl_CHECK_FUNC_TIMESPEC_GET): Set also
	gl_cv_onwards_func_timespec_get.
	* m4/timespec_get.m4 (gl_FUNC_TIMESPEC_GET): Conditionally set
	REPLACE_TIMESPEC_GET.
	* modules/timespec_get (Depends-on, configure.ac): Consider
	REPLACE_TIMESPEC_GET.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 28.

	* m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Conditionally set
	REPLACE_ALIGNED_ALLOC.
	* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Conditionally set
	REPLACE_GETRANDOM.

	* m4/getlogin_r.m4 (gl_FUNC_GETLOGIN_R): Conditionally set
	REPLACE_GETLOGIN_R.
	* lib/unistd.in.h (getlogin_r): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/spawn_h.m4 (gl_HAVE_POSIX_SPAWN): Conditionally set
	REPLACE_POSIX_SPAWN.
	* lib/spawn.in.h: Adapt logic for defining the POSIX_SPAWN_* constants.
	(posix_spawn, posix_spawnp, posix_spawnattr_init,
	posix_spawnattr_destroy, posix_spawnattr_getsigdefault,
	posix_spawnattr_setsigdefault, posix_spawnattr_getsigmask,
	posix_spawnattr_setsigmask, posix_spawnattr_getflags,
	posix_spawnattr_setflags, posix_spawnattr_getpgroup,
	posix_spawnattr_setpgroup, posix_spawn_file_actions_init,
	posix_spawn_file_actions_destroy, posix_spawn_file_actions_addchdir,
	posix_spawn_file_actions_addfchdir): Disable _GL_CXXALIASWARN invocation
	on non-glibc systems.

	* m4/glob.m4 (gl_GLOB): Conditionally set REPLACE_GLOB.
	* lib/glob.in.h (glob): Disable _GL_CXXALIASWARN invocation on non-glibc
	systems.

	* lib/unistd.in.h (getentropy): Consider REPLACE_GETENTROPY. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_GETENTROPY.
	* modules/unistd (Makefile.am): Substitute REPLACE_GETENTROPY.
	* m4/getentropy.m4 (gl_FUNC_GETENTROPY): Conditionally set
	REPLACE_GETENTROPY.
	* modules/getentropy (Depends-on, configure.ac): Consider
	REPLACE_GETENTROPY.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 26.

	* m4/getdomainname.m4 (gl_FUNC_GETDOMAINNAME): Test for getdomainname
	using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS. Conditionally
	set REPLACE_GETSUBOPT.

	* m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Conditionally set
	REPLACE_NL_LANGINFO.
	* lib/langinfo.in.h (nl_langinfo): Disable _GL_CXXALIASWARN invocation
	on non-glibc systems.

	* lib/stdlib.in.h (getsubopt): Consider REPLACE_GETSUBOPT. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_GETSUBOPT.
	* modules/stdlib (Makefile.am): Substitute REPLACE_GETSUBOPT.
	* m4/getsubopt.m4 (gl_FUNC_GETSUBOPT): Conditionally set
	REPLACE_GETSUBOPT.
	* modules/getsubopt (Depends-on, configure.ac): Consider
	REPLACE_GETSUBOPT.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 24.
	* m4/strchrnul.m4 (gl_FUNC_STRCHRNUL): Conditionally set
	REPLACE_STRCHRNUL.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 23.

	* m4/login_tty.m4 (gl_FUNC_LOGIN_TTY): Conditionally set
	REPLACE_LOGIN_TTY.
	* lib/utmp.in.h (login_tty): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Conditionally set REPLACE_MKFIFOAT.
	* lib/sys_stat.in.h (mkfifoat): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS): Conditionally set
	REPLACE_STRERROR_R.
	* lib/string.in.h (strerror_r): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/error_h.m4 (gl_ERROR_H): Conditionally set REPLACE_ERROR.
	* lib/error.in.h (error): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* lib/wchar.in.h (wmempcpy): Consider REPLACE_WMEMPCPY.
	* m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WMEMPCPY.
	* modules/wchar (Makefile.am): Substitute REPLACE_WMEMPCPY.
	* m4/wmempcpy.m4 (gl_FUNC_WMEMPCPY): Conditionally set
	REPLACE_WMEMPCPY.
	* modules/wmempcpy (configure.ac): Consider REPLACE_WMEMPCPY.

	* lib/unistd.in.h (sethostname): Consider REPLACE_SETHOSTNAME. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_SETHOSTNAME.
	* modules/unistd (Makefile.am): Substitute REPLACE_SETHOSTNAME.
	* m4/sethostname.m4 (gl_FUNC_SETHOSTNAME): Conditionally set
	REPLACE_SETHOSTNAME.
	* modules/sethostname (Depends-on, configure.ac): Consider
	REPLACE_SETHOSTNAME.

	* lib/string.in.h (mempcpy): Consider REPLACE_MEMPCPY. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_MEMPCPY.
	* modules/string (Makefile.am): Substitute REPLACE_MEMPCPY.
	* m4/mempcpy.m4 (gl_FUNC_MEMPCPY): Conditionally set REPLACE_MEMPCPY.
	* modules/mempcpy (configure.ac): Consider REPLACE_MEMPCPY.

	* lib/stdlib.in.h (mkostemp): Consider REPLACE_MKOSTEMP. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	(mkostemps): Consider REPLACE_MKOSTEMPS. Disable _GL_CXXALIASWARN
	invocation on non-glibc systems.
	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_MKOSTEMP,
	REPLACE_MKOSTEMPS.
	* modules/stdlib (Makefile.am): Substitute REPLACE_MKOSTEMP,
	REPLACE_MKOSTEMPS.
	* m4/mkostemp.m4 (gl_FUNC_MKOSTEMP): Conditionally set REPLACE_MKOSTEMP.
	* modules/mkostemp (Depends-on, configure.ac): Consider
	REPLACE_MKOSTEMP.
	* m4/mkostemps.m4 (gl_FUNC_MKOSTEMPS): Conditionally set
	REPLACE_MKOSTEMPS.
	* modules/mkostemps (Depends-on, configure.ac): Consider
	REPLACE_MKOSTEMPS.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 21.

	* m4/fts.m4 (gl_FUNC_FTS_CORE): Use rpl_* symbols also when the system
	will have fts_open in a future version.
	* m4/iswblank.m4 (gl_FUNC_ISWBLANK): Conditionally set REPLACE_ISWBLANK.
	* m4/mbtowc.m4 (gl_FUNC_MBTOWC): Conditionally set REPLACE_MBTOWC.
	* m4/vdprintf.m4 (gl_REPLACE_VDPRINTF): Conditionally set
	REPLACE_VDPRINTF.
	* m4/wcsnrtombs.m4 (gl_FUNC_WCSNRTOMBS): Conditionally set
	REPLACE_WCSNRTOMBS.

	* m4/mbsnrtowcs.m4 (gl_FUNC_MBSNRTOWCS): Conditionally set
	REPLACE_MBSNRTOWCS.
	* lib/wchar.in.h (mbsnrtowcs): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/execvpe.m4 (gl_FUNC_EXECVPE): Conditionally set REPLACE_EXECVPE.
	* m4/linkat.m4 (gl_FUNC_LINKAT): Conditionally set REPLACE_LINKAT.
	* m4/readlinkat.m4 (gl_FUNC_READLINKAT): Conditionally set
	REPLACE_READLINKAT.
	* m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Conditionally set
	REPLACE_SYMLINKAT.
	* m4/truncate.m4 (gl_FUNC_TRUNCATE): Conditionally set REPLACE_TRUNCATE.
	* lib/unistd.in.h (execvpe, linkat, readlinkat, symlinkat, truncate):
	Disable _GL_CXXALIASWARN invocation on non-glibc systems.

	* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Conditionally set REPLACE_MKNODAT.
	* lib/sys_stat.in.h (mknodat): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/stpncpy.m4 (gl_FUNC_STPNCPY): Conditionally set REPLACE_STPNCPY.
	* lib/string.in.h (stpncpy): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/random.m4 (gl_FUNC_RANDOM): Conditionally set REPLACE_INITSTATE,
	REPLACE_SETSTATE.
	* lib/stdlib.in.h (initstate, setstate): Disable _GL_CXXALIASWARN
	invocation on non-glibc systems.

	* m4/dprintf.m4 (gl_REPLACE_DPRINTF): Conditionally set REPLACE_DPRINTF.
	* lib/stdio.in.h (dprintf): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Conditionally set
	REPLACE_DUPLOCALE.
	* m4/localename.m4 (gl_LOCALENAME): Conditionally set REPLACE_NEWLOCALE,
	REPLACE_DUPLOCALE, REPLACE_FREELOCALE.
	* lib/locale.in.h (newlocale, duplocale, freelocale): Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.

	* lib/unistd.in.h (dup3): Consider REPLACE_DUP3. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_DUP3.
	* modules/unistd (Makefile.am): Substitute REPLACE_DUP3.
	* m4/dup3.m4 (gl_FUNC_DUP3): Conditionally set REPLACE_DUP3.

	* lib/string.in.h (stpcpy): Consider REPLACE_STPCPY. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_STPCPY.
	* modules/string (Makefile.am): Substitute REPLACE_STPCPY.
	* m4/stpcpy.m4 (gl_FUNC_STPCPY): Conditionally set REPLACE_STPCPY.
	* modules/stpcpy (configure.ac): Consider REPLACE_STPCPY.

	* lib/stdlib.in.h (_Exit): Consider REPLACE__EXIT. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	(getprogname): Consider REPLACE_GETPROGNAME. Disable _GL_CXXALIASWARN
	invocation on non-glibc systems.
	(posix_openpt): Consider REPLACE_POSIX_OPENPT. Disable _GL_CXXALIASWARN
	invocation on non-glibc systems.
	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE__EXIT,
	REPLACE_GETPROGNAME, REPLACE_POSIX_OPENPT.
	* modules/stdlib (Makefile.am): Substitute REPLACE__EXIT,
	REPLACE_GETPROGNAME, REPLACE_POSIX_OPENPT.
	* m4/_Exit.m4 (gl_FUNC__EXIT): Conditionally set REPLACE__EXIT.
	* modules/_Exit (configure.ac): Consider REPLACE__EXIT.
	* m4/getprogname.m4 (gl_FUNC_GETPROGNAME): Conditionally set
	REPLACE_GETPROGNAME.
	* modules/getprogname (configure.ac): Consider REPLACE_GETPROGNAME.
	* m4/posix_openpt.m4 (gl_FUNC_POSIX_OPENPT): Conditionally set
	REPLACE_POSIX_OPENPT.
	* modules/posix_openpt (configure.ac): Consider REPLACE_POSIX_OPENPT.

	* lib/search.in.h (twalk): Consider REPLACE_TWALK.
	* m4/search_h.m4 (gl_SEARCH_H_DEFAULTS): Initialize REPLACE_TWALK.
	* modules/search (Makefile.am): Substitute REPLACE_TWALK.
	* m4/tsearch.m4 (gl_FUNC_TSEARCH): Conditionally set REPLACE_TWALK.
	* modules/tsearch (configure.ac): Consider REPLACE_TWALK.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 19.

	* lib/inttypes.in.h (imaxabs): Consider REPLACE_IMAXABS. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	(imaxdiv): Consider REPLACE_IMAXDIV. Disable _GL_CXXALIASWARN invocation
	on non-glibc systems.
	* m4/inttypes.m4 (gl_INTTYPES_H_DEFAULTS): Initialize HAVE_IMAXABS,
	HAVE_IMAXDIV, REPLACE_IMAXABS, REPLACE_IMAXDIV.
	* modules/inttypes-incomplete (Makefile.am): Substitute REPLACE_IMAXABS,
	REPLACE_IMAXDIV.
	* m4/imaxabs.m4 (gl_FUNC_IMAXABS): Conditionally set HAVE_IMAXABS,
	REPLACE_IMAXABS.
	* modules/imaxabs (configure.ac): Consider HAVE_IMAXABS, REPLACE_IMAXABS.
	* m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Conditionally set HAVE_IMAXDIV,
	REPLACE_IMAXDIV.
	* modules/imaxdiv (configure.ac): Consider HAVE_IMAXDIV, REPLACE_IMAXDIV.

	* m4/futimens.m4 (gl_FUNC_FUTIMENS): Conditionally set REPLACE_FUTIMENS.
	* lib/sys_stat.in.h (futimens): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 18.

	* m4/log2.m4 (gl_FUNC_LOG2): Conditionally set REPLACE_LOG2.
	* m4/log2f.m4 (gl_FUNC_LOG2F): Conditionally set REPLACE_LOG2F.
	* m4/log2l.m4 (gl_FUNC_LOG2L): Conditionally set REPLACE_LOG2L.
	* lib/math.in.h (log2f): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/getdelim.m4 (gl_FUNC_GETDELIM): Conditionally set REPLACE_GETDELIM.
	* m4/getline.m4 (gl_FUNC_GETLINE): Conditionally set REPLACE_GETLINE.
	* lib/stdio.in.h (getdelim, getline): Disable _GL_CXXALIASWARN
	invocation on non-glibc systems.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 16-17.
	* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN): Conditionally set
	REPLACE_POSIX_MEMALIGN.
	* lib/stdlib.in.h (posix_memalign): Disable _GL_CXXALIASWARN invocation
	on non-glibc systems.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 16.

	* m4/tsearch.m4 (gl_FUNC_TSEARCH): Conditionally set REPLACE_TSEARCH.
	* lib/search.in.h (tsearch, tfind, tdelete, twalk): Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.

	* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Conditionally set
	REPLACE_FACCESSAT.
	* lib/unistd.in.h (faccessat): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 12.

	* m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Conditionally set
	REPLACE_UTIMENSAT.
	* lib/sys_stat.in.h (utimensat): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/timegm.m4 (gl_FUNC_TIMEGM): Conditionally set REPLACE_TIMEGM.
	* lib/time.in.h (timegm): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/pwrite.m4 (gl_FUNC_PWRITE): Conditionally set REPLACE_PWRITE.
	* lib/unistd.in.h (pwrite): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/pread.m4 (gl_FUNC_PREAD): Conditionally set REPLACE_PREAD.
	* lib/unistd.in.h (pread): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

	* m4/ftruncate.m4 (gl_FUNC_FTRUNCATE): Conditionally set
	REPLACE_FTRUNCATE.
	* lib/unistd.in.h (ftruncate): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 9.
	* lib/unistd.in.h (fdatasync): Consider REPLACE_FDATASYNC. Disable
	_GL_CXXALIASWARN invocation on non-glibc systems.
	(pipe2): Consider REPLACE_PIPE2. Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.
	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_FDATASYNC,
	REPLACE_PIPE2.
	* modules/unistd (Makefile.am): Substitute REPLACE_FDATASYNC,
	REPLACE_PIPE2.
	* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Test for fdatasync using
	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS. Conditionally set
	REPLACE_FDATASYNC.
	* modules/fdatasync (Depends-on, configure.ac): Consider
	REPLACE_FDATASYNC.
	* m4/pipe2.m4 (gl_FUNC_PIPE2): Conditionally set REPLACE_PIPE2.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 8.
	* m4/ttyname_r.m4 (gl_FUNC_TTYNAME_R): Conditionally set
	REPLACE_TTYNAME_R.
	* lib/unistd.in.h (ttyname_r): Disable _GL_CXXALIASWARN invocation on
	non-glibc systems.

2023-01-22  Bruno Haible  <bruno@clisp.org>

	Prepare for resolving conflicts regarding future Android API levels.
	* m4/gnulib-common.m4 (gl_CHECK_FUNCS_ANDROID): Don't check for the
	function declaration on platforms other than Android. Set a variable
	gl_cv_onwards_func_<func>.


[-- Attachment #2: 0001-Prepare-for-resolving-conflicts-regarding-future-And.patch --]
[-- Type: text/x-patch, Size: 5192 bytes --]

From c7b0223f384120198f06a685aa34b8116173ee52 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 01:19:13 +0100
Subject: [PATCH 01/47] Prepare for resolving conflicts regarding future
 Android API levels.

* m4/gnulib-common.m4 (gl_CHECK_FUNCS_ANDROID): Don't check for the
function declaration on platforms other than Android. Set a variable
gl_cv_onwards_func_<func>.
---
 ChangeLog           |  7 +++++
 m4/gnulib-common.m4 | 73 ++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 61107c67fa..83b5e5dd58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Prepare for resolving conflicts regarding future Android API levels.
+	* m4/gnulib-common.m4 (gl_CHECK_FUNCS_ANDROID): Don't check for the
+	function declaration on platforms other than Android. Set a variable
+	gl_cv_onwards_func_<func>.
+
 2023-01-22  Paul Eggert  <eggert@cs.ucla.edu>
 
 	sigsegv, vma-iter: port to Solaris 10
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index fa814222ce..d5b2f7c4e5 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 76
+# gnulib-common.m4 serial 77
 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,
@@ -1031,8 +1031,21 @@ AC_DEFUN([gl_CONDITIONAL_HEADER],
 dnl gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]])
 dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem
 dnl on Android.
-dnl Namely, if func was added to Android API level, say, 28, then the libc.so
-dnl has the symbol func always, whereas the header file <foo.h> declares func
+dnl
+dnl When code is compiled on Android, it is in the context of a certain
+dnl "Android API level", which indicates the minimum version of Android on
+dnl which the app can be installed. In other words, you don't compile for a
+dnl specific version of Android. You compile for all versions of Android,
+dnl onwards from the given API level.
+dnl Thus, the question "does the OS have the function func" has three possible
+dnl answers:
+dnl   - yes, in all versions starting from the given API level,
+dnl   - no, in no version,
+dnl   - not in the given API level, but in a later version of Android.
+dnl
+dnl In detail, this works as follows:
+dnl If func was added to Android API level, say, 28, then the libc.so has the
+dnl symbol func always, whereas the header file <foo.h> declares func
 dnl conditionally:
 dnl   #if __ANDROID_API__ >= 28
 dnl   ... func (...) __INTRODUCED_IN(28);
@@ -1040,15 +1053,55 @@ dnl   #endif
 dnl Thus, when compiling with "clang -target armv7a-unknown-linux-android28",
 dnl the function func is declared and exists in libc.
 dnl Whereas when compiling with "clang -target armv7a-unknown-linux-android27",
-dnl the function func is not declared but exists in libc. We need to treat this
-dnl case like the case where func does not exist.
+dnl the function func is not declared but exists in libc.
+dnl
+dnl This macro sets two variables:
+dnl   - gl_cv_onwards_func_<func>   to yes / no / "future OS version"
+dnl   - ac_cv_func_<func>           to yes / no / no
+dnl The first variable allows to distinguish all three cases.
+dnl The second variable is set, so that an invocation
+dnl   gl_CHECK_FUNCS_ANDROID([func], [[#include <foo.h>]])
+dnl can be used as a drop-in replacement for
+dnl   AC_CHECK_FUNCS([func]).
 AC_DEFUN([gl_CHECK_FUNCS_ANDROID],
 [
-  AC_CHECK_DECL([$1], , , [$2])
-  if test $ac_cv_have_decl_[$1] = yes; then
-    AC_CHECK_FUNCS([$1])
-  else
-    ac_cv_func_[$1]=no
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  AC_CACHE_CHECK([for [$1]],
+    [[gl_cv_onwards_func_][$1]],
+    [gl_SILENT([
+       case "$host_os" in
+         linux*-android*)
+           AC_CHECK_DECL([$1], , , [$2])
+           if test $[ac_cv_have_decl_][$1] = yes; then
+             AC_CHECK_FUNC([[$1]])
+             if test $[ac_cv_func_][$1] = yes; then
+               [gl_cv_onwards_func_][$1]=yes
+             else
+               dnl The function is declared but does not exist. This should not
+               dnl happen normally. But anyway, we know that a future version
+               dnl of Android will have the function.
+               [gl_cv_onwards_func_][$1]='future OS version'
+             fi
+           else
+             [gl_cv_onwards_func_][$1]='future OS version'
+           fi
+           ;;
+         *)
+           AC_CHECK_FUNC([$1])
+           [gl_cv_onwards_func_][$1]=$[ac_cv_func_][$1]
+           ;;
+       esac
+      ])
+    ])
+  case "$[gl_cv_onwards_func_][$1]" in
+    future*) [ac_cv_func_][$1]=no ;;
+    *)       [ac_cv_func_][$1]=$[gl_cv_onwards_func_][$1] ;;
+  esac
+  if test $[ac_cv_func_][$1] = yes; then
+    AC_DEFINE([HAVE_]m4_translit([[$1]],
+                                 [abcdefghijklmnopqrstuvwxyz],
+                                 [ABCDEFGHIJKLMNOPQRSTUVWXYZ]),
+              [1], [Define to 1 if you have the `$1' function.])
   fi
 ])
 
-- 
2.34.1


[-- Attachment #3: 0002-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2263 bytes --]

From f4b72fccdb381da20f75fda804b37ecb954c8a42 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 01:19:44 +0100
Subject: [PATCH 02/47] Resolve conflicts for functions introduced in Android
 API level 8.

* m4/ttyname_r.m4 (gl_FUNC_TTYNAME_R): Conditionally set
REPLACE_TTYNAME_R.
* lib/unistd.in.h (ttyname_r): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog       | 8 ++++++++
 lib/unistd.in.h | 2 ++
 m4/ttyname_r.m4 | 5 ++++-
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 83b5e5dd58..a491d5ab6f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 8.
+	* m4/ttyname_r.m4 (gl_FUNC_TTYNAME_R): Conditionally set
+	REPLACE_TTYNAME_R.
+	* lib/unistd.in.h (ttyname_r): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Prepare for resolving conflicts regarding future Android API levels.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 4812fdb112..f6d7c8d0a9 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -2173,7 +2173,9 @@ _GL_FUNCDECL_SYS (ttyname_r, int,
 _GL_CXXALIAS_SYS (ttyname_r, int,
                   (int fd, char *buf, size_t buflen));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (ttyname_r);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef ttyname_r
 # if HAVE_RAW_DECL_TTYNAME_R
diff --git a/m4/ttyname_r.m4 b/m4/ttyname_r.m4
index 4a76155469..60aa357c25 100644
--- a/m4/ttyname_r.m4
+++ b/m4/ttyname_r.m4
@@ -1,4 +1,4 @@
-# ttyname_r.m4 serial 12
+# ttyname_r.m4 serial 13
 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,
@@ -20,6 +20,9 @@ AC_DEFUN([gl_FUNC_TTYNAME_R],
   gl_CHECK_FUNCS_ANDROID([ttyname_r], [[#include <unistd.h>]])
   if test $ac_cv_func_ttyname_r = no; then
     HAVE_TTYNAME_R=0
+    case "$gl_cv_onwards_func_ttyname_r" in
+      future*) REPLACE_TTYNAME_R=1 ;;
+    esac
   else
     HAVE_TTYNAME_R=1
     dnl On Mac OS X 10.4 (and Solaris 10 without gl_USE_SYSTEM_EXTENSIONS)
-- 
2.34.1


[-- Attachment #4: 0003-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 9483 bytes --]

From e074cd27a59f9e0ea13088d7889620107510e993 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 01:23:47 +0100
Subject: [PATCH 03/47] Resolve conflicts for functions introduced in Android
 API level 9.

* lib/unistd.in.h (fdatasync): Consider REPLACE_FDATASYNC. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
(pipe2): Consider REPLACE_PIPE2. Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_FDATASYNC,
REPLACE_PIPE2.
* modules/unistd (Makefile.am): Substitute REPLACE_FDATASYNC,
REPLACE_PIPE2.
* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Test for fdatasync using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS. Conditionally set
REPLACE_FDATASYNC.
* modules/fdatasync (Depends-on, configure.ac): Consider
REPLACE_FDATASYNC.
* m4/pipe2.m4 (gl_FUNC_PIPE2): Conditionally set REPLACE_PIPE2.
---
 ChangeLog         | 18 ++++++++++++++++++
 lib/unistd.in.h   | 20 +++++++++++++++++---
 m4/fdatasync.m4   | 17 ++++++++++++-----
 m4/pipe2.m4       |  7 ++++++-
 m4/unistd_h.m4    |  4 +++-
 modules/fdatasync |  4 ++--
 modules/unistd    |  2 ++
 7 files changed, 60 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a491d5ab6f..0859e1fd87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 9.
+	* lib/unistd.in.h (fdatasync): Consider REPLACE_FDATASYNC. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	(pipe2): Consider REPLACE_PIPE2. Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_FDATASYNC,
+	REPLACE_PIPE2.
+	* modules/unistd (Makefile.am): Substitute REPLACE_FDATASYNC,
+	REPLACE_PIPE2.
+	* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Test for fdatasync using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS. Conditionally set
+	REPLACE_FDATASYNC.
+	* modules/fdatasync (Depends-on, configure.ac): Consider
+	REPLACE_FDATASYNC.
+	* m4/pipe2.m4 (gl_FUNC_PIPE2): Conditionally set REPLACE_PIPE2.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 8.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index f6d7c8d0a9..9b330286e0 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1002,11 +1002,22 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
    Return 0 if successful, otherwise -1 and errno set.
    See POSIX:2008 specification
    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>.  */
-# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
+# if @REPLACE_FDATASYNC@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fdatasync
+#   define fdatasync rpl_fdatasync
+#  endif
+_GL_FUNCDECL_RPL (fdatasync, int, (int fd));
+_GL_CXXALIAS_RPL (fdatasync, int, (int fd));
+# else
+#  if !@HAVE_FDATASYNC@|| !@HAVE_DECL_FDATASYNC@
 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (fdatasync);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef fdatasync
 # if HAVE_RAW_DECL_FDATASYNC
@@ -1742,8 +1753,9 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "
    Return 0 upon success, or -1 with errno set upon failure.
    See also the Linux man page at
    <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
-# if @HAVE_PIPE2@
+# if @REPLACE_PIPE2@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef pipe2
 #   define pipe2 rpl_pipe2
 #  endif
 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
@@ -1752,7 +1764,9 @@ _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (pipe2);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef pipe2
 # if HAVE_RAW_DECL_PIPE2
diff --git a/m4/fdatasync.m4 b/m4/fdatasync.m4
index 201d7ffb27..17cf64cc1d 100644
--- a/m4/fdatasync.m4
+++ b/m4/fdatasync.m4
@@ -1,4 +1,4 @@
-# fdatasync.m4 serial 8
+# fdatasync.m4 serial 9
 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,10 +17,13 @@ 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])
+    dnl Likewise Android with API level < 9.
+    gl_CHECK_FUNCS_ANDROID([fdatasync], [[#include <unistd.h>]])
     if test $ac_cv_func_fdatasync = no; then
       HAVE_FDATASYNC=0
+      case "$gl_cv_onwards_func_fdatasync" in
+        future*) REPLACE_FDATASYNC=1 ;;
+      esac
     fi
   else
     case "$host_os" in
@@ -35,10 +38,14 @@ AC_DEFUN([gl_FUNC_FDATASYNC],
         LIBS=$gl_saved_libs
         ;;
       *)
-        dnl Android 4.3 does not have fdatasync but declares it.
-        AC_CHECK_FUNCS([fdatasync])
+        dnl Android 4.3 does not have fdatasync but declares it, and future
+        dnl Android versions have it.
+        gl_CHECK_FUNCS_ANDROID([fdatasync], [[#include <unistd.h>]])
         if test $ac_cv_func_fdatasync = no; then
           HAVE_FDATASYNC=0
+          case "$gl_cv_onwards_func_fdatasync" in
+            future*) REPLACE_FDATASYNC=1 ;;
+          esac
         fi
         ;;
     esac
diff --git a/m4/pipe2.m4 b/m4/pipe2.m4
index c7ec02e873..79de69cd1a 100644
--- a/m4/pipe2.m4
+++ b/m4/pipe2.m4
@@ -1,4 +1,4 @@
-# pipe2.m4 serial 3
+# pipe2.m4 serial 4
 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,
@@ -14,5 +14,10 @@ AC_DEFUN([gl_FUNC_PIPE2],
   gl_CHECK_FUNCS_ANDROID([pipe2], [[#include <unistd.h>]])
   if test $ac_cv_func_pipe2 != yes; then
     HAVE_PIPE2=0
+    case "$gl_cv_onwards_func_pipe2" in
+      future*) REPLACE_PIPE2=1 ;;
+    esac
+  else
+    REPLACE_PIPE2=1
   fi
 ])
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index f4384027e3..c7ef46c26d 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 90
+# unistd_h.m4 serial 91
 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,
@@ -234,6 +234,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_EXECVPE=0;                 AC_SUBST([REPLACE_EXECVPE])
   REPLACE_FACCESSAT=0;               AC_SUBST([REPLACE_FACCESSAT])
   REPLACE_FCHOWNAT=0;                AC_SUBST([REPLACE_FCHOWNAT])
+  REPLACE_FDATASYNC=0;               AC_SUBST([REPLACE_FDATASYNC])
   REPLACE_FTRUNCATE=0;               AC_SUBST([REPLACE_FTRUNCATE])
   REPLACE_GETCWD=0;                  AC_SUBST([REPLACE_GETCWD])
   REPLACE_GETDOMAINNAME=0;           AC_SUBST([REPLACE_GETDOMAINNAME])
@@ -248,6 +249,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_LINK=0;                    AC_SUBST([REPLACE_LINK])
   REPLACE_LINKAT=0;                  AC_SUBST([REPLACE_LINKAT])
   REPLACE_LSEEK=0;                   AC_SUBST([REPLACE_LSEEK])
+  REPLACE_PIPE2=0;                   AC_SUBST([REPLACE_PIPE2])
   REPLACE_PREAD=0;                   AC_SUBST([REPLACE_PREAD])
   REPLACE_PWRITE=0;                  AC_SUBST([REPLACE_PWRITE])
   REPLACE_READ=0;                    AC_SUBST([REPLACE_READ])
diff --git a/modules/fdatasync b/modules/fdatasync
index 6e0f48df21..4d13a97cdb 100644
--- a/modules/fdatasync
+++ b/modules/fdatasync
@@ -6,12 +6,12 @@ lib/fdatasync.c
 m4/fdatasync.m4
 
 Depends-on:
-fsync         [test $HAVE_FDATASYNC = 0]
+fsync         [test $HAVE_FDATASYNC = 0 || test $REPLACE_FDATASYNC = 1]
 unistd
 
 configure.ac:
 gl_FUNC_FDATASYNC
-gl_CONDITIONAL([GL_COND_OBJ_FDATASYNC], [test $HAVE_FDATASYNC = 0])
+gl_CONDITIONAL([GL_COND_OBJ_FDATASYNC], [test $HAVE_FDATASYNC = 0 || test $REPLACE_FDATASYNC = 1])
 gl_UNISTD_MODULE_INDICATOR([fdatasync])
 
 Makefile.am:
diff --git a/modules/unistd b/modules/unistd
index 01da57e23a..80080ede9e 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -188,6 +188,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''REPLACE_EXECVPE''@|$(REPLACE_EXECVPE)|g' \
 	      -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \
 	      -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
+	      -e 's|@''REPLACE_FDATASYNC''@|$(REPLACE_FDATASYNC)|g' \
 	      -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
 	      -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
 	      -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
@@ -202,6 +203,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
 	      -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
 	      -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
+	      -e 's|@''REPLACE_PIPE2''@|$(REPLACE_PIPE2)|g' \
 	      -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
 	      -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
 	      -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \
-- 
2.34.1


[-- Attachment #5: 0004-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 1951 bytes --]

From 3d30085be2768a3de78c5f90fe5160b0d623a771 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 01:34:16 +0100
Subject: [PATCH 04/47] Resolve conflicts for functions introduced in Android
 API level 12.

* m4/ftruncate.m4 (gl_FUNC_FTRUNCATE): Conditionally set
REPLACE_FTRUNCATE.
* lib/unistd.in.h (ftruncate): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog       | 9 +++++++++
 lib/unistd.in.h | 2 ++
 m4/ftruncate.m4 | 5 ++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 0859e1fd87..badff3bc76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 12.
+
+	* m4/ftruncate.m4 (gl_FUNC_FTRUNCATE): Conditionally set
+	REPLACE_FTRUNCATE.
+	* lib/unistd.in.h (ftruncate): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 9.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 9b330286e0..349a0c3f80 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1064,7 +1064,9 @@ _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
 #  endif
 _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (ftruncate);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef ftruncate
 # if HAVE_RAW_DECL_FTRUNCATE
diff --git a/m4/ftruncate.m4 b/m4/ftruncate.m4
index f48126e856..cbb5f423de 100644
--- a/m4/ftruncate.m4
+++ b/m4/ftruncate.m4
@@ -1,4 +1,4 @@
-# serial 22
+# serial 23
 
 # See if we need to emulate a missing ftruncate function using _chsize.
 
@@ -30,6 +30,9 @@ AC_DEFUN([gl_FUNC_FTRUNCATE],
     ])
   else
     HAVE_FTRUNCATE=0
+    case "$gl_cv_onwards_func_ftruncate" in
+      future*) REPLACE_FTRUNCATE=1 ;;
+    esac
   fi
 ])
 
-- 
2.34.1


[-- Attachment #6: 0006-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2018 bytes --]

From dd38adc80bd083fcfc2f99df6ffc1b341139442f Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 01:38:16 +0100
Subject: [PATCH 06/47] Resolve conflicts for functions introduced in Android
 API level 12.

* m4/pwrite.m4 (gl_FUNC_PWRITE): Conditionally set REPLACE_PWRITE.
* lib/unistd.in.h (pwrite): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog       | 4 ++++
 lib/unistd.in.h | 2 ++
 m4/pwrite.m4    | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 0ff8954a34..a9a774a37d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 12.
 
+	* m4/pwrite.m4 (gl_FUNC_PWRITE): Conditionally set REPLACE_PWRITE.
+	* lib/unistd.in.h (pwrite): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/pread.m4 (gl_FUNC_PREAD): Conditionally set REPLACE_PREAD.
 	* lib/unistd.in.h (pread): Disable _GL_CXXALIASWARN invocation on
 	non-glibc systems.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index d625b81cad..bc69194fac 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1840,7 +1840,9 @@ _GL_FUNCDECL_SYS (pwrite, ssize_t,
 _GL_CXXALIAS_SYS (pwrite, ssize_t,
                   (int fd, const void *buf, size_t bufsize, off_t offset));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (pwrite);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef pwrite
 # if HAVE_RAW_DECL_PWRITE
diff --git a/m4/pwrite.m4 b/m4/pwrite.m4
index 48c5255f30..51051c1bc4 100644
--- a/m4/pwrite.m4
+++ b/m4/pwrite.m4
@@ -1,4 +1,4 @@
-# pwrite.m4 serial 7
+# pwrite.m4 serial 8
 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,
@@ -95,5 +95,8 @@ changequote([,])dnl
     esac
   else
     HAVE_PWRITE=0
+    case "$gl_cv_onwards_func_pwrite" in
+      future*) REPLACE_PWRITE=1 ;;
+    esac
   fi
 ])
-- 
2.34.1


[-- Attachment #7: 0005-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 1987 bytes --]

From 73fc9518b91b0631591229484fdf65285e412ae0 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 01:36:31 +0100
Subject: [PATCH 05/47] Resolve conflicts for functions introduced in Android
 API level 12.

* m4/pread.m4 (gl_FUNC_PREAD): Conditionally set REPLACE_PREAD.
* lib/unistd.in.h (pread): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog       | 4 ++++
 lib/unistd.in.h | 2 ++
 m4/pread.m4     | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index badff3bc76..0ff8954a34 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 12.
 
+	* m4/pread.m4 (gl_FUNC_PREAD): Conditionally set REPLACE_PREAD.
+	* lib/unistd.in.h (pread): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/ftruncate.m4 (gl_FUNC_FTRUNCATE): Conditionally set
 	REPLACE_FTRUNCATE.
 	* lib/unistd.in.h (ftruncate): Disable _GL_CXXALIASWARN invocation on
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 349a0c3f80..d625b81cad 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1803,7 +1803,9 @@ _GL_FUNCDECL_SYS (pread, ssize_t,
 _GL_CXXALIAS_SYS (pread, ssize_t,
                   (int fd, void *buf, size_t bufsize, off_t offset));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (pread);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef pread
 # if HAVE_RAW_DECL_PREAD
diff --git a/m4/pread.m4 b/m4/pread.m4
index 8031f910d4..2c60e7c70f 100644
--- a/m4/pread.m4
+++ b/m4/pread.m4
@@ -1,4 +1,4 @@
-# pread.m4 serial 7
+# pread.m4 serial 8
 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,
@@ -81,5 +81,8 @@ changequote([,])dnl
     esac
   else
     HAVE_PREAD=0
+    case "$gl_cv_onwards_func_pread" in
+      future*) REPLACE_PREAD=1 ;;
+    esac
   fi
 ])
-- 
2.34.1


[-- Attachment #8: 0007-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2025 bytes --]

From ca227be2d8649a2a55a4953a97db4f992895440b Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 01:41:06 +0100
Subject: [PATCH 07/47] Resolve conflicts for functions introduced in Android
 API level 12.

* m4/timegm.m4 (gl_FUNC_TIMEGM): Conditionally set REPLACE_TIMEGM.
* lib/time.in.h (timegm): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog     | 4 ++++
 lib/time.in.h | 2 ++
 m4/timegm.m4  | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index a9a774a37d..069ce89b10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 12.
 
+	* m4/timegm.m4 (gl_FUNC_TIMEGM): Conditionally set REPLACE_TIMEGM.
+	* lib/time.in.h (timegm): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/pwrite.m4 (gl_FUNC_PWRITE): Conditionally set REPLACE_PWRITE.
 	* lib/unistd.in.h (pwrite): Disable _GL_CXXALIASWARN invocation on
 	non-glibc systems.
diff --git a/lib/time.in.h b/lib/time.in.h
index 50c9b30b6b..fa0c6351b2 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -423,7 +423,9 @@ _GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1)));
 #   endif
 _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm));
 #  endif
+#  if __GLIBC__ >= 2
 _GL_CXXALIASWARN (timegm);
+#  endif
 # endif
 
 /* Encourage applications to avoid unsafe functions that can overrun
diff --git a/m4/timegm.m4 b/m4/timegm.m4
index fa84e98db3..8ab265e65f 100644
--- a/m4/timegm.m4
+++ b/m4/timegm.m4
@@ -1,4 +1,4 @@
-# timegm.m4 serial 14
+# timegm.m4 serial 15
 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,
@@ -17,6 +17,9 @@ AC_DEFUN([gl_FUNC_TIMEGM],
     fi
   else
     HAVE_TIMEGM=0
+    case "$gl_cv_onwards_func_timegm" in
+      future*) REPLACE_TIMEGM=1 ;;
+    esac
   fi
 ])
 
-- 
2.34.1


[-- Attachment #9: 0008-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2239 bytes --]

From 7d2fc0f518407f69846a4c58cd775689b3465bc6 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 01:46:21 +0100
Subject: [PATCH 08/47] Resolve conflicts for functions introduced in Android
 API level 12.

* m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Conditionally set
REPLACE_UTIMENSAT.
* lib/sys_stat.in.h (utimensat): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog         | 5 +++++
 lib/sys_stat.in.h | 2 +-
 m4/utimensat.m4   | 5 ++++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 069ce89b10..e711c34b6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
 	Resolve conflicts for functions introduced in Android API level 12.
 
+	* m4/utimensat.m4 (gl_FUNC_UTIMENSAT): Conditionally set
+	REPLACE_UTIMENSAT.
+	* lib/sys_stat.in.h (utimensat): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/timegm.m4 (gl_FUNC_TIMEGM): Conditionally set REPLACE_TIMEGM.
 	* lib/time.in.h (timegm): Disable _GL_CXXALIASWARN invocation on
 	non-glibc systems.
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 096887c016..915cab08fb 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -937,7 +937,7 @@ _GL_FUNCDECL_SYS (utimensat, int, (int fd, char const *name,
 _GL_CXXALIAS_SYS (utimensat, int, (int fd, char const *name,
                                    struct timespec const times[2], int flag));
 # endif
-# if @HAVE_UTIMENSAT@
+# if __GLIBC__ >= 2 && @HAVE_UTIMENSAT@
 _GL_CXXALIASWARN (utimensat);
 # endif
 #elif defined GNULIB_POSIXCHECK
diff --git a/m4/utimensat.m4 b/m4/utimensat.m4
index 1d3db2efa2..1a670bb7b7 100644
--- a/m4/utimensat.m4
+++ b/m4/utimensat.m4
@@ -1,4 +1,4 @@
-# serial 10
+# serial 11
 # See if we need to provide utimensat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -16,6 +16,9 @@ AC_DEFUN([gl_FUNC_UTIMENSAT],
   gl_CHECK_FUNCS_ANDROID([utimensat], [[#include <sys/stat.h>]])
   if test $ac_cv_func_utimensat = no; then
     HAVE_UTIMENSAT=0
+    case "$gl_cv_onwards_func_utimensat" in
+      future*) REPLACE_UTIMENSAT=1 ;;
+    esac
   else
     AC_CACHE_CHECK([whether utimensat works],
       [gl_cv_func_utimensat_works],
-- 
2.34.1


[-- Attachment #10: 0009-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2159 bytes --]

From df12be387c61fa8816c5e7a1b1a435f6e2ce255c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 02:00:51 +0100
Subject: [PATCH 09/47] Resolve conflicts for functions introduced in Android
 API level 16.

* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Conditionally set
REPLACE_FACCESSAT.
* lib/unistd.in.h (faccessat): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog       | 9 +++++++++
 lib/unistd.in.h | 2 ++
 m4/faccessat.m4 | 5 ++++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e711c34b6c..7283803817 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 16.
+
+	* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Conditionally set
+	REPLACE_FACCESSAT.
+	* lib/unistd.in.h (faccessat): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 12.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index bc69194fac..df095ba479 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -925,7 +925,9 @@ _GL_FUNCDECL_SYS (faccessat, int,
 _GL_CXXALIAS_SYS (faccessat, int,
                   (int fd, char const *file, int mode, int flag));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (faccessat);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef faccessat
 # if HAVE_RAW_DECL_FACCESSAT
diff --git a/m4/faccessat.m4 b/m4/faccessat.m4
index 958c4978b7..a858bfee33 100644
--- a/m4/faccessat.m4
+++ b/m4/faccessat.m4
@@ -1,4 +1,4 @@
-# serial 11
+# serial 12
 # See if we need to provide faccessat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -19,6 +19,9 @@ AC_DEFUN([gl_FUNC_FACCESSAT],
   gl_CHECK_FUNCS_ANDROID([faccessat], [[#include <unistd.h>]])
   if test $ac_cv_func_faccessat = no; then
     HAVE_FACCESSAT=0
+    case "$gl_cv_onwards_func_faccessat" in
+      future*) REPLACE_FACCESSAT=1 ;;
+    esac
   else
     case $gl_cv_func_lstat_dereferences_slashed_symlink in
       *yes) ;;
-- 
2.34.1


[-- Attachment #11: 0011-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2227 bytes --]

From 3a1e709270f02f91e6132bbb2ef333a01bbaa7e2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 02:08:45 +0100
Subject: [PATCH 11/47] Resolve conflicts for functions introduced in Android
 API level 16-17.

* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN): Conditionally set
REPLACE_POSIX_MEMALIGN.
* lib/stdlib.in.h (posix_memalign): Disable _GL_CXXALIASWARN invocation
on non-glibc systems.
---
 ChangeLog            | 8 ++++++++
 lib/stdlib.in.h      | 2 +-
 m4/posix_memalign.m4 | 5 ++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8f536cfc73..b60113ead2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 16-17.
+	* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN): Conditionally set
+	REPLACE_POSIX_MEMALIGN.
+	* lib/stdlib.in.h (posix_memalign): Disable _GL_CXXALIASWARN invocation
+	on non-glibc systems.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 16.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 55f31feb42..018e7945db 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -733,7 +733,7 @@ _GL_CXXALIAS_SYS (posix_memalign, int,
                   (void **memptr, size_t alignment, size_t size));
 #  endif
 # endif
-# if @HAVE_POSIX_MEMALIGN@
+# if __GLIBC__ >= 2 && @HAVE_POSIX_MEMALIGN@
 _GL_CXXALIASWARN (posix_memalign);
 # endif
 #elif defined GNULIB_POSIXCHECK
diff --git a/m4/posix_memalign.m4 b/m4/posix_memalign.m4
index 36d88e0323..c5404a0119 100644
--- a/m4/posix_memalign.m4
+++ b/m4/posix_memalign.m4
@@ -1,4 +1,4 @@
-# posix_memalign.m4 serial 2
+# posix_memalign.m4 serial 3
 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,
@@ -46,5 +46,8 @@ AC_DEFUN([gl_FUNC_POSIX_MEMALIGN],
   else
     dnl The system does not have posix_memalign.
     HAVE_POSIX_MEMALIGN=0
+    case "$gl_cv_onwards_func_posix_memalign" in
+      future*) REPLACE_POSIX_MEMALIGN=1 ;;
+    esac
   fi
 ])
-- 
2.34.1


[-- Attachment #12: 0010-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 3256 bytes --]

From 74706dd7b80249312e832f768ca4e9699986e4cf Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 02:05:15 +0100
Subject: [PATCH 10/47] Resolve conflicts for functions introduced in Android
 API level 16.

* m4/tsearch.m4 (gl_FUNC_TSEARCH): Conditionally set REPLACE_TSEARCH.
* lib/search.in.h (tsearch, tfind, tdelete, twalk): Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
---
 ChangeLog       | 4 ++++
 lib/search.in.h | 8 ++++++++
 m4/tsearch.m4   | 5 ++++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 7283803817..8f536cfc73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 16.
 
+	* m4/tsearch.m4 (gl_FUNC_TSEARCH): Conditionally set REPLACE_TSEARCH.
+	* lib/search.in.h (tsearch, tfind, tdelete, twalk): Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+
 	* m4/faccessat.m4 (gl_FUNC_FACCESSAT): Conditionally set
 	REPLACE_FACCESSAT.
 	* lib/unistd.in.h (faccessat): Disable _GL_CXXALIASWARN invocation on
diff --git a/lib/search.in.h b/lib/search.in.h
index cf5bfb9b1b..e8cd6992e7 100644
--- a/lib/search.in.h
+++ b/lib/search.in.h
@@ -156,7 +156,9 @@ _GL_CXXALIAS_SYS (tsearch, void *,
                   (const void *key, void **vrootp,
                    _gl_search_compar_fn compar));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (tsearch);
+# endif
 
 /* Searches an element in the tree *VROOTP that compares equal to KEY.
    If one is found, it is returned.  Otherwise, NULL is returned.  */
@@ -181,7 +183,9 @@ _GL_CXXALIAS_SYS_CAST (tfind, void *,
                        (const void *key, void *const *vrootp,
                         _gl_search_compar_fn compar));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (tfind);
+# endif
 
 /* Searches an element in the tree *VROOTP that compares equal to KEY.
    If one is found, it is removed from the tree, and its parent node is
@@ -205,7 +209,9 @@ _GL_CXXALIAS_SYS (tdelete, void *,
                   (const void *restrict key, void **restrict vrootp,
                    _gl_search_compar_fn compar));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (tdelete);
+# endif
 
 /* Perform a depth-first, left-to-right traversal of the tree VROOT.
    The ACTION function is called:
@@ -233,7 +239,9 @@ _GL_FUNCDECL_SYS (twalk, void,
 _GL_CXXALIAS_SYS (twalk, void,
                   (const void *vroot, _gl_search_action_fn action));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (twalk);
+# endif
 
 /* Flags used by tsearch.c.  */
 # define GNULIB_defined_tsearch  (@REPLACE_TSEARCH@ || !@HAVE_TSEARCH@)
diff --git a/m4/tsearch.m4 b/m4/tsearch.m4
index d78da9b198..0781151e52 100644
--- a/m4/tsearch.m4
+++ b/m4/tsearch.m4
@@ -1,4 +1,4 @@
-# tsearch.m4 serial 10
+# tsearch.m4 serial 11
 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,
@@ -53,6 +53,9 @@ main ()
     esac
   else
     HAVE_TSEARCH=0
+    case "$gl_cv_onwards_func_tsearch" in
+      future*) REPLACE_TSEARCH=1 ;;
+    esac
   fi
   if test $ac_cv_func_twalk != yes; then
     HAVE_TWALK=0
-- 
2.34.1


[-- Attachment #13: 0012-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 3010 bytes --]

From 8148edea8666b821663a7d29e1ea9151d9570106 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 02:22:22 +0100
Subject: [PATCH 12/47] Resolve conflicts for functions introduced in Android
 API level 18.

* m4/getdelim.m4 (gl_FUNC_GETDELIM): Conditionally set REPLACE_GETDELIM.
* m4/getline.m4 (gl_FUNC_GETLINE): Conditionally set REPLACE_GETLINE.
* lib/stdio.in.h (getdelim, getline): Disable _GL_CXXALIASWARN
invocation on non-glibc systems.
---
 ChangeLog      | 9 +++++++++
 lib/stdio.in.h | 4 +++-
 m4/getdelim.m4 | 5 ++++-
 m4/getline.m4  | 5 ++++-
 4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b60113ead2..39c23bce80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 18.
+
+	* m4/getdelim.m4 (gl_FUNC_GETDELIM): Conditionally set REPLACE_GETDELIM.
+	* m4/getline.m4 (gl_FUNC_GETLINE): Conditionally set REPLACE_GETLINE.
+	* lib/stdio.in.h (getdelim, getline): Disable _GL_CXXALIASWARN
+	invocation on non-glibc systems.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 16-17.
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 8b5ef4bd2d..e3bd60dae1 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -882,7 +882,9 @@ _GL_CXXALIAS_SYS (getdelim, ssize_t,
                    int delimiter,
                    FILE *restrict stream));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (getdelim);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef getdelim
 # if HAVE_RAW_DECL_GETDELIM
@@ -921,7 +923,7 @@ _GL_CXXALIAS_SYS (getline, ssize_t,
                   (char **restrict lineptr, size_t *restrict linesize,
                    FILE *restrict stream));
 # endif
-# if @HAVE_DECL_GETLINE@
+# if __GLIBC__ >= 2 && @HAVE_DECL_GETLINE@
 _GL_CXXALIASWARN (getline);
 # endif
 #elif defined GNULIB_POSIXCHECK
diff --git a/m4/getdelim.m4 b/m4/getdelim.m4
index bbd7c03bcb..d89aae5dff 100644
--- a/m4/getdelim.m4
+++ b/m4/getdelim.m4
@@ -1,4 +1,4 @@
-# getdelim.m4 serial 17
+# getdelim.m4 serial 18
 
 dnl Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
 dnl
@@ -96,6 +96,9 @@ AC_DEFUN([gl_FUNC_GETDELIM],
     esac
   else
     HAVE_GETDELIM=0
+    case "$gl_cv_onwards_func_getdelim" in
+      future*) REPLACE_GETDELIM=1 ;;
+    esac
   fi
 
   if test $ac_cv_have_decl_getdelim = no; then
diff --git a/m4/getline.m4 b/m4/getline.m4
index f68fa3a1ac..1f2825c336 100644
--- a/m4/getline.m4
+++ b/m4/getline.m4
@@ -1,4 +1,4 @@
-# getline.m4 serial 31
+# getline.m4 serial 32
 
 dnl Copyright (C) 1998-2003, 2005-2007, 2009-2023 Free Software Foundation,
 dnl Inc.
@@ -84,6 +84,9 @@ AC_DEFUN([gl_FUNC_GETLINE],
       ])
   else
     am_cv_func_working_getline=no
+    case "$gl_cv_onwards_func_getline" in
+      future*) REPLACE_GETLINE=1 ;;
+    esac
   fi
 
   if test $ac_cv_have_decl_getline = no; then
-- 
2.34.1


[-- Attachment #14: 0013-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 3733 bytes --]

From 307c5c697b42f3e60b6a672d31223585121a464d Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 02:25:19 +0100
Subject: [PATCH 13/47] Resolve conflicts for functions introduced in Android
 API level 18.

* m4/log2.m4 (gl_FUNC_LOG2): Conditionally set REPLACE_LOG2.
* m4/log2f.m4 (gl_FUNC_LOG2F): Conditionally set REPLACE_LOG2F.
* m4/log2l.m4 (gl_FUNC_LOG2L): Conditionally set REPLACE_LOG2L.
* lib/math.in.h (log2f): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog     | 6 ++++++
 lib/math.in.h | 2 ++
 m4/log2.m4    | 5 ++++-
 m4/log2f.m4   | 5 ++++-
 m4/log2l.m4   | 5 ++++-
 5 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 39c23bce80..acd6ddfe0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
 
 	Resolve conflicts for functions introduced in Android API level 18.
 
+	* m4/log2.m4 (gl_FUNC_LOG2): Conditionally set REPLACE_LOG2.
+	* m4/log2f.m4 (gl_FUNC_LOG2F): Conditionally set REPLACE_LOG2F.
+	* m4/log2l.m4 (gl_FUNC_LOG2L): Conditionally set REPLACE_LOG2L.
+	* lib/math.in.h (log2f): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/getdelim.m4 (gl_FUNC_GETDELIM): Conditionally set REPLACE_GETDELIM.
 	* m4/getline.m4 (gl_FUNC_GETLINE): Conditionally set REPLACE_GETLINE.
 	* lib/stdio.in.h (getdelim, getline): Disable _GL_CXXALIASWARN
diff --git a/lib/math.in.h b/lib/math.in.h
index a1cb22936b..70b75e2399 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -1696,7 +1696,9 @@ _GL_FUNCDECL_SYS (log2f, float, (float x));
 #  endif
 _GL_CXXALIAS_SYS (log2f, float, (float x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (log2f);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef log2f
 # if HAVE_RAW_DECL_LOG2F
diff --git a/m4/log2.m4 b/m4/log2.m4
index 4e08f48fe8..809853ed3b 100644
--- a/m4/log2.m4
+++ b/m4/log2.m4
@@ -1,4 +1,4 @@
-# log2.m4 serial 11
+# log2.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,
@@ -100,6 +100,9 @@ int main (int argc, char *argv[])
   else
     HAVE_LOG2=0
     HAVE_DECL_LOG2=0
+    case "$gl_cv_onwards_func_log2" in
+      future*) REPLACE_LOG2=1 ;;
+    esac
   fi
   if test $HAVE_LOG2 = 0 || test $REPLACE_LOG2 = 1; then
     dnl Find libraries needed to link lib/log2.c.
diff --git a/m4/log2f.m4 b/m4/log2f.m4
index b85993c2c2..3c47f1aa87 100644
--- a/m4/log2f.m4
+++ b/m4/log2f.m4
@@ -1,4 +1,4 @@
-# log2f.m4 serial 11
+# log2f.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,
@@ -101,6 +101,9 @@ int main (int argc, char *argv[])
   else
     HAVE_LOG2F=0
     HAVE_DECL_LOG2F=0
+    case "$gl_cv_onwards_func_log2f" in
+      future*) REPLACE_LOG2F=1 ;;
+    esac
   fi
   if test $HAVE_LOG2F = 0 || test $REPLACE_LOG2F = 1; then
     dnl Find libraries needed to link lib/log2f.c.
diff --git a/m4/log2l.m4 b/m4/log2l.m4
index e4810d5a94..57639a2af5 100644
--- a/m4/log2l.m4
+++ b/m4/log2l.m4
@@ -1,4 +1,4 @@
-# log2l.m4 serial 4
+# log2l.m4 serial 5
 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,
@@ -37,6 +37,9 @@ AC_DEFUN([gl_FUNC_LOG2L],
   else
     HAVE_LOG2L=0
     HAVE_DECL_LOG2L=0
+    case "$gl_cv_onwards_func_log2l" in
+      future*) REPLACE_LOG2L=1 ;;
+    esac
   fi
   if test $HAVE_LOG2L = 0 || test $REPLACE_LOG2L = 1; then
     dnl Find libraries needed to link lib/log2l.c.
-- 
2.34.1


[-- Attachment #15: 0014-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2181 bytes --]

From cb4b0191ce484321121bd5701d271f9d1832958c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 02:43:23 +0100
Subject: [PATCH 14/47] Resolve conflicts for functions introduced in Android
 API level 19.

* m4/futimens.m4 (gl_FUNC_FUTIMENS): Conditionally set REPLACE_FUTIMENS.
* lib/sys_stat.in.h (futimens): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog         | 8 ++++++++
 lib/sys_stat.in.h | 2 +-
 m4/futimens.m4    | 5 ++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index acd6ddfe0f..ace915fe22 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 19.
+
+	* m4/futimens.m4 (gl_FUNC_FUTIMENS): Conditionally set REPLACE_FUTIMENS.
+	* lib/sys_stat.in.h (futimens): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 18.
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 915cab08fb..7d92239dd1 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -549,7 +549,7 @@ _GL_FUNCDECL_SYS (futimens, int, (int fd, struct timespec const times[2]));
 #  endif
 _GL_CXXALIAS_SYS (futimens, int, (int fd, struct timespec const times[2]));
 # endif
-# if @HAVE_FUTIMENS@
+# if __GLIBC__ >= 2 && @HAVE_FUTIMENS@
 _GL_CXXALIASWARN (futimens);
 # endif
 #elif defined GNULIB_POSIXCHECK
diff --git a/m4/futimens.m4 b/m4/futimens.m4
index 8e997d6ea6..dc0b21b9d5 100644
--- a/m4/futimens.m4
+++ b/m4/futimens.m4
@@ -1,4 +1,4 @@
-# serial 10
+# serial 11
 # See if we need to provide futimens replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -16,6 +16,9 @@ AC_DEFUN([gl_FUNC_FUTIMENS],
   gl_CHECK_FUNCS_ANDROID([futimens], [[#include <sys/stat.h>]])
   if test $ac_cv_func_futimens = no; then
     HAVE_FUTIMENS=0
+    case "$gl_cv_onwards_func_futimens" in
+      future*) REPLACE_FUTIMENS=1 ;;
+    esac
   else
     AC_CACHE_CHECK([whether futimens works],
       [gl_cv_func_futimens_works],
-- 
2.34.1


[-- Attachment #16: 0015-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 8436 bytes --]

From afcb36b3c4bca6e8c3fafa8103841f03772e87a5 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 11:42:32 +0100
Subject: [PATCH 15/47] Resolve conflicts for functions introduced in Android
 API level 19.

* lib/inttypes.in.h (imaxabs): Consider REPLACE_IMAXABS. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
(imaxdiv): Consider REPLACE_IMAXDIV. Disable _GL_CXXALIASWARN invocation
on non-glibc systems.
* m4/inttypes.m4 (gl_INTTYPES_H_DEFAULTS): Initialize HAVE_IMAXABS,
HAVE_IMAXDIV, REPLACE_IMAXABS, REPLACE_IMAXDIV.
* modules/inttypes-incomplete (Makefile.am): Substitute REPLACE_IMAXABS,
REPLACE_IMAXDIV.
* m4/imaxabs.m4 (gl_FUNC_IMAXABS): Conditionally set HAVE_IMAXABS,
REPLACE_IMAXABS.
* modules/imaxabs (configure.ac): Consider HAVE_IMAXABS, REPLACE_IMAXABS.
* m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Conditionally set HAVE_IMAXDIV,
REPLACE_IMAXDIV.
* modules/imaxdiv (configure.ac): Consider HAVE_IMAXDIV, REPLACE_IMAXDIV.
---
 ChangeLog                   | 15 +++++++++++++++
 lib/inttypes.in.h           | 34 ++++++++++++++++++++++++++++++----
 m4/imaxabs.m4               |  8 +++++++-
 m4/imaxdiv.m4               |  8 +++++++-
 m4/inttypes.m4              |  6 +++++-
 modules/imaxabs             |  3 ++-
 modules/imaxdiv             |  3 ++-
 modules/inttypes-incomplete |  2 ++
 8 files changed, 70 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ace915fe22..449746ce95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,21 @@
 
 	Resolve conflicts for functions introduced in Android API level 19.
 
+	* lib/inttypes.in.h (imaxabs): Consider REPLACE_IMAXABS. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	(imaxdiv): Consider REPLACE_IMAXDIV. Disable _GL_CXXALIASWARN invocation
+	on non-glibc systems.
+	* m4/inttypes.m4 (gl_INTTYPES_H_DEFAULTS): Initialize HAVE_IMAXABS,
+	HAVE_IMAXDIV, REPLACE_IMAXABS, REPLACE_IMAXDIV.
+	* modules/inttypes-incomplete (Makefile.am): Substitute REPLACE_IMAXABS,
+	REPLACE_IMAXDIV.
+	* m4/imaxabs.m4 (gl_FUNC_IMAXABS): Conditionally set HAVE_IMAXABS,
+	REPLACE_IMAXABS.
+	* modules/imaxabs (configure.ac): Consider HAVE_IMAXABS, REPLACE_IMAXABS.
+	* m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Conditionally set HAVE_IMAXDIV,
+	REPLACE_IMAXDIV.
+	* modules/imaxdiv (configure.ac): Consider HAVE_IMAXDIV, REPLACE_IMAXDIV.
+
 	* m4/futimens.m4 (gl_FUNC_FUTIMENS): Conditionally set REPLACE_FUTIMENS.
 	* lib/sys_stat.in.h (futimens): Disable _GL_CXXALIASWARN invocation on
 	non-glibc systems.
diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h
index 50a2bbfcda..5b7ef12dc7 100644
--- a/lib/inttypes.in.h
+++ b/lib/inttypes.in.h
@@ -903,8 +903,21 @@ extern "C" {
 #endif
 
 #if @GNULIB_IMAXABS@
-# if !@HAVE_DECL_IMAXABS@
-extern intmax_t imaxabs (intmax_t);
+# if @REPLACE_IMAXABS@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef imaxabs
+#   define imaxabs rpl_imaxabs
+#  endif
+_GL_FUNCDECL_RPL (imaxabs, intmax_t, (intmax_t x));
+_GL_CXXALIAS_RPL (imaxabs, intmax_t, (intmax_t x));
+# else
+#  if !@HAVE_DECL_IMAXABS@
+_GL_FUNCDECL_SYS (imaxabs, intmax_t, (intmax_t x));
+#  endif
+_GL_CXXALIAS_SYS (imaxabs, intmax_t, (intmax_t x));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (imaxabs);
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef imaxabs
@@ -921,8 +934,21 @@ typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
 #   define GNULIB_defined_imaxdiv_t 1
 #  endif
 # endif
-# if !@HAVE_DECL_IMAXDIV@
-extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
+# if @REPLACE_IMAXDIV@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef imaxdiv
+#   define imaxdiv rpl_imaxdiv
+#  endif
+_GL_FUNCDECL_RPL (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom));
+_GL_CXXALIAS_RPL (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom));
+# else
+#  if !@HAVE_DECL_IMAXDIV@
+_GL_FUNCDECL_SYS (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom));
+#  endif
+_GL_CXXALIAS_SYS (imaxdiv, imaxdiv_t, (intmax_t numer, intmax_t denom));
+# endif
+# if __GLIBC__ >= 2
+_GL_CXXALIASWARN (imaxdiv);
 # endif
 #elif defined GNULIB_POSIXCHECK
 # undef imaxdiv
diff --git a/m4/imaxabs.m4 b/m4/imaxabs.m4
index 504db4845c..b0e928912f 100644
--- a/m4/imaxabs.m4
+++ b/m4/imaxabs.m4
@@ -1,4 +1,4 @@
-# imaxabs.m4 serial 5
+# imaxabs.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,
@@ -10,6 +10,12 @@ AC_DEFUN([gl_FUNC_IMAXABS],
 
   dnl On OSF/1 5.1 with cc, this function is declared but not defined.
   gl_CHECK_FUNCS_ANDROID([imaxabs], [[#include <inttypes.h>]])
+  if test $ac_cv_func_imaxabs = no; then
+    HAVE_IMAXABS=0
+    case "$gl_cv_onwards_func_imaxabs" in
+      future*) REPLACE_IMAXABS=1 ;;
+    esac
+  fi
   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 7ad5da4ebf..731fa88c0e 100644
--- a/m4/imaxdiv.m4
+++ b/m4/imaxdiv.m4
@@ -1,4 +1,4 @@
-# imaxdiv.m4 serial 6
+# imaxdiv.m4 serial 7
 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,
@@ -10,6 +10,12 @@ AC_DEFUN([gl_FUNC_IMAXDIV],
 
   dnl On OSF/1 5.1 with cc, this function is declared but not defined.
   gl_CHECK_FUNCS_ANDROID([imaxdiv], [[#include <inttypes.h>]])
+  if test $ac_cv_func_imaxdiv = no; then
+    HAVE_IMAXDIV=0
+    case "$gl_cv_onwards_func_imaxdiv" in
+      future*) REPLACE_IMAXDIV=1 ;;
+    esac
+  fi
   AC_CHECK_DECLS_ONCE([imaxdiv])
   if test "$ac_cv_have_decl_imaxdiv" != yes; then
     HAVE_DECL_IMAXDIV=0
diff --git a/m4/inttypes.m4 b/m4/inttypes.m4
index bf2eab2ba3..e7efbe9416 100644
--- a/m4/inttypes.m4
+++ b/m4/inttypes.m4
@@ -1,4 +1,4 @@
-# inttypes.m4 serial 36
+# inttypes.m4 serial 37
 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,
@@ -170,6 +170,10 @@ AC_DEFUN([gl_INTTYPES_H_DEFAULTS],
   HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX])
   HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX])
   HAVE_IMAXDIV_T=1;      AC_SUBST([HAVE_IMAXDIV_T])
+  HAVE_IMAXABS=1;        AC_SUBST([HAVE_IMAXABS])
+  HAVE_IMAXDIV=1;        AC_SUBST([HAVE_IMAXDIV])
+  REPLACE_IMAXABS=0;     AC_SUBST([REPLACE_IMAXABS])
+  REPLACE_IMAXDIV=0;     AC_SUBST([REPLACE_IMAXDIV])
   REPLACE_STRTOIMAX=0;   AC_SUBST([REPLACE_STRTOIMAX])
   REPLACE_STRTOUMAX=0;   AC_SUBST([REPLACE_STRTOUMAX])
   INT32_MAX_LT_INTMAX_MAX=1;  AC_SUBST([INT32_MAX_LT_INTMAX_MAX])
diff --git a/modules/imaxabs b/modules/imaxabs
index 70bb9cd9c0..e33b48ff8e 100644
--- a/modules/imaxabs
+++ b/modules/imaxabs
@@ -10,7 +10,8 @@ inttypes-incomplete
 
 configure.ac:
 gl_FUNC_IMAXABS
-gl_CONDITIONAL([GL_COND_OBJ_IMAXABS], [test $ac_cv_func_imaxabs = no])
+gl_CONDITIONAL([GL_COND_OBJ_IMAXABS],
+               [test $HAVE_IMAXABS = 0 || test $REPLACE_IMAXABS = 1])
 AM_COND_IF([GL_COND_OBJ_IMAXABS], [
   gl_PREREQ_IMAXABS
 ])
diff --git a/modules/imaxdiv b/modules/imaxdiv
index 192a5e048d..74f800b64f 100644
--- a/modules/imaxdiv
+++ b/modules/imaxdiv
@@ -10,7 +10,8 @@ inttypes-incomplete
 
 configure.ac:
 gl_FUNC_IMAXDIV
-gl_CONDITIONAL([GL_COND_OBJ_IMAXDIV], [test $ac_cv_func_imaxdiv = no])
+gl_CONDITIONAL([GL_COND_OBJ_IMAXDIV],
+               [test $HAVE_IMAXDIV = 0 || test $REPLACE_IMAXDIV = 1])
 AM_COND_IF([GL_COND_OBJ_IMAXDIV], [
   gl_PREREQ_IMAXDIV
 ])
diff --git a/modules/inttypes-incomplete b/modules/inttypes-incomplete
index 38177e1e19..96ab2e3cdd 100644
--- a/modules/inttypes-incomplete
+++ b/modules/inttypes-incomplete
@@ -43,6 +43,8 @@ inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U
 	      -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
 	      -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
 	      -e 's/@''HAVE_IMAXDIV_T''@/$(HAVE_IMAXDIV_T)/g' \
+	      -e 's/@''REPLACE_IMAXABS''@/$(REPLACE_IMAXABS)/g' \
+	      -e 's/@''REPLACE_IMAXDIV''@/$(REPLACE_IMAXDIV)/g' \
 	      -e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \
 	      -e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \
 	      -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \
-- 
2.34.1


[-- Attachment #17: 0016-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 5066 bytes --]

From 8c15a911325fd0166dbeb2f30b78ac02a71fb304 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 11:47:22 +0100
Subject: [PATCH 16/47] Resolve conflicts for functions introduced in Android
 API level 21.

* lib/search.in.h (twalk): Consider REPLACE_TWALK.
* m4/search_h.m4 (gl_SEARCH_H_DEFAULTS): Initialize REPLACE_TWALK.
* modules/search (Makefile.am): Substitute REPLACE_TWALK.
* m4/tsearch.m4 (gl_FUNC_TSEARCH): Conditionally set REPLACE_TWALK.
* modules/tsearch (configure.ac): Consider REPLACE_TWALK.
---
 ChangeLog       | 10 ++++++++++
 lib/search.in.h |  8 ++++++--
 m4/search_h.m4  |  3 ++-
 m4/tsearch.m4   |  6 +++++-
 modules/search  |  1 +
 modules/tsearch |  2 +-
 6 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 449746ce95..b6deccf065 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 21.
+
+	* lib/search.in.h (twalk): Consider REPLACE_TWALK.
+	* m4/search_h.m4 (gl_SEARCH_H_DEFAULTS): Initialize REPLACE_TWALK.
+	* modules/search (Makefile.am): Substitute REPLACE_TWALK.
+	* m4/tsearch.m4 (gl_FUNC_TSEARCH): Conditionally set REPLACE_TWALK.
+	* modules/tsearch (configure.ac): Consider REPLACE_TWALK.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 19.
diff --git a/lib/search.in.h b/lib/search.in.h
index e8cd6992e7..32b022edc6 100644
--- a/lib/search.in.h
+++ b/lib/search.in.h
@@ -100,6 +100,10 @@ _GL_CXXALIASWARN (lsearch);
 #   define tsearch rpl_tsearch
 #   define tfind rpl_tfind
 #   define tdelete rpl_tdelete
+#  endif
+# endif
+# if @REPLACE_TWALK@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   define twalk rpl_twalk
 #  endif
 # endif
@@ -224,7 +228,7 @@ _GL_CXXALIASWARN (tdelete);
         pointer to the key,
      2. an indicator which visit of the node this is,
      3. the level of the node in the tree (0 for the root).  */
-# if @REPLACE_TSEARCH@
+# if @REPLACE_TWALK@
 _GL_FUNCDECL_RPL (twalk, void,
                   (const void *vroot, _gl_search_action_fn action)
                   _GL_ARG_NONNULL ((2)));
@@ -245,7 +249,7 @@ _GL_CXXALIASWARN (twalk);
 
 /* Flags used by tsearch.c.  */
 # define GNULIB_defined_tsearch  (@REPLACE_TSEARCH@ || !@HAVE_TSEARCH@)
-# define GNULIB_defined_twalk    (@REPLACE_TSEARCH@ || !@HAVE_TWALK@)
+# define GNULIB_defined_twalk    (@REPLACE_TWALK@ || !@HAVE_TWALK@)
 
 #elif defined GNULIB_POSIXCHECK
 # undef tsearch
diff --git a/m4/search_h.m4 b/m4/search_h.m4
index 4fb2c77b09..a8c87abcee 100644
--- a/m4/search_h.m4
+++ b/m4/search_h.m4
@@ -1,4 +1,4 @@
-# search_h.m4 serial 15
+# search_h.m4 serial 16
 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,
@@ -78,4 +78,5 @@ AC_DEFUN([gl_SEARCH_H_DEFAULTS],
   HAVE_TSEARCH=1;    AC_SUBST([HAVE_TSEARCH])
   HAVE_TWALK=1;      AC_SUBST([HAVE_TWALK])
   REPLACE_TSEARCH=0; AC_SUBST([REPLACE_TSEARCH])
+  REPLACE_TWALK=0;   AC_SUBST([REPLACE_TWALK])
 ])
diff --git a/m4/tsearch.m4 b/m4/tsearch.m4
index 0781151e52..c2ddc8a71e 100644
--- a/m4/tsearch.m4
+++ b/m4/tsearch.m4
@@ -1,4 +1,4 @@
-# tsearch.m4 serial 11
+# tsearch.m4 serial 12
 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,
@@ -49,6 +49,7 @@ main ()
     case "$gl_cv_func_tdelete_works" in
       *no)
         REPLACE_TSEARCH=1
+        REPLACE_TWALK=1
         ;;
     esac
   else
@@ -59,6 +60,9 @@ main ()
   fi
   if test $ac_cv_func_twalk != yes; then
     HAVE_TWALK=0
+    case "$gl_cv_onwards_func_twalk" in
+      future*) REPLACE_TWALK=1 ;;
+    esac
   fi
 ])
 
diff --git a/modules/search b/modules/search
index ad9382fc1b..2debf36b89 100644
--- a/modules/search
+++ b/modules/search
@@ -38,6 +38,7 @@ search.h: search.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''HAVE_TSEARCH''@|$(HAVE_TSEARCH)|g' \
 	      -e 's|@''HAVE_TWALK''@|$(HAVE_TWALK)|g' \
 	      -e 's|@''REPLACE_TSEARCH''@|$(REPLACE_TSEARCH)|g' \
+	      -e 's|@''REPLACE_TWALK''@|$(REPLACE_TWALK)|g' \
 	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
 	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
diff --git a/modules/tsearch b/modules/tsearch
index 91ef56c8c0..c4c363b7a6 100644
--- a/modules/tsearch
+++ b/modules/tsearch
@@ -11,7 +11,7 @@ search
 configure.ac:
 gl_FUNC_TSEARCH
 gl_CONDITIONAL([GL_COND_OBJ_TSEARCH],
-               [test $HAVE_TSEARCH = 0 || test $HAVE_TWALK = 0 || test $REPLACE_TSEARCH = 1])
+               [test $HAVE_TSEARCH = 0 || test $HAVE_TWALK = 0 || test $REPLACE_TSEARCH = 1 || test $REPLACE_TWALK = 1])
 AM_COND_IF([GL_COND_OBJ_TSEARCH], [
   gl_PREREQ_TSEARCH
 ])
-- 
2.34.1


[-- Attachment #18: 0017-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 12512 bytes --]

From daa77bf4aa393cbdec3a5a81ae3dc6923a981f6d Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 11:48:22 +0100
Subject: [PATCH 17/47] Resolve conflicts for functions introduced in Android
 API level 21.

* lib/stdlib.in.h (_Exit): Consider REPLACE__EXIT. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
(getprogname): Consider REPLACE_GETPROGNAME. Disable _GL_CXXALIASWARN
invocation on non-glibc systems.
(posix_openpt): Consider REPLACE_POSIX_OPENPT. Disable _GL_CXXALIASWARN
invocation on non-glibc systems.
* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE__EXIT,
REPLACE_GETPROGNAME, REPLACE_POSIX_OPENPT.
* modules/stdlib (Makefile.am): Substitute REPLACE__EXIT,
REPLACE_GETPROGNAME, REPLACE_POSIX_OPENPT.
* m4/_Exit.m4 (gl_FUNC__EXIT): Conditionally set REPLACE__EXIT.
* modules/_Exit (configure.ac): Consider REPLACE__EXIT.
* m4/getprogname.m4 (gl_FUNC_GETPROGNAME): Conditionally set
REPLACE_GETPROGNAME.
* modules/getprogname (configure.ac): Consider REPLACE_GETPROGNAME.
* m4/posix_openpt.m4 (gl_FUNC_POSIX_OPENPT): Conditionally set
REPLACE_POSIX_OPENPT.
* modules/posix_openpt (configure.ac): Consider REPLACE_POSIX_OPENPT.
---
 ChangeLog            | 19 +++++++++++++++++
 lib/stdlib.in.h      | 51 ++++++++++++++++++++++++++++++++++++++------
 m4/_Exit.m4          |  5 ++++-
 m4/getprogname.m4    |  5 ++++-
 m4/posix_openpt.m4   |  5 ++++-
 m4/stdlib_h.m4       |  5 ++++-
 modules/_Exit        |  3 ++-
 modules/getprogname  |  3 ++-
 modules/posix_openpt |  3 ++-
 modules/stdlib       |  3 +++
 10 files changed, 88 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b6deccf065..80063baa0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,25 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* lib/stdlib.in.h (_Exit): Consider REPLACE__EXIT. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	(getprogname): Consider REPLACE_GETPROGNAME. Disable _GL_CXXALIASWARN
+	invocation on non-glibc systems.
+	(posix_openpt): Consider REPLACE_POSIX_OPENPT. Disable _GL_CXXALIASWARN
+	invocation on non-glibc systems.
+	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE__EXIT,
+	REPLACE_GETPROGNAME, REPLACE_POSIX_OPENPT.
+	* modules/stdlib (Makefile.am): Substitute REPLACE__EXIT,
+	REPLACE_GETPROGNAME, REPLACE_POSIX_OPENPT.
+	* m4/_Exit.m4 (gl_FUNC__EXIT): Conditionally set REPLACE__EXIT.
+	* modules/_Exit (configure.ac): Consider REPLACE__EXIT.
+	* m4/getprogname.m4 (gl_FUNC_GETPROGNAME): Conditionally set
+	REPLACE_GETPROGNAME.
+	* modules/getprogname (configure.ac): Consider REPLACE_GETPROGNAME.
+	* m4/posix_openpt.m4 (gl_FUNC_POSIX_OPENPT): Conditionally set
+	REPLACE_POSIX_OPENPT.
+	* modules/posix_openpt (configure.ac): Consider REPLACE_POSIX_OPENPT.
+
 	* lib/search.in.h (twalk): Consider REPLACE_TWALK.
 	* m4/search_h.m4 (gl_SEARCH_H_DEFAULTS): Initialize REPLACE_TWALK.
 	* modules/search (Makefile.am): Substitute REPLACE_TWALK.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 018e7945db..88a8e034a1 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -164,11 +164,22 @@ struct random_data
 #if @GNULIB__EXIT@
 /* Terminate the current process with the given return code, without running
    the 'atexit' handlers.  */
-# if !@HAVE__EXIT@
+# if @REPLACE__EXIT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef _Exit
+#   define _Exit rpl__Exit
+#  endif
+_GL_FUNCDECL_RPL (_Exit, _Noreturn void, (int status));
+_GL_CXXALIAS_RPL (_Exit, void, (int status));
+# else
+#  if !@HAVE__EXIT@
 _GL_FUNCDECL_SYS (_Exit, _Noreturn void, (int status));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (_Exit, void, (int status));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (_Exit);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef _Exit
 # if HAVE_RAW_DECL__EXIT
@@ -433,15 +444,30 @@ _GL_WARN_ON_USE (getloadavg, "getloadavg is not portable - "
 #if @GNULIB_GETPROGNAME@
 /* Return the base name of the executing program.
    On native Windows this will usually end in ".exe" or ".EXE". */
-# if !@HAVE_GETPROGNAME@
+# if @REPLACE_GETPROGNAME@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef getprogname
+#   define getprogname rpl_getprogname
+#  endif
 #  ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
-_GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE);
+_GL_FUNCDECL_RPL (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE);
 #  else
+_GL_FUNCDECL_RPL (getprogname, const char *, (void));
+#  endif
+_GL_CXXALIAS_RPL (getprogname, const char *, (void));
+# else
+#  if !@HAVE_GETPROGNAME@
+#   ifdef HAVE_DECL_PROGRAM_INVOCATION_NAME
+_GL_FUNCDECL_SYS (getprogname, const char *, (void) _GL_ATTRIBUTE_PURE);
+#   else
 _GL_FUNCDECL_SYS (getprogname, const char *, (void));
+#   endif
 #  endif
-# endif
 _GL_CXXALIAS_SYS (getprogname, const char *, (void));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (getprogname);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef getprogname
 # if HAVE_RAW_DECL_GETPROGNAME
@@ -747,11 +773,22 @@ _GL_WARN_ON_USE (posix_memalign, "posix_memalign is not portable - "
 #if @GNULIB_POSIX_OPENPT@
 /* Return an FD open to the master side of a pseudo-terminal.  Flags should
    include O_RDWR, and may also include O_NOCTTY.  */
-# if !@HAVE_POSIX_OPENPT@
+# if @REPLACE_POSIX_OPENPT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef posix_openpt
+#   define posix_openpt rpl_posix_openpt
+#  endif
+_GL_FUNCDECL_RPL (posix_openpt, int, (int flags));
+_GL_CXXALIAS_RPL (posix_openpt, int, (int flags));
+# else
+#  if !@HAVE_POSIX_OPENPT@
 _GL_FUNCDECL_SYS (posix_openpt, int, (int flags));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (posix_openpt, int, (int flags));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_openpt);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_openpt
 # if HAVE_RAW_DECL_POSIX_OPENPT
diff --git a/m4/_Exit.m4 b/m4/_Exit.m4
index 61e1f848b7..8f032a7c92 100644
--- a/m4/_Exit.m4
+++ b/m4/_Exit.m4
@@ -1,4 +1,4 @@
-# _Exit.m4 serial 3
+# _Exit.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,
@@ -10,6 +10,9 @@ AC_DEFUN([gl_FUNC__EXIT],
   gl_CHECK_FUNCS_ANDROID([_Exit], [[#include <stdlib.h>]])
   if test $ac_cv_func__Exit = no; then
     HAVE__EXIT=0
+    case "$gl_cv_onwards_func__Exit" in
+      future*) REPLACE__EXIT=1 ;;
+    esac
   fi
 ])
 
diff --git a/m4/getprogname.m4 b/m4/getprogname.m4
index 0a4b9c874a..b8636e143a 100644
--- a/m4/getprogname.m4
+++ b/m4/getprogname.m4
@@ -5,13 +5,16 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 6
+# serial 7
 
 AC_DEFUN([gl_FUNC_GETPROGNAME],
 [
   gl_CHECK_FUNCS_ANDROID([getprogname], [[#include <stdlib.h>]])
   if test $ac_cv_func_getprogname = no; then
     HAVE_GETPROGNAME=0
+    case "$gl_cv_onwards_func_getprogname" in
+      future*) REPLACE_GETPROGNAME=1 ;;
+    esac
   fi
 ])
 
diff --git a/m4/posix_openpt.m4 b/m4/posix_openpt.m4
index f5912a12bb..7aaa495b63 100644
--- a/m4/posix_openpt.m4
+++ b/m4/posix_openpt.m4
@@ -1,4 +1,4 @@
-# posix_openpt.m4 serial 3
+# posix_openpt.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,
@@ -15,5 +15,8 @@ AC_DEFUN([gl_FUNC_POSIX_OPENPT],
   if test $ac_cv_func_posix_openpt != yes; then
     dnl The system does not have posix_openpt.
     HAVE_POSIX_OPENPT=0
+    case "$gl_cv_onwards_func_posix_openpt" in
+      future*) REPLACE_POSIX_OPENPT=1 ;;
+    esac
   fi
 ])
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index f1f2d04047..f1360a457b 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 67
+# stdlib_h.m4 serial 68
 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,
@@ -168,17 +168,20 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   HAVE_SYS_LOADAVG_H=0;      AC_SUBST([HAVE_SYS_LOADAVG_H])
   HAVE_UNLOCKPT=1;           AC_SUBST([HAVE_UNLOCKPT])
   HAVE_DECL_UNSETENV=1;      AC_SUBST([HAVE_DECL_UNSETENV])
+  REPLACE__EXIT=0;           AC_SUBST([REPLACE__EXIT])
   REPLACE_ALIGNED_ALLOC=0;   AC_SUBST([REPLACE_ALIGNED_ALLOC])
   REPLACE_CALLOC_FOR_CALLOC_GNU=0;    AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_GNU])
   REPLACE_CALLOC_FOR_CALLOC_POSIX=0;  AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX])
   REPLACE_CANONICALIZE_FILE_NAME=0;  AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
   REPLACE_FREE=0;            AC_SUBST([REPLACE_FREE])
+  REPLACE_GETPROGNAME=0;     AC_SUBST([REPLACE_GETPROGNAME])
   REPLACE_INITSTATE=0;       AC_SUBST([REPLACE_INITSTATE])
   REPLACE_MALLOC_FOR_MALLOC_GNU=0;    AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU])
   REPLACE_MALLOC_FOR_MALLOC_POSIX=0;  AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX])
   REPLACE_MBTOWC=0;          AC_SUBST([REPLACE_MBTOWC])
   REPLACE_MKSTEMP=0;         AC_SUBST([REPLACE_MKSTEMP])
   REPLACE_POSIX_MEMALIGN=0;  AC_SUBST([REPLACE_POSIX_MEMALIGN])
+  REPLACE_POSIX_OPENPT=0;    AC_SUBST([REPLACE_POSIX_OPENPT])
   REPLACE_PTSNAME=0;         AC_SUBST([REPLACE_PTSNAME])
   REPLACE_PTSNAME_R=0;       AC_SUBST([REPLACE_PTSNAME_R])
   REPLACE_PUTENV=0;          AC_SUBST([REPLACE_PUTENV])
diff --git a/modules/_Exit b/modules/_Exit
index fa4bde0554..75f0399e88 100644
--- a/modules/_Exit
+++ b/modules/_Exit
@@ -11,7 +11,8 @@ unistd
 
 configure.ac:
 gl_FUNC__EXIT
-gl_CONDITIONAL([GL_COND_OBJ__EXIT], [test $HAVE__EXIT = 0])
+gl_CONDITIONAL([GL_COND_OBJ__EXIT],
+               [test $HAVE__EXIT = 0 || test $REPLACE__EXIT = 1])
 AM_COND_IF([GL_COND_OBJ__EXIT], [
   gl_PREREQ__EXIT
 ])
diff --git a/modules/getprogname b/modules/getprogname
index dadbffbbd6..0631589ee6 100644
--- a/modules/getprogname
+++ b/modules/getprogname
@@ -14,7 +14,8 @@ open            [test $HAVE_GETPROGNAME = 0]
 
 configure.ac:
 gl_FUNC_GETPROGNAME
-gl_CONDITIONAL([GL_COND_OBJ_GETPROGNAME], [test $HAVE_GETPROGNAME = 0])
+gl_CONDITIONAL([GL_COND_OBJ_GETPROGNAME],
+               [test $HAVE_GETPROGNAME = 0 || test $REPLACE_GETPROGNAME = 1])
 AM_COND_IF([GL_COND_OBJ_GETPROGNAME], [
   gl_PREREQ_GETPROGNAME
 ])
diff --git a/modules/posix_openpt b/modules/posix_openpt
index 96a4229879..1b065e10d0 100644
--- a/modules/posix_openpt
+++ b/modules/posix_openpt
@@ -11,7 +11,8 @@ stdlib
 
 configure.ac:
 gl_FUNC_POSIX_OPENPT
-gl_CONDITIONAL([GL_COND_OBJ_POSIX_OPENPT], [test $HAVE_POSIX_OPENPT = 0])
+gl_CONDITIONAL([GL_COND_OBJ_POSIX_OPENPT],
+               [test $HAVE_POSIX_OPENPT = 0 || test $REPLACE_POSIX_OPENPT = 1])
 gl_STDLIB_MODULE_INDICATOR([posix_openpt])
 
 Makefile.am:
diff --git a/modules/stdlib b/modules/stdlib
index 1e6e18f53c..0be8fb54a5 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -128,17 +128,20 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
 	      -e 's|@''HAVE_SYS_LOADAVG_H''@|$(HAVE_SYS_LOADAVG_H)|g' \
 	      -e 's|@''HAVE_UNLOCKPT''@|$(HAVE_UNLOCKPT)|g' \
 	      -e 's|@''HAVE_DECL_UNSETENV''@|$(HAVE_DECL_UNSETENV)|g' \
+	      -e 's|@''REPLACE__EXIT''@|$(REPLACE__EXIT)|g' \
 	      -e 's|@''REPLACE_ALIGNED_ALLOC''@|$(REPLACE_ALIGNED_ALLOC)|g' \
 	      -e 's|@''REPLACE_CALLOC_FOR_CALLOC_GNU''@|$(REPLACE_CALLOC_FOR_CALLOC_GNU)|g' \
 	      -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \
 	      -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
 	      -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
+	      -e 's|@''REPLACE_GETPROGNAME''@|$(REPLACE_GETPROGNAME)|g' \
 	      -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
 	      -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \
 	      -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \
 	      -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
 	      -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
 	      -e 's|@''REPLACE_POSIX_MEMALIGN''@|$(REPLACE_POSIX_MEMALIGN)|g' \
+	      -e 's|@''REPLACE_POSIX_OPENPT''@|$(REPLACE_POSIX_OPENPT)|g' \
 	      -e 's|@''REPLACE_PTSNAME''@|$(REPLACE_PTSNAME)|g' \
 	      -e 's|@''REPLACE_PTSNAME_R''@|$(REPLACE_PTSNAME_R)|g' \
 	      -e 's|@''REPLACE_PUTENV''@|$(REPLACE_PUTENV)|g' \
-- 
2.34.1


[-- Attachment #19: 0018-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 5267 bytes --]

From b6b037e627692b276e22f6c3ca6eabedcc535f70 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 11:51:46 +0100
Subject: [PATCH 18/47] Resolve conflicts for functions introduced in Android
 API level 21.

* lib/string.in.h (stpcpy): Consider REPLACE_STPCPY. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_STPCPY.
* modules/string (Makefile.am): Substitute REPLACE_STPCPY.
* m4/stpcpy.m4 (gl_FUNC_STPCPY): Conditionally set REPLACE_STPCPY.
* modules/stpcpy (configure.ac): Consider REPLACE_STPCPY.
---
 ChangeLog       |  7 +++++++
 lib/string.in.h | 18 ++++++++++++++++--
 m4/stpcpy.m4    |  5 ++++-
 m4/string_h.m4  |  3 ++-
 modules/stpcpy  |  3 ++-
 modules/string  |  1 +
 6 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 80063baa0f..1cf4f77554 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* lib/string.in.h (stpcpy): Consider REPLACE_STPCPY. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_STPCPY.
+	* modules/string (Makefile.am): Substitute REPLACE_STPCPY.
+	* m4/stpcpy.m4 (gl_FUNC_STPCPY): Conditionally set REPLACE_STPCPY.
+	* modules/stpcpy (configure.ac): Consider REPLACE_STPCPY.
+
 	* lib/stdlib.in.h (_Exit): Consider REPLACE__EXIT. Disable
 	_GL_CXXALIASWARN invocation on non-glibc systems.
 	(getprogname): Consider REPLACE_GETPROGNAME. Disable _GL_CXXALIASWARN
diff --git a/lib/string.in.h b/lib/string.in.h
index b227a17887..ffcc7e25c6 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -406,14 +406,28 @@ _GL_WARN_ON_USE (rawmemchr, "rawmemchr is unportable - "
 
 /* Copy SRC to DST, returning the address of the terminating '\0' in DST.  */
 #if @GNULIB_STPCPY@
-# if ! @HAVE_STPCPY@
+# if @REPLACE_STPCPY@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef stpcpy
+#   define stpcpy rpl_stpcpy
+#  endif
+_GL_FUNCDECL_RPL (stpcpy, char *,
+                  (char *restrict __dst, char const *restrict __src)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (stpcpy, char *,
+                  (char *restrict __dst, char const *restrict __src));
+# else
+#  if !@HAVE_STPCPY@
 _GL_FUNCDECL_SYS (stpcpy, char *,
                   (char *restrict __dst, char const *restrict __src)
                   _GL_ARG_NONNULL ((1, 2)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (stpcpy, char *,
                   (char *restrict __dst, char const *restrict __src));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (stpcpy);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef stpcpy
 # if HAVE_RAW_DECL_STPCPY
diff --git a/m4/stpcpy.m4 b/m4/stpcpy.m4
index 462f511d25..f3acbee7be 100644
--- a/m4/stpcpy.m4
+++ b/m4/stpcpy.m4
@@ -1,4 +1,4 @@
-# stpcpy.m4 serial 10
+# stpcpy.m4 serial 11
 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,
@@ -16,6 +16,9 @@ AC_DEFUN([gl_FUNC_STPCPY],
   gl_CHECK_FUNCS_ANDROID([stpcpy], [[#include <string.h>]])
   if test $ac_cv_func_stpcpy = no; then
     HAVE_STPCPY=0
+    case "$gl_cv_onwards_func_stpcpy" in
+      future*) REPLACE_STPCPY=1 ;;
+    esac
   fi
 ])
 
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index 5da3cc2529..132ed87d6a 100644
--- a/m4/string_h.m4
+++ b/m4/string_h.m4
@@ -5,7 +5,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 35
+# serial 36
 
 # Written by Paul Eggert.
 
@@ -131,6 +131,7 @@ AC_DEFUN([gl_STRING_H_DEFAULTS],
   REPLACE_FFSLL=0;              AC_SUBST([REPLACE_FFSLL])
   REPLACE_MEMCHR=0;             AC_SUBST([REPLACE_MEMCHR])
   REPLACE_MEMMEM=0;             AC_SUBST([REPLACE_MEMMEM])
+  REPLACE_STPCPY=0;             AC_SUBST([REPLACE_STPCPY])
   REPLACE_STPNCPY=0;            AC_SUBST([REPLACE_STPNCPY])
   REPLACE_STRCHRNUL=0;          AC_SUBST([REPLACE_STRCHRNUL])
   REPLACE_STRDUP=0;             AC_SUBST([REPLACE_STRDUP])
diff --git a/modules/stpcpy b/modules/stpcpy
index a4aac236a2..66c481d691 100644
--- a/modules/stpcpy
+++ b/modules/stpcpy
@@ -11,7 +11,8 @@ string
 
 configure.ac:
 gl_FUNC_STPCPY
-gl_CONDITIONAL([GL_COND_OBJ_STPCPY], [test $HAVE_STPCPY = 0])
+gl_CONDITIONAL([GL_COND_OBJ_STPCPY],
+               [test $HAVE_STPCPY = 0 || test $REPLACE_STPCPY = 1])
 AM_COND_IF([GL_COND_OBJ_STPCPY], [
   gl_PREREQ_STPCPY
 ])
diff --git a/modules/string b/modules/string
index 70bf2b869f..03a1b0547c 100644
--- a/modules/string
+++ b/modules/string
@@ -109,6 +109,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
 	      -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
 	      -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
+	      -e 's|@''REPLACE_STPCPY''@|$(REPLACE_STPCPY)|g' \
 	      -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
 	      -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \
 	      -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \
-- 
2.34.1


[-- Attachment #20: 0019-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 4549 bytes --]

From 0244a842e9d5c0670c7ff2bc1cf90a23cbc251ab Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 11:55:01 +0100
Subject: [PATCH 19/47] Resolve conflicts for functions introduced in Android
 API level 21.

* lib/unistd.in.h (dup3): Consider REPLACE_DUP3. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_DUP3.
* modules/unistd (Makefile.am): Substitute REPLACE_DUP3.
* m4/dup3.m4 (gl_FUNC_DUP3): Conditionally set REPLACE_DUP3.
---
 ChangeLog       | 6 ++++++
 lib/unistd.in.h | 7 ++++++-
 m4/dup3.m4      | 7 ++++++-
 m4/unistd_h.m4  | 3 ++-
 modules/unistd  | 1 +
 5 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1cf4f77554..22a28b2fd3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* lib/unistd.in.h (dup3): Consider REPLACE_DUP3. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_DUP3.
+	* modules/unistd (Makefile.am): Substitute REPLACE_DUP3.
+	* m4/dup3.m4 (gl_FUNC_DUP3): Conditionally set REPLACE_DUP3.
+
 	* lib/string.in.h (stpcpy): Consider REPLACE_STPCPY. Disable
 	_GL_CXXALIASWARN invocation on non-glibc systems.
 	* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_STPCPY.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index df095ba479..345b73945a 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -541,17 +541,22 @@ _GL_CXXALIASWARN (dup2);
    Return newfd if successful, otherwise -1 and errno set.
    See the Linux man page at
    <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
-# if @HAVE_DUP3@
+# if @REPLACE_DUP3@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef dup3
 #   define dup3 rpl_dup3
 #  endif
 _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
 _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
 # else
+#  if !@HAVE_DUP3@
 _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
+#  endif
 _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (dup3);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef dup3
 # if HAVE_RAW_DECL_DUP3
diff --git a/m4/dup3.m4 b/m4/dup3.m4
index 644a172006..602222e925 100644
--- a/m4/dup3.m4
+++ b/m4/dup3.m4
@@ -1,4 +1,4 @@
-# dup3.m4 serial 6
+# dup3.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,
@@ -15,6 +15,11 @@ AC_DEFUN([gl_FUNC_DUP3],
   gl_CHECK_FUNCS_ANDROID([dup3], [[#include <unistd.h>]])
   if test $ac_cv_func_dup3 != yes; then
     HAVE_DUP3=0
+    case "$gl_cv_onwards_func_dup3" in
+      future*) REPLACE_DUP3=1 ;;
+    esac
+  else
+    REPLACE_DUP3=1
   fi
 
 dnl Not needed yet, because dup3 is unconditionally replaced.
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index c7ef46c26d..8fbd82b2b7 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 91
+# unistd_h.m4 serial 92
 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,
@@ -225,6 +225,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_COPY_FILE_RANGE=0;         AC_SUBST([REPLACE_COPY_FILE_RANGE])
   REPLACE_DUP=0;                     AC_SUBST([REPLACE_DUP])
   REPLACE_DUP2=0;                    AC_SUBST([REPLACE_DUP2])
+  REPLACE_DUP3=0;                    AC_SUBST([REPLACE_DUP3])
   REPLACE_EXECL=0;                   AC_SUBST([REPLACE_EXECL])
   REPLACE_EXECLE=0;                  AC_SUBST([REPLACE_EXECLE])
   REPLACE_EXECLP=0;                  AC_SUBST([REPLACE_EXECLP])
diff --git a/modules/unistd b/modules/unistd
index 80080ede9e..065e4ad52e 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -179,6 +179,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''REPLACE_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \
 	      -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \
 	      -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \
+	      -e 's|@''REPLACE_DUP3''@|$(REPLACE_DUP3)|g' \
 	      -e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \
 	      -e 's|@''REPLACE_EXECLE''@|$(REPLACE_EXECLE)|g' \
 	      -e 's|@''REPLACE_EXECLP''@|$(REPLACE_EXECLP)|g' \
-- 
2.34.1


[-- Attachment #21: 0020-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 4494 bytes --]

From 40135ed721447d3fc5c423d42c47f8aaa65bb8c6 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 12:19:58 +0100
Subject: [PATCH 20/47] Resolve conflicts for functions introduced in Android
 API level 21.

* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Conditionally set
REPLACE_DUPLOCALE.
* m4/localename.m4 (gl_LOCALENAME): Conditionally set REPLACE_NEWLOCALE,
REPLACE_DUPLOCALE, REPLACE_FREELOCALE.
* lib/locale.in.h (newlocale, duplocale, freelocale): Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
---
 ChangeLog        |  7 +++++++
 lib/locale.in.h  |  6 +++---
 m4/duplocale.m4  |  5 ++++-
 m4/localename.m4 | 14 +++++++++++++-
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 22a28b2fd3..a6f1cb08a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Conditionally set
+	REPLACE_DUPLOCALE.
+	* m4/localename.m4 (gl_LOCALENAME): Conditionally set REPLACE_NEWLOCALE,
+	REPLACE_DUPLOCALE, REPLACE_FREELOCALE.
+	* lib/locale.in.h (newlocale, duplocale, freelocale): Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+
 	* lib/unistd.in.h (dup3): Consider REPLACE_DUP3. Disable
 	_GL_CXXALIASWARN invocation on non-glibc systems.
 	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_DUP3.
diff --git a/lib/locale.in.h b/lib/locale.in.h
index 538b83412b..e9c34182e5 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -229,7 +229,7 @@ _GL_CXXALIAS_SYS (newlocale, locale_t,
                   (int category_mask, const char *name, locale_t base));
 #  endif
 # endif
-# if @HAVE_NEWLOCALE@
+# if __GLIBC__ >= 2 && @HAVE_NEWLOCALE@
 _GL_CXXALIASWARN (newlocale);
 # endif
 # if @HAVE_NEWLOCALE@ || @REPLACE_NEWLOCALE@
@@ -258,7 +258,7 @@ _GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale));
 _GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale));
 #  endif
 # endif
-# if @HAVE_DUPLOCALE@
+# if __GLIBC__ >= 2 && @HAVE_DUPLOCALE@
 _GL_CXXALIASWARN (duplocale);
 # endif
 # if @HAVE_DUPLOCALE@ || @REPLACE_DUPLOCALE@
@@ -290,7 +290,7 @@ _GL_CXXALIAS_RPL (freelocale, void, (locale_t locale));
 _GL_CXXALIAS_SYS_CAST (freelocale, void, (locale_t locale));
 #  endif
 # endif
-# if @HAVE_FREELOCALE@
+# if __GLIBC__ >= 2 && @HAVE_FREELOCALE@
 _GL_CXXALIASWARN (freelocale);
 # endif
 #elif defined GNULIB_POSIXCHECK
diff --git a/m4/duplocale.m4 b/m4/duplocale.m4
index 22b4bf80bd..54349e920a 100644
--- a/m4/duplocale.m4
+++ b/m4/duplocale.m4
@@ -1,4 +1,4 @@
-# duplocale.m4 serial 17
+# duplocale.m4 serial 18
 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,
@@ -110,6 +110,9 @@ int main ()
     fi
   else
     HAVE_DUPLOCALE=0
+    case "$gl_cv_onwards_func_duplocale" in
+      future*) REPLACE_DUPLOCALE=1 ;;
+    esac
   fi
   if test $REPLACE_DUPLOCALE = 1; then
     DUPLOCALE_LIB="$SETLOCALE_NULL_LIB"
diff --git a/m4/localename.m4 b/m4/localename.m4
index 43725d8444..8c43a13aa0 100644
--- a/m4/localename.m4
+++ b/m4/localename.m4
@@ -1,4 +1,4 @@
-# localename.m4 serial 9
+# localename.m4 serial 10
 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,
@@ -22,18 +22,30 @@ AC_DEFUN([gl_LOCALENAME],
   else
     dnl In 2019, some versions of z/OS lack the locale_t type and have broken
     dnl newlocale, duplocale, freelocale functions.
+    gl_cv_onwards_func_newlocale='future OS version'
+    gl_cv_onwards_func_duplocale='future OS version'
+    gl_cv_onwards_func_freelocale='future OS version'
     gl_func_newlocale=no
     gl_func_duplocale=no
     gl_func_freelocale=no
   fi
   if test $gl_func_newlocale != yes; then
     HAVE_NEWLOCALE=0
+    case "$gl_cv_onwards_func_newlocale" in
+      future*) REPLACE_NEWLOCALE=1 ;;
+    esac
   fi
   if test $gl_func_duplocale != yes; then
     HAVE_DUPLOCALE=0
+    case "$gl_cv_onwards_func_duplocale" in
+      future*) REPLACE_DUPLOCALE=1 ;;
+    esac
   fi
   if test $gl_func_freelocale != yes; then
     HAVE_FREELOCALE=0
+    case "$gl_cv_onwards_func_freelocale" in
+      future*) REPLACE_FREELOCALE=1 ;;
+    esac
   fi
   if test $gt_localename_enhances_locale_funcs = yes; then
     REPLACE_NEWLOCALE=1
-- 
2.34.1


[-- Attachment #22: 0021-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2246 bytes --]

From 3dfb81922f3c40795b047c4305cfa28cd60c3269 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 12:22:31 +0100
Subject: [PATCH 21/47] Resolve conflicts for functions introduced in Android
 API level 21.

* m4/dprintf.m4 (gl_REPLACE_DPRINTF): Conditionally set REPLACE_DPRINTF.
* lib/stdio.in.h (dprintf): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog      | 4 ++++
 lib/stdio.in.h | 2 ++
 m4/dprintf.m4  | 8 ++++++--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a6f1cb08a0..ea0077fcbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* m4/dprintf.m4 (gl_REPLACE_DPRINTF): Conditionally set REPLACE_DPRINTF.
+	* lib/stdio.in.h (dprintf): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Conditionally set
 	REPLACE_DUPLOCALE.
 	* m4/localename.m4 (gl_LOCALENAME): Conditionally set REPLACE_NEWLOCALE,
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index e3bd60dae1..3f8ea98533 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -210,7 +210,9 @@ _GL_FUNCDECL_SYS (dprintf, int, (int fd, const char *restrict format, ...)
 #  endif
 _GL_CXXALIAS_SYS (dprintf, int, (int fd, const char *restrict format, ...));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (dprintf);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef dprintf
 # if HAVE_RAW_DECL_DPRINTF
diff --git a/m4/dprintf.m4 b/m4/dprintf.m4
index 54c186620b..1ffed0d627 100644
--- a/m4/dprintf.m4
+++ b/m4/dprintf.m4
@@ -1,4 +1,4 @@
-# dprintf.m4 serial 2
+# dprintf.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,
@@ -18,7 +18,11 @@ AC_DEFUN([gl_REPLACE_DPRINTF],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   AC_LIBOBJ([dprintf])
-  if test $ac_cv_func_dprintf = yes; then
+  if test $ac_cv_func_dprintf = yes \
+     || case "$gl_cv_onwards_func_dprintf" in \
+          future*) true ;; \
+          *) false ;; \
+        esac; then
     REPLACE_DPRINTF=1
   fi
   gl_PREREQ_DPRINTF
-- 
2.34.1


[-- Attachment #23: 0022-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 4042 bytes --]

From a26916573e4d78592989c6eecbbe4081d0398d43 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 12:25:06 +0100
Subject: [PATCH 22/47] Resolve conflicts for functions introduced in Android
 API level 21.

* m4/random.m4 (gl_FUNC_RANDOM): Conditionally set REPLACE_INITSTATE,
REPLACE_SETSTATE.
* lib/stdlib.in.h (initstate, setstate): Disable _GL_CXXALIASWARN
invocation on non-glibc systems.
---
 ChangeLog       |  5 +++++
 lib/stdlib.in.h |  4 ++++
 m4/random.m4    | 36 +++++++++++++++++++++++-------------
 3 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ea0077fcbb..3de67682f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* m4/random.m4 (gl_FUNC_RANDOM): Conditionally set REPLACE_INITSTATE,
+	REPLACE_SETSTATE.
+	* lib/stdlib.in.h (initstate, setstate): Disable _GL_CXXALIASWARN
+	invocation on non-glibc systems.
+
 	* m4/dprintf.m4 (gl_REPLACE_DPRINTF): Conditionally set REPLACE_DPRINTF.
 	* lib/stdio.in.h (dprintf): Disable _GL_CXXALIASWARN invocation on
 	non-glibc systems.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 88a8e034a1..c9e2475477 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -1013,7 +1013,9 @@ _GL_FUNCDECL_SYS (initstate, char *,
 _GL_CXXALIAS_SYS_CAST (initstate, char *,
                        (unsigned int seed, char *buf, size_t buf_size));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (initstate);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef initstate
 # if HAVE_RAW_DECL_INITSTATE
@@ -1038,7 +1040,9 @@ _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1)));
    is                                     const char *arg_state.  */
 _GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (setstate);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef setstate
 # if HAVE_RAW_DECL_SETSTATE
diff --git a/m4/random.m4 b/m4/random.m4
index b99603cf9a..b0d1cb86ee 100644
--- a/m4/random.m4
+++ b/m4/random.m4
@@ -1,4 +1,4 @@
-# random.m4 serial 5
+# random.m4 serial 6
 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,
@@ -19,29 +19,39 @@ AC_DEFUN([gl_FUNC_RANDOM],
        [gl_cv_func_random=yes],
        [gl_cv_func_random=no])
     ])
+  gl_CHECK_FUNCS_ANDROID([initstate], [[#include <stdlib.h>]])
+  gl_CHECK_FUNCS_ANDROID([setstate], [[#include <stdlib.h>]])
   if test $gl_cv_func_random = no; then
     HAVE_RANDOM=0
     HAVE_INITSTATE=0
     HAVE_SETSTATE=0
   else
-    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
     if test $ac_cv_func_setstate = no; then
       HAVE_SETSTATE=0
     fi
-    if test $ac_cv_func_initstate = no || test $ac_cv_func_setstate = no; then
-      dnl In order to define initstate or setstate, we need to define all the
-      dnl functions at once.
-      REPLACE_RANDOM=1
-      if test $ac_cv_func_initstate = yes; then
-        REPLACE_INITSTATE=1
-      fi
-      if test $ac_cv_func_setstate = yes; then
-        REPLACE_SETSTATE=1
-      fi
+  fi
+  if test $HAVE_INITSTATE = 0; then
+    case "$gl_cv_onwards_func_initstate" in
+      future*) REPLACE_INITSTATE=1 ;;
+    esac
+  fi
+  if test $HAVE_SETSTATE = 0; then
+    case "$gl_cv_onwards_func_setstate" in
+      future*) REPLACE_SETSTATE=1 ;;
+    esac
+  fi
+  if test $ac_cv_func_initstate = no || test $ac_cv_func_setstate = no; then
+    dnl In order to define initstate or setstate, we need to define all the
+    dnl functions at once.
+    REPLACE_RANDOM=1
+    if test $ac_cv_func_initstate = yes; then
+      REPLACE_INITSTATE=1
+    fi
+    if test $ac_cv_func_setstate = yes; then
+      REPLACE_SETSTATE=1
     fi
   fi
 
-- 
2.34.1


[-- Attachment #24: 0023-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 1993 bytes --]

From 5ca443e0b95097f86c466efe051221851c1bc84f Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 12:27:03 +0100
Subject: [PATCH 23/47] Resolve conflicts for functions introduced in Android
 API level 21.

* m4/stpncpy.m4 (gl_FUNC_STPNCPY): Conditionally set REPLACE_STPNCPY.
* lib/string.in.h (stpncpy): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog       | 4 ++++
 lib/string.in.h | 2 ++
 m4/stpncpy.m4   | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 3de67682f1..092a3b50d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* m4/stpncpy.m4 (gl_FUNC_STPNCPY): Conditionally set REPLACE_STPNCPY.
+	* lib/string.in.h (stpncpy): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/random.m4 (gl_FUNC_RANDOM): Conditionally set REPLACE_INITSTATE,
 	REPLACE_SETSTATE.
 	* lib/stdlib.in.h (initstate, setstate): Disable _GL_CXXALIASWARN
diff --git a/lib/string.in.h b/lib/string.in.h
index ffcc7e25c6..7d0104ce55 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -462,7 +462,9 @@ _GL_CXXALIAS_SYS (stpncpy, char *,
                   (char *restrict __dst, char const *restrict __src,
                    size_t __n));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (stpncpy);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef stpncpy
 # if HAVE_RAW_DECL_STPNCPY
diff --git a/m4/stpncpy.m4 b/m4/stpncpy.m4
index c321093b66..b9850364ed 100644
--- a/m4/stpncpy.m4
+++ b/m4/stpncpy.m4
@@ -1,4 +1,4 @@
-# stpncpy.m4 serial 20
+# stpncpy.m4 serial 21
 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2023 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -96,6 +96,9 @@ int main ()
     esac
   else
     HAVE_STPNCPY=0
+    case "$gl_cv_onwards_func_stpncpy" in
+      future*) REPLACE_STPNCPY=1 ;;
+    esac
   fi
 ])
 
-- 
2.34.1


[-- Attachment #25: 0024-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2038 bytes --]

From 09730bf22348989d457861b85ffab15eb0f294cb Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 12:30:17 +0100
Subject: [PATCH 24/47] Resolve conflicts for functions introduced in Android
 API level 21.

* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Conditionally set REPLACE_MKNODAT.
* lib/sys_stat.in.h (mknodat): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog         | 4 ++++
 lib/sys_stat.in.h | 2 ++
 m4/mkfifoat.m4    | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 092a3b50d5..33b820b888 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Conditionally set REPLACE_MKNODAT.
+	* lib/sys_stat.in.h (mknodat): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/stpncpy.m4 (gl_FUNC_STPNCPY): Conditionally set REPLACE_STPNCPY.
 	* lib/string.in.h (stpncpy): Disable _GL_CXXALIASWARN invocation on
 	non-glibc systems.
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 7d92239dd1..4ebe121a31 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -773,7 +773,9 @@ _GL_FUNCDECL_SYS (mknodat, int,
 _GL_CXXALIAS_SYS (mknodat, int,
                   (int fd, char const *file, mode_t mode, dev_t dev));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (mknodat);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef mknodat
 # if HAVE_RAW_DECL_MKNODAT
diff --git a/m4/mkfifoat.m4 b/m4/mkfifoat.m4
index e9ed962415..d7311f2557 100644
--- a/m4/mkfifoat.m4
+++ b/m4/mkfifoat.m4
@@ -1,4 +1,4 @@
-# serial 7
+# serial 8
 # See if we need to provide mkfifoat/mknodat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -63,5 +63,8 @@ AC_DEFUN([gl_FUNC_MKFIFOAT],
     # No known system has mkfifoat but not mknodat
     HAVE_MKFIFOAT=0
     HAVE_MKNODAT=0
+    case "$gl_cv_onwards_func_mknodat" in
+      future*) REPLACE_MKNODAT=1 ;;
+    esac
   fi
 ])
-- 
2.34.1


[-- Attachment #26: 0025-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 6984 bytes --]

From 959415ca4a76b25f254082716a8222f6be140955 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 12:34:17 +0100
Subject: [PATCH 25/47] Resolve conflicts for functions introduced in Android
 API level 21.

* m4/execvpe.m4 (gl_FUNC_EXECVPE): Conditionally set REPLACE_EXECVPE.
* m4/linkat.m4 (gl_FUNC_LINKAT): Conditionally set REPLACE_LINKAT.
* m4/readlinkat.m4 (gl_FUNC_READLINKAT): Conditionally set
REPLACE_READLINKAT.
* m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Conditionally set
REPLACE_SYMLINKAT.
* m4/truncate.m4 (gl_FUNC_TRUNCATE): Conditionally set REPLACE_TRUNCATE.
* lib/unistd.in.h (execvpe, linkat, readlinkat, symlinkat, truncate):
Disable _GL_CXXALIASWARN invocation on non-glibc systems.
---
 ChangeLog        | 10 ++++++++++
 lib/unistd.in.h  | 10 ++++++++++
 m4/execvpe.m4    |  5 ++++-
 m4/linkat.m4     |  5 ++++-
 m4/readlinkat.m4 |  5 ++++-
 m4/symlinkat.m4  |  5 ++++-
 m4/truncate.m4   |  8 ++++----
 7 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 33b820b888..5479a8685e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,16 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* m4/execvpe.m4 (gl_FUNC_EXECVPE): Conditionally set REPLACE_EXECVPE.
+	* m4/linkat.m4 (gl_FUNC_LINKAT): Conditionally set REPLACE_LINKAT.
+	* m4/readlinkat.m4 (gl_FUNC_READLINKAT): Conditionally set
+	REPLACE_READLINKAT.
+	* m4/symlinkat.m4 (gl_FUNC_SYMLINKAT): Conditionally set
+	REPLACE_SYMLINKAT.
+	* m4/truncate.m4 (gl_FUNC_TRUNCATE): Conditionally set REPLACE_TRUNCATE.
+	* lib/unistd.in.h (execvpe, linkat, readlinkat, symlinkat, truncate):
+	Disable _GL_CXXALIASWARN invocation on non-glibc systems.
+
 	* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Conditionally set REPLACE_MKNODAT.
 	* lib/sys_stat.in.h (mknodat): Disable _GL_CXXALIASWARN invocation on
 	non-glibc systems.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 345b73945a..2a6d4ce743 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -875,7 +875,9 @@ _GL_FUNCDECL_SYS (execvpe, int,
 _GL_CXXALIAS_SYS (execvpe, int,
                   (const char *program, char * const *argv, char * const *env));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (execvpe);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef execvpe
 # if HAVE_RAW_DECL_EXECVPE
@@ -1681,7 +1683,9 @@ _GL_CXXALIAS_SYS (linkat, int,
                   (int fd1, const char *path1, int fd2, const char *path2,
                    int flag));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (linkat);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef linkat
 # if HAVE_RAW_DECL_LINKAT
@@ -1963,7 +1967,9 @@ _GL_CXXALIAS_SYS (readlinkat, ssize_t,
                   (int fd, char const *restrict file,
                    char *restrict buf, size_t len));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (readlinkat);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef readlinkat
 # if HAVE_RAW_DECL_READLINKAT
@@ -2140,7 +2146,9 @@ _GL_FUNCDECL_SYS (symlinkat, int,
 _GL_CXXALIAS_SYS (symlinkat, int,
                   (char const *contents, int fd, char const *file));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (symlinkat);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef symlinkat
 # if HAVE_RAW_DECL_SYMLINKAT
@@ -2170,7 +2178,9 @@ _GL_FUNCDECL_SYS (truncate, int, (const char *filename, off_t length)
 #  endif
 _GL_CXXALIAS_SYS (truncate, int, (const char *filename, off_t length));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (truncate);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef truncate
 # if HAVE_RAW_DECL_TRUNCATE
diff --git a/m4/execvpe.m4 b/m4/execvpe.m4
index 6c0a0e9b7d..3f211049b8 100644
--- a/m4/execvpe.m4
+++ b/m4/execvpe.m4
@@ -1,4 +1,4 @@
-# execvpe.m4 serial 2
+# execvpe.m4 serial 3
 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,
@@ -18,6 +18,9 @@ AC_DEFUN([gl_FUNC_EXECVPE],
       gl_CHECK_FUNCS_ANDROID([execvpe], [[#include <unistd.h>]])
       if test $ac_cv_func_execvpe != yes; then
         HAVE_EXECVPE=0
+        case "$gl_cv_onwards_func_execvpe" in
+          future*) REPLACE_EXECVPE=1 ;;
+        esac
       fi
       ;;
   esac
diff --git a/m4/linkat.m4 b/m4/linkat.m4
index 9b35fc14e3..032e89bb54 100644
--- a/m4/linkat.m4
+++ b/m4/linkat.m4
@@ -1,4 +1,4 @@
-# serial 15
+# serial 16
 # See if we need to provide linkat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -19,6 +19,9 @@ AC_DEFUN([gl_FUNC_LINKAT],
   gl_CHECK_FUNCS_ANDROID([linkat], [[#include <unistd.h>]])
   if test $ac_cv_func_linkat = no; then
     HAVE_LINKAT=0
+    case "$gl_cv_onwards_func_linkat" in
+      future*) REPLACE_LINKAT=1 ;;
+    esac
   else
     dnl OS X Yosemite has linkat() but it's not sufficient
     dnl to our needs since it doesn't support creating
diff --git a/m4/readlinkat.m4 b/m4/readlinkat.m4
index 416f9c0d64..5c51356291 100644
--- a/m4/readlinkat.m4
+++ b/m4/readlinkat.m4
@@ -1,4 +1,4 @@
-# serial 7
+# serial 8
 # See if we need to provide readlinkat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -16,6 +16,9 @@ AC_DEFUN([gl_FUNC_READLINKAT],
   AC_REQUIRE([gl_FUNC_READLINK])
   if test $ac_cv_func_readlinkat = no; then
     HAVE_READLINKAT=0
+    case "$gl_cv_onwards_func_readlinkat" in
+      future*) REPLACE_READLINKAT=1 ;;
+    esac
   else
     AC_CACHE_CHECK([whether readlinkat signature is correct],
       [gl_cv_decl_readlinkat_works],
diff --git a/m4/symlinkat.m4 b/m4/symlinkat.m4
index d12f91997c..dc3dd323aa 100644
--- a/m4/symlinkat.m4
+++ b/m4/symlinkat.m4
@@ -1,4 +1,4 @@
-# serial 11
+# serial 12
 # See if we need to provide symlinkat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -17,6 +17,9 @@ AC_DEFUN([gl_FUNC_SYMLINKAT],
   gl_CHECK_FUNCS_ANDROID([symlinkat], [[#include <unistd.h>]])
   if test $ac_cv_func_symlinkat = no; then
     HAVE_SYMLINKAT=0
+    case "$gl_cv_onwards_func_symlinkat" in
+      future*) REPLACE_SYMLINKAT=1 ;;
+    esac
   else
     AC_CACHE_CHECK([whether symlinkat handles trailing slash correctly],
       [gl_cv_func_symlinkat_works],
diff --git a/m4/truncate.m4 b/m4/truncate.m4
index b047af34c9..fe9fdbf408 100644
--- a/m4/truncate.m4
+++ b/m4/truncate.m4
@@ -1,4 +1,4 @@
-# truncate.m4 serial 4   -*- Autoconf -*-
+# truncate.m4 serial 5   -*- 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,
@@ -71,10 +71,10 @@ AC_DEFUN([gl_FUNC_TRUNCATE],
     fi
   else
     HAVE_DECL_TRUNCATE=0
-    if test $ac_cv_func_truncate = yes; then
+    case "$gl_cv_onwards_func_truncate" in
       dnl Avoid a conflict with the 'truncate' in libc.
-      REPLACE_TRUNCATE=1
-    fi
+      yes | future*) REPLACE_TRUNCATE=1 ;;
+    esac
   fi
 ])
 
-- 
2.34.1


[-- Attachment #27: 0027-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 5528 bytes --]

From facb752a0f9b4d609d678791a7a9aecb580ff6e2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 12:41:14 +0100
Subject: [PATCH 27/47] Resolve conflicts for functions introduced in Android
 API level 21.

* m4/fts.m4 (gl_FUNC_FTS_CORE): Use rpl_* symbols also when the system
will have fts_open in a future version.
* m4/iswblank.m4 (gl_FUNC_ISWBLANK): Conditionally set REPLACE_ISWBLANK.
* m4/mbtowc.m4 (gl_FUNC_MBTOWC): Conditionally set REPLACE_MBTOWC.
* m4/vdprintf.m4 (gl_REPLACE_VDPRINTF): Conditionally set
REPLACE_VDPRINTF.
* m4/wcsnrtombs.m4 (gl_FUNC_WCSNRTOMBS): Conditionally set
REPLACE_WCSNRTOMBS.
---
 ChangeLog        |  9 +++++++++
 m4/fts.m4        | 10 +++++++---
 m4/iswblank.m4   |  8 ++++++--
 m4/mbtowc.m4     |  5 ++++-
 m4/vdprintf.m4   |  8 ++++++--
 m4/wcsnrtombs.m4 |  5 ++++-
 6 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f8a57d2d70..c00928615f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,15 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* m4/fts.m4 (gl_FUNC_FTS_CORE): Use rpl_* symbols also when the system
+	will have fts_open in a future version.
+	* m4/iswblank.m4 (gl_FUNC_ISWBLANK): Conditionally set REPLACE_ISWBLANK.
+	* m4/mbtowc.m4 (gl_FUNC_MBTOWC): Conditionally set REPLACE_MBTOWC.
+	* m4/vdprintf.m4 (gl_REPLACE_VDPRINTF): Conditionally set
+	REPLACE_VDPRINTF.
+	* m4/wcsnrtombs.m4 (gl_FUNC_WCSNRTOMBS): Conditionally set
+	REPLACE_WCSNRTOMBS.
+
 	* m4/mbsnrtowcs.m4 (gl_FUNC_MBSNRTOWCS): Conditionally set
 	REPLACE_MBSNRTOWCS.
 	* lib/wchar.in.h (mbsnrtowcs): Disable _GL_CXXALIASWARN invocation on
diff --git a/m4/fts.m4 b/m4/fts.m4
index eec034287c..6f521f5141 100644
--- a/m4/fts.m4
+++ b/m4/fts.m4
@@ -1,4 +1,4 @@
-#serial 23
+#serial 24
 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,
@@ -30,8 +30,12 @@ AC_DEFUN([gl_FUNC_FTS_CORE],
   fi
 
   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.
+  if case "$gl_cv_onwards_func_fts_open" in \
+       yes | future*) true ;; \
+       *) false ;; \
+     esac; then
+    dnl The system already has the symbols fts_open, etc. or will have them
+    dnl in a future version.
     dnl Avoid conflicts between these symbols and ours at the linker level.
     AC_DEFINE([fts_open], [rpl_fts_open],
       [Define to the overridden function name])
diff --git a/m4/iswblank.m4 b/m4/iswblank.m4
index f3f96bb784..b1220b1e93 100644
--- a/m4/iswblank.m4
+++ b/m4/iswblank.m4
@@ -1,4 +1,4 @@
-# iswblank.m4 serial 6
+# iswblank.m4 serial 7
 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,
@@ -17,7 +17,11 @@ AC_DEFUN([gl_FUNC_ISWBLANK],
   ]])
   if test $ac_cv_func_iswblank = no; then
     HAVE_ISWBLANK=0
-    if test $ac_cv_have_decl_iswblank = yes; then
+    if test $ac_cv_have_decl_iswblank = yes \
+       || case "$gl_cv_onwards_func_iswblank" in \
+            future*) true ;; \
+            *) false ;; \
+          esac; then
       REPLACE_ISWBLANK=1
     fi
   fi
diff --git a/m4/mbtowc.m4 b/m4/mbtowc.m4
index 88eb39a6de..02ed6ebb33 100644
--- a/m4/mbtowc.m4
+++ b/m4/mbtowc.m4
@@ -1,4 +1,4 @@
-# mbtowc.m4 serial 4
+# mbtowc.m4 serial 5
 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,6 +11,9 @@ AC_DEFUN([gl_FUNC_MBTOWC],
   gl_CHECK_FUNCS_ANDROID([mbtowc], [[#include <stdlib.h>]])
   if test $ac_cv_func_mbtowc = no; then
     HAVE_MBTOWC=0
+    case "$gl_cv_onwards_func_mbtowc" in
+      future*) REPLACE_MBTOWC=1 ;;
+    esac
   else
     if false; then
       REPLACE_MBTOWC=1
diff --git a/m4/vdprintf.m4 b/m4/vdprintf.m4
index 1420efdb51..1df2bc1505 100644
--- a/m4/vdprintf.m4
+++ b/m4/vdprintf.m4
@@ -1,4 +1,4 @@
-# vdprintf.m4 serial 2
+# vdprintf.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,
@@ -18,7 +18,11 @@ AC_DEFUN([gl_REPLACE_VDPRINTF],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   AC_LIBOBJ([vdprintf])
-  if test $ac_cv_func_vdprintf = yes; then
+  if test $ac_cv_func_vdprintf = yes \
+     || case "$gl_cv_onwards_func_vdprintf" in \
+          future*) true ;; \
+          *) false ;; \
+        esac; then
     REPLACE_VDPRINTF=1
   fi
   gl_PREREQ_VDPRINTF
diff --git a/m4/wcsnrtombs.m4 b/m4/wcsnrtombs.m4
index af6d26c78d..ab22f6cd63 100644
--- a/m4/wcsnrtombs.m4
+++ b/m4/wcsnrtombs.m4
@@ -1,4 +1,4 @@
-# wcsnrtombs.m4 serial 8
+# wcsnrtombs.m4 serial 9
 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,
@@ -14,6 +14,9 @@ AC_DEFUN([gl_FUNC_WCSNRTOMBS],
   gl_CHECK_FUNCS_ANDROID([wcsnrtombs], [[#include <wchar.h>]])
   if test $ac_cv_func_wcsnrtombs = no; then
     HAVE_WCSNRTOMBS=0
+    case "$gl_cv_onwards_func_wcsnrtombs" in
+      future*) REPLACE_WCSNRTOMBS=1 ;;
+    esac
   else
     if test $REPLACE_MBSTATE_T = 1; then
       REPLACE_WCSNRTOMBS=1
-- 
2.34.1


[-- Attachment #28: 0026-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2330 bytes --]

From 639d41bfee3a281ba226188cbc3255f642cf41a0 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 12:36:45 +0100
Subject: [PATCH 26/47] Resolve conflicts for functions introduced in Android
 API level 21.

* m4/mbsnrtowcs.m4 (gl_FUNC_MBSNRTOWCS): Conditionally set
REPLACE_MBSNRTOWCS.
* lib/wchar.in.h (mbsnrtowcs): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog        | 5 +++++
 lib/wchar.in.h   | 2 ++
 m4/mbsnrtowcs.m4 | 5 ++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 5479a8685e..f8a57d2d70 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
 	Resolve conflicts for functions introduced in Android API level 21.
 
+	* m4/mbsnrtowcs.m4 (gl_FUNC_MBSNRTOWCS): Conditionally set
+	REPLACE_MBSNRTOWCS.
+	* lib/wchar.in.h (mbsnrtowcs): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/execvpe.m4 (gl_FUNC_EXECVPE): Conditionally set REPLACE_EXECVPE.
 	* m4/linkat.m4 (gl_FUNC_LINKAT): Conditionally set REPLACE_LINKAT.
 	* m4/readlinkat.m4 (gl_FUNC_READLINKAT): Conditionally set
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index 09c9185f62..354709db52 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -441,7 +441,9 @@ _GL_CXXALIAS_SYS (mbsnrtowcs, size_t,
                    const char **restrict srcp, size_t srclen, size_t len,
                    mbstate_t *restrict ps));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (mbsnrtowcs);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef mbsnrtowcs
 # if HAVE_RAW_DECL_MBSNRTOWCS
diff --git a/m4/mbsnrtowcs.m4 b/m4/mbsnrtowcs.m4
index 1b398c7ca7..34dcf30e63 100644
--- a/m4/mbsnrtowcs.m4
+++ b/m4/mbsnrtowcs.m4
@@ -1,4 +1,4 @@
-# mbsnrtowcs.m4 serial 7
+# mbsnrtowcs.m4 serial 8
 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,
@@ -17,6 +17,9 @@ AC_DEFUN([gl_FUNC_MBSNRTOWCS],
   gl_CHECK_FUNCS_ANDROID([mbsnrtowcs], [[#include <wchar.h>]])
   if test $ac_cv_func_mbsnrtowcs = no; then
     HAVE_MBSNRTOWCS=0
+    case "$gl_cv_onwards_func_mbsnrtowcs" in
+      future*) REPLACE_MBSNRTOWCS=1 ;;
+    esac
   else
     if test $REPLACE_MBSTATE_T = 1; then
       REPLACE_MBSNRTOWCS=1
-- 
2.34.1


[-- Attachment #29: 0028-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 8764 bytes --]

From 6f43ec52f0b6c548a974ec46244292106fc48bfe Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 12:43:06 +0100
Subject: [PATCH 28/47] Resolve conflicts for functions introduced in Android
 API level 23.

* lib/stdlib.in.h (mkostemp): Consider REPLACE_MKOSTEMP. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
(mkostemps): Consider REPLACE_MKOSTEMPS. Disable _GL_CXXALIASWARN
invocation on non-glibc systems.
* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_MKOSTEMP,
REPLACE_MKOSTEMPS.
* modules/stdlib (Makefile.am): Substitute REPLACE_MKOSTEMP,
REPLACE_MKOSTEMPS.
* m4/mkostemp.m4 (gl_FUNC_MKOSTEMP): Conditionally set REPLACE_MKOSTEMP.
* modules/mkostemp (Depends-on, configure.ac): Consider
REPLACE_MKOSTEMP.
* m4/mkostemps.m4 (gl_FUNC_MKOSTEMPS): Conditionally set
REPLACE_MKOSTEMPS.
* modules/mkostemps (Depends-on, configure.ac): Consider
REPLACE_MKOSTEMPS.
---
 ChangeLog         | 20 ++++++++++++++++++++
 lib/stdlib.in.h   | 34 ++++++++++++++++++++++++++++++----
 m4/mkostemp.m4    |  5 ++++-
 m4/mkostemps.m4   |  5 ++++-
 m4/stdlib_h.m4    |  4 +++-
 modules/mkostemp  |  5 +++--
 modules/mkostemps |  5 +++--
 modules/stdlib    |  2 ++
 8 files changed, 69 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c00928615f..8c6d6dcf6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 23.
+
+	* lib/stdlib.in.h (mkostemp): Consider REPLACE_MKOSTEMP. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	(mkostemps): Consider REPLACE_MKOSTEMPS. Disable _GL_CXXALIASWARN
+	invocation on non-glibc systems.
+	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_MKOSTEMP,
+	REPLACE_MKOSTEMPS.
+	* modules/stdlib (Makefile.am): Substitute REPLACE_MKOSTEMP,
+	REPLACE_MKOSTEMPS.
+	* m4/mkostemp.m4 (gl_FUNC_MKOSTEMP): Conditionally set REPLACE_MKOSTEMP.
+	* modules/mkostemp (Depends-on, configure.ac): Consider
+	REPLACE_MKOSTEMP.
+	* m4/mkostemps.m4 (gl_FUNC_MKOSTEMPS): Conditionally set
+	REPLACE_MKOSTEMPS.
+	* modules/mkostemps (Depends-on, configure.ac): Consider
+	REPLACE_MKOSTEMPS.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 21.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index c9e2475477..95e0b847b9 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -625,12 +625,24 @@ _GL_WARN_ON_USE (mkdtemp, "mkdtemp is unportable - "
    implementation.
    Returns the open file descriptor if successful, otherwise -1 and errno
    set.  */
-# if !@HAVE_MKOSTEMP@
+# if @REPLACE_MKOSTEMP@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mkostemp
+#   define mkostemp rpl_mkostemp
+#  endif
+_GL_FUNCDECL_RPL (mkostemp, int, (char * /*template*/, int /*flags*/)
+                                 _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkostemp, int, (char * /*template*/, int /*flags*/));
+# else
+#  if !@HAVE_MKOSTEMP@
 _GL_FUNCDECL_SYS (mkostemp, int, (char * /*template*/, int /*flags*/)
                                  _GL_ARG_NONNULL ((1)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (mkostemp, int, (char * /*template*/, int /*flags*/));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (mkostemp);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef mkostemp
 # if HAVE_RAW_DECL_MKOSTEMP
@@ -653,14 +665,28 @@ _GL_WARN_ON_USE (mkostemp, "mkostemp is unportable - "
    implementation.
    Returns the open file descriptor if successful, otherwise -1 and errno
    set.  */
-# if !@HAVE_MKOSTEMPS@
+# if @REPLACE_MKOSTEMPS@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mkostemps
+#   define mkostemps rpl_mkostemps
+#  endif
+_GL_FUNCDECL_RPL (mkostemps, int,
+                  (char * /*template*/, int /*suffixlen*/, int /*flags*/)
+                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (mkostemps, int,
+                  (char * /*template*/, int /*suffixlen*/, int /*flags*/));
+# else
+#  if !@HAVE_MKOSTEMPS@
 _GL_FUNCDECL_SYS (mkostemps, int,
                   (char * /*template*/, int /*suffixlen*/, int /*flags*/)
                   _GL_ARG_NONNULL ((1)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (mkostemps, int,
                   (char * /*template*/, int /*suffixlen*/, int /*flags*/));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (mkostemps);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef mkostemps
 # if HAVE_RAW_DECL_MKOSTEMPS
diff --git a/m4/mkostemp.m4 b/m4/mkostemp.m4
index 9424f85f43..1b0d0d5594 100644
--- a/m4/mkostemp.m4
+++ b/m4/mkostemp.m4
@@ -1,4 +1,4 @@
-# mkostemp.m4 serial 3
+# mkostemp.m4 serial 4
 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,
@@ -14,6 +14,9 @@ AC_DEFUN([gl_FUNC_MKOSTEMP],
   gl_CHECK_FUNCS_ANDROID([mkostemp], [[#include <stdlib.h>]])
   if test $ac_cv_func_mkostemp != yes; then
     HAVE_MKOSTEMP=0
+    case "$gl_cv_onwards_func_mkostemp" in
+      future*) REPLACE_MKOSTEMP=1 ;;
+    esac
   fi
 ])
 
diff --git a/m4/mkostemps.m4 b/m4/mkostemps.m4
index fdf6971496..2ce47d130f 100644
--- a/m4/mkostemps.m4
+++ b/m4/mkostemps.m4
@@ -1,4 +1,4 @@
-# mkostemps.m4 serial 3
+# mkostemps.m4 serial 4
 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,
@@ -14,5 +14,8 @@ AC_DEFUN([gl_FUNC_MKOSTEMPS],
   gl_CHECK_FUNCS_ANDROID([mkostemps], [[#include <stdlib.h>]])
   if test $ac_cv_func_mkostemps != yes; then
     HAVE_MKOSTEMPS=0
+    case "$gl_cv_onwards_func_mkostemps" in
+      future*) REPLACE_MKOSTEMPS=1 ;;
+    esac
   fi
 ])
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index f1360a457b..525cd5ba78 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 68
+# stdlib_h.m4 serial 69
 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,
@@ -179,6 +179,8 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   REPLACE_MALLOC_FOR_MALLOC_GNU=0;    AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU])
   REPLACE_MALLOC_FOR_MALLOC_POSIX=0;  AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX])
   REPLACE_MBTOWC=0;          AC_SUBST([REPLACE_MBTOWC])
+  REPLACE_MKOSTEMP=0;        AC_SUBST([REPLACE_MKOSTEMP])
+  REPLACE_MKOSTEMPS=0;       AC_SUBST([REPLACE_MKOSTEMPS])
   REPLACE_MKSTEMP=0;         AC_SUBST([REPLACE_MKSTEMP])
   REPLACE_POSIX_MEMALIGN=0;  AC_SUBST([REPLACE_POSIX_MEMALIGN])
   REPLACE_POSIX_OPENPT=0;    AC_SUBST([REPLACE_POSIX_OPENPT])
diff --git a/modules/mkostemp b/modules/mkostemp
index 467fb109ae..a47353d427 100644
--- a/modules/mkostemp
+++ b/modules/mkostemp
@@ -10,11 +10,12 @@ Depends-on:
 stdlib
 extensions
 largefile
-tempname        [test $HAVE_MKOSTEMP = 0]
+tempname        [test $HAVE_MKOSTEMP = 0 || test $REPLACE_MKOSTEMP = 1]
 
 configure.ac:
 gl_FUNC_MKOSTEMP
-gl_CONDITIONAL([GL_COND_OBJ_MKOSTEMP], [test $HAVE_MKOSTEMP = 0])
+gl_CONDITIONAL([GL_COND_OBJ_MKOSTEMP],
+               [test $HAVE_MKOSTEMP = 0 || test $REPLACE_MKOSTEMP = 1])
 AM_COND_IF([GL_COND_OBJ_MKOSTEMP], [
   gl_PREREQ_MKOSTEMP
 ])
diff --git a/modules/mkostemps b/modules/mkostemps
index 92ef9ea29e..3bcb438860 100644
--- a/modules/mkostemps
+++ b/modules/mkostemps
@@ -10,11 +10,12 @@ Depends-on:
 stdlib
 extensions
 largefile
-tempname        [test $HAVE_MKOSTEMPS = 0]
+tempname        [test $HAVE_MKOSTEMPS = 0 || test $REPLACE_MKOSTEMPS = 1]
 
 configure.ac:
 gl_FUNC_MKOSTEMPS
-gl_CONDITIONAL([GL_COND_OBJ_MKOSTEMPS], [test $HAVE_MKOSTEMPS = 0])
+gl_CONDITIONAL([GL_COND_OBJ_MKOSTEMPS],
+               [test $HAVE_MKOSTEMPS = 0 || test $REPLACE_MKOSTEMPS = 1])
 gl_MODULE_INDICATOR([mkostemps])
 gl_STDLIB_MODULE_INDICATOR([mkostemps])
 
diff --git a/modules/stdlib b/modules/stdlib
index 0be8fb54a5..57f1e40269 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -139,6 +139,8 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
 	      -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \
 	      -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \
 	      -e 's|@''REPLACE_MBTOWC''@|$(REPLACE_MBTOWC)|g' \
+	      -e 's|@''REPLACE_MKOSTEMP''@|$(REPLACE_MKOSTEMP)|g' \
+	      -e 's|@''REPLACE_MKOSTEMPS''@|$(REPLACE_MKOSTEMPS)|g' \
 	      -e 's|@''REPLACE_MKSTEMP''@|$(REPLACE_MKSTEMP)|g' \
 	      -e 's|@''REPLACE_POSIX_MEMALIGN''@|$(REPLACE_POSIX_MEMALIGN)|g' \
 	      -e 's|@''REPLACE_POSIX_OPENPT''@|$(REPLACE_POSIX_OPENPT)|g' \
-- 
2.34.1


[-- Attachment #30: 0029-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 5433 bytes --]

From 9746be9cd8ccaebc0e1052c19da8d5644766caad Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 13:01:14 +0100
Subject: [PATCH 29/47] Resolve conflicts for functions introduced in Android
 API level 23.

* lib/string.in.h (mempcpy): Consider REPLACE_MEMPCPY. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_MEMPCPY.
* modules/string (Makefile.am): Substitute REPLACE_MEMPCPY.
* m4/mempcpy.m4 (gl_FUNC_STPCPY): Conditionally set REPLACE_MEMPCPY.
* modules/mempcpy (configure.ac): Consider REPLACE_MEMPCPY.
---
 ChangeLog       |  7 +++++++
 lib/string.in.h | 20 ++++++++++++++++++--
 m4/mempcpy.m4   |  5 ++++-
 m4/string_h.m4  |  3 ++-
 modules/mempcpy |  3 ++-
 modules/string  |  1 +
 6 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8c6d6dcf6a..3accc92f95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
 
 	Resolve conflicts for functions introduced in Android API level 23.
 
+	* lib/string.in.h (mempcpy): Consider REPLACE_MEMPCPY. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_MEMPCPY.
+	* modules/string (Makefile.am): Substitute REPLACE_MEMPCPY.
+	* m4/mempcpy.m4 (gl_FUNC_MEMPCPY): Conditionally set REPLACE_MEMPCPY.
+	* modules/mempcpy (configure.ac): Consider REPLACE_MEMPCPY.
+
 	* lib/stdlib.in.h (mkostemp): Consider REPLACE_MKOSTEMP. Disable
 	_GL_CXXALIASWARN invocation on non-glibc systems.
 	(mkostemps): Consider REPLACE_MKOSTEMPS. Disable _GL_CXXALIASWARN
diff --git a/lib/string.in.h b/lib/string.in.h
index 7d0104ce55..2e078aff47 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -308,16 +308,32 @@ _GL_WARN_ON_USE (memmem, "memmem is unportable and often quadratic - "
 /* Copy N bytes of SRC to DEST, return pointer to bytes after the
    last written byte.  */
 #if @GNULIB_MEMPCPY@
-# if ! @HAVE_MEMPCPY@
+# if @REPLACE_MEMPCPY@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef mempcpy
+#   define mempcpy rpl_mempcpy
+#  endif
+_GL_FUNCDECL_RPL (mempcpy, void *,
+                  (void *restrict __dest, void const *restrict __src,
+                   size_t __n)
+                  _GL_ARG_NONNULL ((1, 2)));
+_GL_CXXALIAS_RPL (mempcpy, void *,
+                  (void *restrict __dest, void const *restrict __src,
+                   size_t __n));
+# else
+#  if !@HAVE_MEMPCPY@
 _GL_FUNCDECL_SYS (mempcpy, void *,
                   (void *restrict __dest, void const *restrict __src,
                    size_t __n)
                   _GL_ARG_NONNULL ((1, 2)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (mempcpy, void *,
                   (void *restrict __dest, void const *restrict __src,
                    size_t __n));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (mempcpy);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef mempcpy
 # if HAVE_RAW_DECL_MEMPCPY
diff --git a/m4/mempcpy.m4 b/m4/mempcpy.m4
index d663b67174..612b77b3c1 100644
--- a/m4/mempcpy.m4
+++ b/m4/mempcpy.m4
@@ -1,4 +1,4 @@
-# mempcpy.m4 serial 13
+# mempcpy.m4 serial 14
 dnl Copyright (C) 2003-2004, 2006-2007, 2009-2023 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -17,6 +17,9 @@ AC_DEFUN([gl_FUNC_MEMPCPY],
   gl_CHECK_FUNCS_ANDROID([mempcpy], [[#include <string.h>]])
   if test $ac_cv_func_mempcpy = no; then
     HAVE_MEMPCPY=0
+    case "$gl_cv_onwards_func_mempcpy" in
+      future*) REPLACE_MEMPCPY=1 ;;
+    esac
   fi
 ])
 
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index 132ed87d6a..7f51391cbf 100644
--- a/m4/string_h.m4
+++ b/m4/string_h.m4
@@ -5,7 +5,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 36
+# serial 37
 
 # Written by Paul Eggert.
 
@@ -131,6 +131,7 @@ AC_DEFUN([gl_STRING_H_DEFAULTS],
   REPLACE_FFSLL=0;              AC_SUBST([REPLACE_FFSLL])
   REPLACE_MEMCHR=0;             AC_SUBST([REPLACE_MEMCHR])
   REPLACE_MEMMEM=0;             AC_SUBST([REPLACE_MEMMEM])
+  REPLACE_MEMPCPY=0;            AC_SUBST([REPLACE_MEMPCPY])
   REPLACE_STPCPY=0;             AC_SUBST([REPLACE_STPCPY])
   REPLACE_STPNCPY=0;            AC_SUBST([REPLACE_STPNCPY])
   REPLACE_STRCHRNUL=0;          AC_SUBST([REPLACE_STRCHRNUL])
diff --git a/modules/mempcpy b/modules/mempcpy
index 142ce7fdca..469dbd8789 100644
--- a/modules/mempcpy
+++ b/modules/mempcpy
@@ -11,7 +11,8 @@ string
 
 configure.ac:
 gl_FUNC_MEMPCPY
-gl_CONDITIONAL([GL_COND_OBJ_MEMPCPY], [test $HAVE_MEMPCPY = 0])
+gl_CONDITIONAL([GL_COND_OBJ_MEMPCPY],
+               [test $HAVE_MEMPCPY = 0 || test $REPLACE_MEMPCPY = 1])
 AM_COND_IF([GL_COND_OBJ_MEMPCPY], [
   gl_PREREQ_MEMPCPY
 ])
diff --git a/modules/string b/modules/string
index 03a1b0547c..9bfed12613 100644
--- a/modules/string
+++ b/modules/string
@@ -108,6 +108,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''REPLACE_FFSLL''@|$(REPLACE_FFSLL)|g' \
 	      -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
 	      -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
+	      -e 's|@''REPLACE_MEMPCPY''@|$(REPLACE_MEMPCPY)|g' \
 	      -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
 	      -e 's|@''REPLACE_STPCPY''@|$(REPLACE_STPCPY)|g' \
 	      -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \
-- 
2.34.1


[-- Attachment #31: 0031-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 5068 bytes --]

From 6de13dcceb91445233d5d1e26c7498f826d2b8a2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 13:12:02 +0100
Subject: [PATCH 31/47] Resolve conflicts for functions introduced in Android
 API level 23.

* lib/wchar.in.h (wmempcpy): Consider REPLACE_WMEMPCPY.
* m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WMEMPCPY.
* modules/wchar (Makefile.am): Substitute REPLACE_WMEMPCPY.
* m4/wmempcpy.m4 (gl_FUNC_WMEMPCPY): Conditionally set
REPLACE_WMEMPCPY.
* modules/wmempcpy (configure.ac): Consider REPLACE_WMEMPCPY.
---
 ChangeLog        |  7 +++++++
 lib/wchar.in.h   | 17 +++++++++++++++--
 m4/wchar_h.m4    |  3 ++-
 m4/wmempcpy.m4   |  5 ++++-
 modules/wchar    |  1 +
 modules/wmempcpy |  3 ++-
 6 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a39769fb47..3f429d5afc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
 
 	Resolve conflicts for functions introduced in Android API level 23.
 
+	* lib/wchar.in.h (wmempcpy): Consider REPLACE_WMEMPCPY.
+	* m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WMEMPCPY.
+	* modules/wchar (Makefile.am): Substitute REPLACE_WMEMPCPY.
+	* m4/wmempcpy.m4 (gl_FUNC_WMEMPCPY): Conditionally set
+	REPLACE_WMEMPCPY.
+	* modules/wmempcpy (configure.ac): Consider REPLACE_WMEMPCPY.
+
 	* lib/unistd.in.h (sethostname): Consider REPLACE_SETHOSTNAME. Disable
 	_GL_CXXALIASWARN invocation on non-glibc systems.
 	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_SETHOSTNAME.
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index 354709db52..bbca92797d 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -696,14 +696,27 @@ _GL_WARN_ON_USE (wmemmove, "wmemmove is unportable - "
 /* Copy N wide characters of SRC to DEST.
    Return pointer to wide characters after the last written wide character.  */
 #if @GNULIB_WMEMPCPY@
-# if !@HAVE_WMEMPCPY@
+# if @REPLACE_WMEMPCPY@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef wmempcpy
+#   define wmempcpy rpl_wmempcpy
+#  endif
+_GL_FUNCDECL_RPL (wmempcpy, wchar_t *,
+                  (wchar_t *restrict dest,
+                   const wchar_t *restrict src, size_t n));
+_GL_CXXALIAS_RPL (wmempcpy, wchar_t *,
+                  (wchar_t *restrict dest,
+                   const wchar_t *restrict src, size_t n));
+# else
+#  if !@HAVE_WMEMPCPY@
 _GL_FUNCDECL_SYS (wmempcpy, wchar_t *,
                   (wchar_t *restrict dest,
                    const wchar_t *restrict src, size_t n));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (wmempcpy, wchar_t *,
                   (wchar_t *restrict dest,
                    const wchar_t *restrict src, size_t n));
+# endif
 # if __GLIBC__ >= 2
 _GL_CXXALIASWARN (wmempcpy);
 # endif
diff --git a/m4/wchar_h.m4 b/m4/wchar_h.m4
index 8ec66193e0..ad3d4ecbb4 100644
--- a/m4/wchar_h.m4
+++ b/m4/wchar_h.m4
@@ -7,7 +7,7 @@ dnl with or without modifications, as long as this notice is preserved.
 
 dnl Written by Eric Blake.
 
-# wchar_h.m4 serial 55
+# wchar_h.m4 serial 56
 
 AC_DEFUN_ONCE([gl_WCHAR_H],
 [
@@ -254,4 +254,5 @@ AC_DEFUN([gl_WCHAR_H_DEFAULTS],
   REPLACE_WCSWIDTH=0;   AC_SUBST([REPLACE_WCSWIDTH])
   REPLACE_WCSFTIME=0;   AC_SUBST([REPLACE_WCSFTIME])
   REPLACE_WCSTOK=0;     AC_SUBST([REPLACE_WCSTOK])
+  REPLACE_WMEMPCPY=0;   AC_SUBST([REPLACE_WMEMPCPY])
 ])
diff --git a/m4/wmempcpy.m4 b/m4/wmempcpy.m4
index 729128cab7..abf1df345d 100644
--- a/m4/wmempcpy.m4
+++ b/m4/wmempcpy.m4
@@ -1,4 +1,4 @@
-# wmempcpy.m4 serial 2
+# wmempcpy.m4 serial 3
 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,
@@ -17,5 +17,8 @@ AC_DEFUN([gl_FUNC_WMEMPCPY],
   gl_CHECK_FUNCS_ANDROID([wmempcpy], [[#include <wchar.h>]])
   if test $ac_cv_func_wmempcpy = no; then
     HAVE_WMEMPCPY=0
+    case "$gl_cv_onwards_func_wmempcpy" in
+      future*) REPLACE_WMEMPCPY=1 ;;
+    esac
   fi
 ])
diff --git a/modules/wchar b/modules/wchar
index 58c2d1f368..4a507f0167 100644
--- a/modules/wchar
+++ b/modules/wchar
@@ -143,6 +143,7 @@ wchar.h: wchar.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H)
 	      -e 's|@''REPLACE_WCSWIDTH''@|$(REPLACE_WCSWIDTH)|g' \
 	      -e 's|@''REPLACE_WCSFTIME''@|$(REPLACE_WCSFTIME)|g' \
 	      -e 's|@''REPLACE_WCSTOK''@|$(REPLACE_WCSTOK)|g' \
+	      -e 's|@''REPLACE_WMEMPCPY''@|$(REPLACE_WMEMPCPY)|g' \
 	      -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
 	      -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
 	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
diff --git a/modules/wmempcpy b/modules/wmempcpy
index 7548b2a74b..3f8e2c5112 100644
--- a/modules/wmempcpy
+++ b/modules/wmempcpy
@@ -10,7 +10,8 @@ wchar
 
 configure.ac:
 gl_FUNC_WMEMPCPY
-gl_CONDITIONAL([GL_COND_OBJ_WMEMPCPY], [test $HAVE_WMEMPCPY = 0])
+gl_CONDITIONAL([GL_COND_OBJ_WMEMPCPY],
+               [test $HAVE_WMEMPCPY = 0 || test $REPLACE_WMEMPCPY = 1])
 gl_WCHAR_MODULE_INDICATOR([wmempcpy])
 
 Makefile.am:
-- 
2.34.1


[-- Attachment #32: 0030-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 6073 bytes --]

From 134320a310c64fc3b497618cabc2749bd98735fb Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 13:05:19 +0100
Subject: [PATCH 30/47] Resolve conflicts for functions introduced in Android
 API level 23.

* lib/unistd.in.h (sethostname): Consider REPLACE_SETHOSTNAME. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_SETHOSTNAME.
* modules/unistd (Makefile.am): Substitute REPLACE_SETHOSTNAME.
* m4/sethostname.m4 (gl_FUNC_SETHOSTNAME): Conditionally set
REPLACE_SETHOSTNAME.
* modules/sethostname (Depends-on, configure.ac): Consider
REPLACE_SETHOSTNAME.
---
 ChangeLog           |  9 +++++++++
 lib/unistd.in.h     | 16 ++++++++++++++--
 m4/sethostname.m4   |  5 ++++-
 m4/unistd_h.m4      |  3 ++-
 modules/sethostname |  7 ++++---
 modules/unistd      |  1 +
 6 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3accc92f95..a39769fb47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,15 @@
 
 	Resolve conflicts for functions introduced in Android API level 23.
 
+	* lib/unistd.in.h (sethostname): Consider REPLACE_SETHOSTNAME. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_SETHOSTNAME.
+	* modules/unistd (Makefile.am): Substitute REPLACE_SETHOSTNAME.
+	* m4/sethostname.m4 (gl_FUNC_SETHOSTNAME): Conditionally set
+	REPLACE_SETHOSTNAME.
+	* modules/sethostname (Depends-on, configure.ac): Consider
+	REPLACE_SETHOSTNAME.
+
 	* lib/string.in.h (mempcpy): Consider REPLACE_MEMPCPY. Disable
 	_GL_CXXALIASWARN invocation on non-glibc systems.
 	* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_MEMPCPY.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 2a6d4ce743..9930a11c19 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -2029,15 +2029,27 @@ _GL_CXXALIASWARN (rmdir);
 
    Platforms with no ability to set the hostname return -1 and set
    errno = ENOSYS.  */
-# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
+# if @REPLACE_SETHOSTNAME@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef sethostname
+#   define sethostname rpl_sethostname
+#  endif
+_GL_FUNCDECL_RPL (sethostname, int, (const char *name, size_t len)
+                                    _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (sethostname, int, (const char *name, size_t len));
+# else
+#  if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
 _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
                                     _GL_ARG_NONNULL ((1)));
-# endif
+#  endif
 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
    and FreeBSD 6.4 the second parameter is int.  On Solaris 11
    2011-10, the first parameter is not const.  */
 _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (sethostname);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef sethostname
 # if HAVE_RAW_DECL_SETHOSTNAME
diff --git a/m4/sethostname.m4 b/m4/sethostname.m4
index 8f3cd18c6c..c3dea59464 100644
--- a/m4/sethostname.m4
+++ b/m4/sethostname.m4
@@ -1,4 +1,4 @@
-# sethostname.m4 serial 2
+# sethostname.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,
@@ -16,6 +16,9 @@ AC_DEFUN([gl_FUNC_SETHOSTNAME],
   gl_CHECK_FUNCS_ANDROID([sethostname], [[#include <unistd.h>]])
   if test $ac_cv_func_sethostname = no; then
     HAVE_SETHOSTNAME=0
+    case "$gl_cv_onwards_func_sethostname" in
+      future*) REPLACE_SETHOSTNAME=1 ;;
+    esac
   fi
 
   AC_CHECK_DECLS([sethostname])
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index 8fbd82b2b7..fc8e2a58f3 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 92
+# unistd_h.m4 serial 93
 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,
@@ -257,6 +257,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_READLINK=0;                AC_SUBST([REPLACE_READLINK])
   REPLACE_READLINKAT=0;              AC_SUBST([REPLACE_READLINKAT])
   REPLACE_RMDIR=0;                   AC_SUBST([REPLACE_RMDIR])
+  REPLACE_SETHOSTNAME=0;             AC_SUBST([REPLACE_SETHOSTNAME])
   REPLACE_SLEEP=0;                   AC_SUBST([REPLACE_SLEEP])
   REPLACE_SYMLINK=0;                 AC_SUBST([REPLACE_SYMLINK])
   REPLACE_SYMLINKAT=0;               AC_SUBST([REPLACE_SYMLINKAT])
diff --git a/modules/sethostname b/modules/sethostname
index 56b68b2ad4..6057ef06cd 100644
--- a/modules/sethostname
+++ b/modules/sethostname
@@ -8,12 +8,13 @@ m4/gethostname.m4
 
 Depends-on:
 unistd
-errno           [test $HAVE_SETHOSTNAME = 0]
-fopen-gnu       [test $HAVE_SETHOSTNAME = 0]
+errno           [test $HAVE_SETHOSTNAME = 0 || test $REPLACE_SETHOSTNAME = 1]
+fopen-gnu       [test $HAVE_SETHOSTNAME = 0 || test $REPLACE_SETHOSTNAME = 1]
 
 configure.ac:
 gl_FUNC_SETHOSTNAME
-gl_CONDITIONAL([GL_COND_OBJ_SETHOSTNAME], [test $HAVE_SETHOSTNAME = 0])
+gl_CONDITIONAL([GL_COND_OBJ_SETHOSTNAME],
+               [test $HAVE_SETHOSTNAME = 0 || test $REPLACE_SETHOSTNAME = 1])
 gl_UNISTD_MODULE_INDICATOR([sethostname])
 
 Makefile.am:
diff --git a/modules/unistd b/modules/unistd
index 065e4ad52e..ddb0991f85 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -211,6 +211,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \
 	      -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \
 	      -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \
+	      -e 's|@''REPLACE_SETHOSTNAME''@|$(REPLACE_SETHOSTNAME)|g' \
 	      -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \
 	      -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \
 	      -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \
-- 
2.34.1


[-- Attachment #33: 0032-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2399 bytes --]

From eaf067b33e6883af540f72340400eabd9f79c029 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:09:49 +0100
Subject: [PATCH 32/47] Resolve conflicts for functions introduced in Android
 API level 23.

* m4/error_h.m4 (gl_ERROR_H): Conditionally set REPLACE_ERROR.
* lib/error.in.h (error): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog      | 4 ++++
 lib/error.in.h | 2 ++
 m4/error_h.m4  | 8 ++++++--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3f429d5afc..496db94438 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 23.
 
+	* m4/error_h.m4 (gl_ERROR_H): Conditionally set REPLACE_ERROR.
+	* lib/error.in.h (error): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* lib/wchar.in.h (wmempcpy): Consider REPLACE_WMEMPCPY.
 	* m4/wchar_h.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WMEMPCPY.
 	* modules/wchar (Makefile.am): Substitute REPLACE_WMEMPCPY.
diff --git a/lib/error.in.h b/lib/error.in.h
index 2ac99c2817..bfddb011c0 100644
--- a/lib/error.in.h
+++ b/lib/error.in.h
@@ -56,7 +56,9 @@ _GL_FUNCDECL_SYS (error, void,
 _GL_CXXALIAS_SYS (error, void,
                   (int __status, int __errnum, const char *__format, ...));
 #endif
+#if __GLIBC__ >= 2
 _GL_CXXALIASWARN (error);
+#endif
 
 /* Likewise.  If FILENAME is non-NULL, include FILENAME:LINENO: in the
    message.  */
diff --git a/m4/error_h.m4 b/m4/error_h.m4
index bb8f68ff81..15b5112309 100644
--- a/m4/error_h.m4
+++ b/m4/error_h.m4
@@ -1,4 +1,4 @@
-# error_h.m4 serial 1
+# error_h.m4 serial 2
 dnl Copyright (C) 1996-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,13 +11,17 @@ AC_DEFUN_ONCE([gl_ERROR_H],
 [
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
+  REPLACE_ERROR=0
+
   gl_CHECK_FUNCS_ANDROID([error], [[#include <error.h>]])
   if test $ac_cv_func_error = yes; then
     HAVE_ERROR=1
   else
     HAVE_ERROR=0
+    case "$gl_cv_onwards_func_error" in
+      future*) REPLACE_ERROR=1 ;;
+    esac
   fi
-  REPLACE_ERROR=0
 
   dnl We don't use AC_FUNC_ERROR_AT_LINE any more, because it is no longer
   dnl maintained in Autoconf and because it invokes AC_LIBOBJ.
-- 
2.34.1


[-- Attachment #34: 0033-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2140 bytes --]

From 11525f6203e65c4828f9f643a80916586ec07ed1 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:11:49 +0100
Subject: [PATCH 33/47] Resolve conflicts for functions introduced in Android
 API level 23.

* m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS): Conditionally set
REPLACE_STRERROR_R.
* lib/string.in.h (strerror_r): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog        | 5 +++++
 lib/string.in.h  | 2 +-
 m4/strerror_r.m4 | 6 +++++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 496db94438..50cf6768b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
 	Resolve conflicts for functions introduced in Android API level 23.
 
+	* m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS): Conditionally set
+	REPLACE_STRERROR_R.
+	* lib/string.in.h (strerror_r): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/error_h.m4 (gl_ERROR_H): Conditionally set REPLACE_ERROR.
 	* lib/error.in.h (error): Disable _GL_CXXALIASWARN invocation on
 	non-glibc systems.
diff --git a/lib/string.in.h b/lib/string.in.h
index 2e078aff47..aa08821392 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -1244,7 +1244,7 @@ _GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
 #  endif
 _GL_CXXALIAS_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen));
 # endif
-# if @HAVE_DECL_STRERROR_R@
+# if __GLIBC__ >= 2 && @HAVE_DECL_STRERROR_R@
 _GL_CXXALIASWARN (strerror_r);
 # endif
 #elif defined GNULIB_POSIXCHECK
diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4
index 358fc07bfd..d790ba8775 100644
--- a/m4/strerror_r.m4
+++ b/m4/strerror_r.m4
@@ -1,4 +1,4 @@
-# strerror_r.m4 serial 25
+# strerror_r.m4 serial 26
 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,
@@ -172,5 +172,9 @@ changequote([,])dnl
         fi
       fi
     fi
+  else
+    case "$gl_cv_onwards_func_strerror_r" in
+      future*) REPLACE_STRERROR_R=1 ;;
+    esac
   fi
 ])
-- 
2.34.1


[-- Attachment #35: 0034-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2146 bytes --]

From d59a6421e9f6cbac3197a33e39d3c3f29a175e52 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:13:24 +0100
Subject: [PATCH 34/47] Resolve conflicts for functions introduced in Android
 API level 23.

* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Conditionally set REPLACE_MKFIFOAT.
* lib/sys_stat.in.h (mkfifoat): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog         | 4 ++++
 lib/sys_stat.in.h | 2 ++
 m4/mkfifoat.m4    | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 50cf6768b4..6b292af178 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 23.
 
+	* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Conditionally set REPLACE_MKFIFOAT.
+	* lib/sys_stat.in.h (mkfifoat): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS): Conditionally set
 	REPLACE_STRERROR_R.
 	* lib/string.in.h (strerror_r): Disable _GL_CXXALIASWARN invocation on
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 4ebe121a31..0c2f39c12b 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -716,7 +716,9 @@ _GL_FUNCDECL_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode)
 #  endif
 _GL_CXXALIAS_SYS (mkfifoat, int, (int fd, char const *file, mode_t mode));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (mkfifoat);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef mkfifoat
 # if HAVE_RAW_DECL_MKFIFOAT
diff --git a/m4/mkfifoat.m4 b/m4/mkfifoat.m4
index d7311f2557..ed86d5c197 100644
--- a/m4/mkfifoat.m4
+++ b/m4/mkfifoat.m4
@@ -1,4 +1,4 @@
-# serial 8
+# serial 9
 # See if we need to provide mkfifoat/mknodat replacement.
 
 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
@@ -62,6 +62,9 @@ AC_DEFUN([gl_FUNC_MKFIFOAT],
   else
     # No known system has mkfifoat but not mknodat
     HAVE_MKFIFOAT=0
+    case "$gl_cv_onwards_func_mkfifoat" in
+      future*) REPLACE_MKFIFOAT=1 ;;
+    esac
     HAVE_MKNODAT=0
     case "$gl_cv_onwards_func_mknodat" in
       future*) REPLACE_MKNODAT=1 ;;
-- 
2.34.1


[-- Attachment #36: 0036-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 1627 bytes --]

From 98a7c3a0cb97db93cabf376cbef7fbb81d4f4023 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:15:21 +0100
Subject: [PATCH 36/47] Resolve conflicts for functions introduced in Android
 API level 24.

* m4/strchrnul.m4 (gl_FUNC_STRCHRNUL): Conditionally set
REPLACE_STRCHRNUL.
---
 ChangeLog       | 6 ++++++
 m4/strchrnul.m4 | 5 ++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 0239e388cd..905fd782d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 24.
+	* m4/strchrnul.m4 (gl_FUNC_STRCHRNUL): Conditionally set
+	REPLACE_STRCHRNUL.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 23.
diff --git a/m4/strchrnul.m4 b/m4/strchrnul.m4
index a38e78531e..9b9ab11ada 100644
--- a/m4/strchrnul.m4
+++ b/m4/strchrnul.m4
@@ -1,4 +1,4 @@
-# strchrnul.m4 serial 11
+# strchrnul.m4 serial 12
 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,
@@ -13,6 +13,9 @@ AC_DEFUN([gl_FUNC_STRCHRNUL],
   gl_CHECK_FUNCS_ANDROID([strchrnul], [[#include <string.h>]])
   if test $ac_cv_func_strchrnul = no; then
     HAVE_STRCHRNUL=0
+    case "$gl_cv_onwards_func_strchrnul" in
+      future*) REPLACE_STRCHRNUL=1 ;;
+    esac
   else
     AC_CACHE_CHECK([whether strchrnul works],
       [gl_cv_func_strchrnul_works],
-- 
2.34.1


[-- Attachment #37: 0035-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2070 bytes --]

From fbe4d2d5362f8dea731f7162011eafb78ba7c073 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:14:42 +0100
Subject: [PATCH 35/47] Resolve conflicts for functions introduced in Android
 API level 23.

* m4/login_tty.m4 (gl_FUNC_LOGIN_TTY): Conditionally set
REPLACE_LOGIN_TTY.
* lib/utmp.in.h (login_tty): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog       | 5 +++++
 lib/utmp.in.h   | 2 ++
 m4/login_tty.m4 | 5 ++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 6b292af178..0239e388cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
 	Resolve conflicts for functions introduced in Android API level 23.
 
+	* m4/login_tty.m4 (gl_FUNC_LOGIN_TTY): Conditionally set
+	REPLACE_LOGIN_TTY.
+	* lib/utmp.in.h (login_tty): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/mkfifoat.m4 (gl_FUNC_MKFIFOAT): Conditionally set REPLACE_MKFIFOAT.
 	* lib/sys_stat.in.h (mkfifoat): Disable _GL_CXXALIASWARN invocation on
 	non-glibc systems.
diff --git a/lib/utmp.in.h b/lib/utmp.in.h
index 58318e7ffb..c33b3d2469 100644
--- a/lib/utmp.in.h
+++ b/lib/utmp.in.h
@@ -62,7 +62,9 @@ _GL_FUNCDECL_SYS (login_tty, int, (int fd));
 #  endif
 _GL_CXXALIAS_SYS (login_tty, int, (int fd));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (login_tty);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef login_tty
 # if HAVE_RAW_DECL_LOGIN_TTY
diff --git a/m4/login_tty.m4 b/m4/login_tty.m4
index 0d504050f1..ca15e6aabb 100644
--- a/m4/login_tty.m4
+++ b/m4/login_tty.m4
@@ -1,4 +1,4 @@
-# login_tty.m4 serial 1
+# login_tty.m4 serial 2
 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,
@@ -26,5 +26,8 @@ AC_DEFUN([gl_FUNC_LOGIN_TTY],
 
   if test $ac_cv_func_login_tty = no; then
     HAVE_LOGIN_TTY=0
+    case "$gl_cv_onwards_func_login_tty" in
+      future*) REPLACE_LOGIN_TTY=1 ;;
+    esac
   fi
 ])
-- 
2.34.1


[-- Attachment #38: 0037-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 5984 bytes --]

From 31617d81c53135e56f943299f54fd26acc3afe79 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:16:36 +0100
Subject: [PATCH 37/47] Resolve conflicts for functions introduced in Android
 API level 26.

* lib/stdlib.in.h (getsubopt): Consider REPLACE_GETSUBOPT. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_GETSUBOPT.
* modules/stdlib (Makefile.am): Substitute REPLACE_GETSUBOPT.
* m4/getsubopt.m4 (gl_FUNC_GETSUBOPT): Conditionally set
REPLACE_GETSUBOPT.
* modules/getsubopt (Depends-on, configure.ac): Consider
REPLACE_GETSUBOPT.
---
 ChangeLog         | 13 +++++++++++++
 lib/stdlib.in.h   | 18 ++++++++++++++++--
 m4/getsubopt.m4   |  5 ++++-
 m4/stdlib_h.m4    |  3 ++-
 modules/getsubopt |  7 ++++---
 modules/stdlib    |  1 +
 6 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 905fd782d8..39709e91cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 26.
+
+	* lib/stdlib.in.h (getsubopt): Consider REPLACE_GETSUBOPT. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_GETSUBOPT.
+	* modules/stdlib (Makefile.am): Substitute REPLACE_GETSUBOPT.
+	* m4/getsubopt.m4 (gl_FUNC_GETSUBOPT): Conditionally set
+	REPLACE_GETSUBOPT.
+	* modules/getsubopt (Depends-on, configure.ac): Consider
+	REPLACE_GETSUBOPT.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 24.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index 95e0b847b9..c03f46ee38 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -488,14 +488,28 @@ _GL_WARN_ON_USE (getprogname, "getprogname is unportable - "
    Otherwise it returns -1, and *OPTIONP and *VALUEP are undefined.
    For more details see the POSIX specification.
    https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html */
-# if !@HAVE_GETSUBOPT@
+# if @REPLACE_GETSUBOPT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef getsubopt
+#   define getsubopt rpl_getsubopt
+#  endif
+_GL_FUNCDECL_RPL (getsubopt, int,
+                  (char **optionp, char *const *tokens, char **valuep)
+                  _GL_ARG_NONNULL ((1, 2, 3)));
+_GL_CXXALIAS_RPL (getsubopt, int,
+                  (char **optionp, char *const *tokens, char **valuep));
+# else
+#  if !@HAVE_GETSUBOPT@
 _GL_FUNCDECL_SYS (getsubopt, int,
                   (char **optionp, char *const *tokens, char **valuep)
                   _GL_ARG_NONNULL ((1, 2, 3)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (getsubopt, int,
                   (char **optionp, char *const *tokens, char **valuep));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (getsubopt);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef getsubopt
 # if HAVE_RAW_DECL_GETSUBOPT
diff --git a/m4/getsubopt.m4 b/m4/getsubopt.m4
index a528ec7143..3bafefeda6 100644
--- a/m4/getsubopt.m4
+++ b/m4/getsubopt.m4
@@ -1,4 +1,4 @@
-# getsubopt.m4 serial 6
+# getsubopt.m4 serial 7
 dnl Copyright (C) 2004, 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,9 @@ AC_DEFUN([gl_FUNC_GETSUBOPT],
     ]])
   if test $ac_cv_func_getsubopt = no; then
     HAVE_GETSUBOPT=0
+    case "$gl_cv_onwards_func_getsubopt" in
+      future*) REPLACE_GETSUBOPT=1 ;;
+    esac
   fi
 ])
 
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index 525cd5ba78..ee1f48ee5a 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 69
+# stdlib_h.m4 serial 70
 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,
@@ -175,6 +175,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   REPLACE_CANONICALIZE_FILE_NAME=0;  AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
   REPLACE_FREE=0;            AC_SUBST([REPLACE_FREE])
   REPLACE_GETPROGNAME=0;     AC_SUBST([REPLACE_GETPROGNAME])
+  REPLACE_GETSUBOPT=0;       AC_SUBST([REPLACE_GETSUBOPT])
   REPLACE_INITSTATE=0;       AC_SUBST([REPLACE_INITSTATE])
   REPLACE_MALLOC_FOR_MALLOC_GNU=0;    AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_GNU])
   REPLACE_MALLOC_FOR_MALLOC_POSIX=0;  AC_SUBST([REPLACE_MALLOC_FOR_MALLOC_POSIX])
diff --git a/modules/getsubopt b/modules/getsubopt
index 0b0d23d56d..bdabdd76d5 100644
--- a/modules/getsubopt
+++ b/modules/getsubopt
@@ -8,12 +8,13 @@ m4/getsubopt.m4
 Depends-on:
 stdlib
 extensions
-strchrnul       [test $HAVE_GETSUBOPT = 0]
-memchr          [test $HAVE_GETSUBOPT = 0]
+strchrnul       [test $HAVE_GETSUBOPT = 0 || test $REPLACE_GETSUBOPT = 1]
+memchr          [test $HAVE_GETSUBOPT = 0 || test $REPLACE_GETSUBOPT = 1]
 
 configure.ac:
 gl_FUNC_GETSUBOPT
-gl_CONDITIONAL([GL_COND_OBJ_GETSUBOPT], [test $HAVE_GETSUBOPT = 0])
+gl_CONDITIONAL([GL_COND_OBJ_GETSUBOPT],
+               [test $HAVE_GETSUBOPT = 0 || test $REPLACE_GETSUBOPT = 1])
 AM_COND_IF([GL_COND_OBJ_GETSUBOPT], [
   gl_PREREQ_GETSUBOPT
 ])
diff --git a/modules/stdlib b/modules/stdlib
index 57f1e40269..5ae3e6665d 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -135,6 +135,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
 	      -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
 	      -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
 	      -e 's|@''REPLACE_GETPROGNAME''@|$(REPLACE_GETPROGNAME)|g' \
+	      -e 's|@''REPLACE_GETSUBOPT''@|$(REPLACE_GETSUBOPT)|g' \
 	      -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
 	      -e 's|@''REPLACE_MALLOC_FOR_MALLOC_GNU''@|$(REPLACE_MALLOC_FOR_MALLOC_GNU)|g' \
 	      -e 's|@''REPLACE_MALLOC_FOR_MALLOC_POSIX''@|$(REPLACE_MALLOC_FOR_MALLOC_POSIX)|g' \
-- 
2.34.1


[-- Attachment #39: 0038-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2276 bytes --]

From 2b7729265f7e38e1087cd9f51099cce5e862147d Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:20:58 +0100
Subject: [PATCH 38/47] Resolve conflicts for functions introduced in Android
 API level 26.

* m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Conditionally set
REPLACE_NL_LANGINFO.
* lib/langinfo.in.h (nl_langinfo): Disable _GL_CXXALIASWARN invocation
on non-glibc systems.
---
 ChangeLog         | 5 +++++
 lib/langinfo.in.h | 2 ++
 m4/nl_langinfo.m4 | 5 ++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 39709e91cd..71c23426e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
 	Resolve conflicts for functions introduced in Android API level 26.
 
+	* m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Conditionally set
+	REPLACE_NL_LANGINFO.
+	* lib/langinfo.in.h (nl_langinfo): Disable _GL_CXXALIASWARN invocation
+	on non-glibc systems.
+
 	* lib/stdlib.in.h (getsubopt): Consider REPLACE_GETSUBOPT. Disable
 	_GL_CXXALIASWARN invocation on non-glibc systems.
 	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_GETSUBOPT.
diff --git a/lib/langinfo.in.h b/lib/langinfo.in.h
index c7555a6a59..82e1e3cb1b 100644
--- a/lib/langinfo.in.h
+++ b/lib/langinfo.in.h
@@ -208,7 +208,9 @@ _GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item));
 #  endif
 _GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (nl_langinfo);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef nl_langinfo
 # if HAVE_RAW_DECL_NL_LANGINFO
diff --git a/m4/nl_langinfo.m4 b/m4/nl_langinfo.m4
index c7146ace03..7648d52467 100644
--- a/m4/nl_langinfo.m4
+++ b/m4/nl_langinfo.m4
@@ -1,4 +1,4 @@
-# nl_langinfo.m4 serial 10
+# nl_langinfo.m4 serial 11
 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,
@@ -60,6 +60,9 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
     fi
   else
     HAVE_NL_LANGINFO=0
+    case "$gl_cv_onwards_func_nl_langinfo" in
+      future*) REPLACE_NL_LANGINFO=1 ;;
+    esac
   fi
   if test $HAVE_NL_LANGINFO = 0 || test $HAVE_LANGINFO_CODESET = 0; then
     LIB_NL_LANGINFO="$SETLOCALE_NULL_LIB"
-- 
2.34.1


[-- Attachment #40: 0039-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2799 bytes --]

From a1e2c8310d3694d3a80201ea63371e33a58d2d2a Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:21:48 +0100
Subject: [PATCH 39/47] Resolve conflicts for functions introduced in Android
 API level 26.

* m4/getdomainname.m4 (gl_FUNC_GETDOMAINNAME): Test for getdomainname
using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS. Conditionally
set REPLACE_GETSUBOPT.
---
 ChangeLog           |  4 ++++
 m4/getdomainname.m4 | 12 ++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 71c23426e6..513a009fce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 26.
 
+	* m4/getdomainname.m4 (gl_FUNC_GETDOMAINNAME): Test for getdomainname
+	using gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS. Conditionally
+	set REPLACE_GETSUBOPT.
+
 	* m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Conditionally set
 	REPLACE_NL_LANGINFO.
 	* lib/langinfo.in.h (nl_langinfo): Disable _GL_CXXALIASWARN invocation
diff --git a/m4/getdomainname.m4 b/m4/getdomainname.m4
index 8b118bafe7..54bc5a66e2 100644
--- a/m4/getdomainname.m4
+++ b/m4/getdomainname.m4
@@ -1,4 +1,4 @@
-# getdomainname.m4 serial 12
+# getdomainname.m4 serial 13
 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,
@@ -19,7 +19,8 @@ AC_DEFUN([gl_FUNC_GETDOMAINNAME],
   dnl   <https://web.archive.org/web/20100121182558/http://www.sun.com/software/solaris/programs/abi/appcert_faq.xml#q18>.
   dnl   We need to avoid a collision with this function.
   dnl - Otherwise it is in libc.
-  AC_CHECK_FUNCS([getdomainname], , [
+  gl_CHECK_FUNCS_ANDROID([getdomainname], [[#include <unistd.h>]])
+  if test $ac_cv_func_getdomainname = no; then
     AC_CACHE_CHECK([for getdomainname in -lnsl],
       [gl_cv_func_getdomainname_in_libnsl],
       [gl_cv_func_getdomainname_in_libnsl=no
@@ -38,7 +39,7 @@ AC_DEFUN([gl_FUNC_GETDOMAINNAME],
          [gl_cv_func_getdomainname_in_libnsl=yes])
        LIBS="$gl_save_LIBS"
       ])
-  ])
+  fi
 
   dnl What about the declaration?
   dnl - It's  int getdomainname(char *, size_t)  on glibc, NetBSD, OpenBSD.
@@ -85,10 +86,13 @@ 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; \
      } \
+     || case "$gl_cv_onwards_func_getdomainname" in \
+          future*) true ;; \
+          *) false ;; \
+        esac \
      || test "$gl_cv_func_getdomainname_in_libnsl" = yes; then
     REPLACE_GETDOMAINNAME=1
   fi
-- 
2.34.1


[-- Attachment #41: 0040-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 5489 bytes --]

From 39eda5d0b1b3d1df691102b311868ef4ce69d221 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:22:28 +0100
Subject: [PATCH 40/47] Resolve conflicts for functions introduced in Android
 API level 28.

* lib/unistd.in.h (getentropy): Consider REPLACE_GETENTROPY. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_GETENTROPY.
* modules/unistd (Makefile.am): Substitute REPLACE_GETENTROPY.
* m4/getentropy.m4 (gl_FUNC_GETENTROPY): Conditionally set
REPLACE_GETENTROPY.
* modules/getentropy (Depends-on, configure.ac): Consider
REPLACE_GETENTROPY.
---
 ChangeLog          | 13 +++++++++++++
 lib/unistd.in.h    | 15 +++++++++++++--
 m4/getentropy.m4   |  5 ++++-
 m4/unistd_h.m4     |  3 ++-
 modules/getentropy |  5 +++--
 modules/unistd     |  1 +
 6 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 513a009fce..fa9d220e0c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 28.
+
+	* lib/unistd.in.h (getentropy): Consider REPLACE_GETENTROPY. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_GETENTROPY.
+	* modules/unistd (Makefile.am): Substitute REPLACE_GETENTROPY.
+	* m4/getentropy.m4 (gl_FUNC_GETENTROPY): Conditionally set
+	REPLACE_GETENTROPY.
+	* modules/getentropy (Depends-on, configure.ac): Consider
+	REPLACE_GETENTROPY.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 26.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 9930a11c19..8016f7345e 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1207,11 +1207,22 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
 
 #if @GNULIB_GETENTROPY@
 /* Fill a buffer with random bytes.  */
-# if !@HAVE_GETENTROPY@
+# if @REPLACE_GETENTROPY@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef getentropy
+#   define getentropy rpl_getentropy
+#  endif
+_GL_FUNCDECL_RPL (getentropy, int, (void *buffer, size_t length));
+_GL_CXXALIAS_RPL (getentropy, int, (void *buffer, size_t length));
+# else
+#  if !@HAVE_GETENTROPY@
 _GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (getentropy);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef getentropy
 # if HAVE_RAW_DECL_GETENTROPY
diff --git a/m4/getentropy.m4 b/m4/getentropy.m4
index 352b04ee4f..0e7ef26940 100644
--- a/m4/getentropy.m4
+++ b/m4/getentropy.m4
@@ -1,4 +1,4 @@
-# getentropy.m4 serial 2
+# getentropy.m4 serial 3
 dnl Copyright 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,
@@ -19,5 +19,8 @@ AC_DEFUN([gl_FUNC_GETENTROPY],
     ]])
   if test $ac_cv_func_getentropy = no; then
     HAVE_GETENTROPY=0
+    case "$gl_cv_onwards_func_getentropy" in
+      future*) REPLACE_GETENTROPY=1 ;;
+    esac
   fi
 ])
diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4
index fc8e2a58f3..1c96158155 100644
--- a/m4/unistd_h.m4
+++ b/m4/unistd_h.m4
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 93
+# unistd_h.m4 serial 94
 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,
@@ -240,6 +240,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_GETCWD=0;                  AC_SUBST([REPLACE_GETCWD])
   REPLACE_GETDOMAINNAME=0;           AC_SUBST([REPLACE_GETDOMAINNAME])
   REPLACE_GETDTABLESIZE=0;           AC_SUBST([REPLACE_GETDTABLESIZE])
+  REPLACE_GETENTROPY=0;              AC_SUBST([REPLACE_GETENTROPY])
   REPLACE_GETLOGIN_R=0;              AC_SUBST([REPLACE_GETLOGIN_R])
   REPLACE_GETGROUPS=0;               AC_SUBST([REPLACE_GETGROUPS])
   REPLACE_GETPAGESIZE=0;             AC_SUBST([REPLACE_GETPAGESIZE])
diff --git a/modules/getentropy b/modules/getentropy
index 2f4bcf054c..3b0c434547 100644
--- a/modules/getentropy
+++ b/modules/getentropy
@@ -6,13 +6,14 @@ lib/getentropy.c
 m4/getentropy.m4
 
 Depends-on:
-getrandom      [test $HAVE_GETENTROPY = 0]
+getrandom      [test $HAVE_GETENTROPY = 0 || test $REPLACE_GETENTROPY = 1]
 extensions
 unistd
 
 configure.ac:
 gl_FUNC_GETENTROPY
-gl_CONDITIONAL([GL_COND_OBJ_GETENTROPY], [test $HAVE_GETENTROPY = 0])
+gl_CONDITIONAL([GL_COND_OBJ_GETENTROPY],
+               [test $HAVE_GETENTROPY = 0 || test $REPLACE_GETENTROPY = 1])
 gl_UNISTD_MODULE_INDICATOR([getentropy])
 
 Makefile.am:
diff --git a/modules/unistd b/modules/unistd
index ddb0991f85..1e9bc9ca6b 100644
--- a/modules/unistd
+++ b/modules/unistd
@@ -194,6 +194,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
 	      -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
 	      -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
 	      -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \
+	      -e 's|@''REPLACE_GETENTROPY''@|$(REPLACE_GETENTROPY)|g' \
 	      -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \
 	      -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \
 	      -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \
-- 
2.34.1


[-- Attachment #42: 0041-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2194 bytes --]

From 64ad3c7d1d74fb34ab6ae92b8ab0fdd9cdd3bfbc Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:33:37 +0100
Subject: [PATCH 41/47] Resolve conflicts for functions introduced in Android
 API level 28.

* m4/glob.m4 (gl_GLOB): Conditionally set REPLACE_GLOB.
* lib/glob.in.h (glob): Disable _GL_CXXALIASWARN invocation on non-glibc
systems.
---
 ChangeLog     | 4 ++++
 lib/glob.in.h | 2 ++
 m4/glob.m4    | 5 ++++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index fa9d220e0c..152b3399fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@
 
 	Resolve conflicts for functions introduced in Android API level 28.
 
+	* m4/glob.m4 (gl_GLOB): Conditionally set REPLACE_GLOB.
+	* lib/glob.in.h (glob): Disable _GL_CXXALIASWARN invocation on non-glibc
+	systems.
+
 	* lib/unistd.in.h (getentropy): Consider REPLACE_GETENTROPY. Disable
 	_GL_CXXALIASWARN invocation on non-glibc systems.
 	* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_GETENTROPY.
diff --git a/lib/glob.in.h b/lib/glob.in.h
index c628a9bcbd..7fc3ef7347 100644
--- a/lib/glob.in.h
+++ b/lib/glob.in.h
@@ -120,7 +120,9 @@ _GL_CXXALIAS_SYS (glob, int, (const char *_Restrict_ __pattern, int __flags,
                               _gl_glob_errfunc_fn __errfunc,
                               glob_t *_Restrict_ __pglob));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (glob);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef glob
 # if HAVE_RAW_DECL_GLOB
diff --git a/m4/glob.m4 b/m4/glob.m4
index 9365f3362d..62be6a3397 100644
--- a/m4/glob.m4
+++ b/m4/glob.m4
@@ -1,4 +1,4 @@
-# glob.m4 serial 29
+# glob.m4 serial 30
 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,9 @@ AC_DEFUN([gl_GLOB],
   gl_CHECK_FUNCS_ANDROID([glob], [[#include <glob.h>]])
   if test $ac_cv_func_glob = no; then
     HAVE_GLOB=0
+    case "$gl_cv_onwards_func_glob" in
+      future*) REPLACE_GLOB=1 ;;
+    esac
   else
 
     AC_CACHE_CHECK([for GNU glob interface version 1 or 2],
-- 
2.34.1


[-- Attachment #43: 0042-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 10554 bytes --]

From efd13f2f20f8fbd178fd5dff28b5f31219ea0538 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:41:07 +0100
Subject: [PATCH 42/47] Resolve conflicts for functions introduced in Android
 API level 28.

* m4/spawn_h.m4 (gl_HAVE_POSIX_SPAWN): Conditionally set
REPLACE_POSIX_SPAWN.
* lib/spawn.in.h: Adapt logic for defining the POSIX_SPAWN_* constants.
(posix_spawn, posix_spawnp, posix_spawnattr_init,
posix_spawnattr_destroy, posix_spawnattr_getsigdefault,
posix_spawnattr_setsigdefault, posix_spawnattr_getsigmask,
posix_spawnattr_setsigmask, posix_spawnattr_getflags,
posix_spawnattr_setflags, posix_spawnattr_getpgroup,
posix_spawnattr_setpgroup, posix_spawn_file_actions_init,
posix_spawn_file_actions_destroy, posix_spawn_file_actions_addchdir,
posix_spawn_file_actions_addfchdir): Disable _GL_CXXALIASWARN invocation
on non-glibc systems.
---
 ChangeLog      | 13 ++++++++++
 lib/spawn.in.h | 64 +++++++++++++++++++++++++++++++++++++-------------
 m4/spawn_h.m4  |  5 +++-
 3 files changed, 65 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 152b3399fa..5d85124904 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,19 @@
 
 	Resolve conflicts for functions introduced in Android API level 28.
 
+	* m4/spawn_h.m4 (gl_HAVE_POSIX_SPAWN): Conditionally set
+	REPLACE_POSIX_SPAWN.
+	* lib/spawn.in.h: Adapt logic for defining the POSIX_SPAWN_* constants.
+	(posix_spawn, posix_spawnp, posix_spawnattr_init,
+	posix_spawnattr_destroy, posix_spawnattr_getsigdefault,
+	posix_spawnattr_setsigdefault, posix_spawnattr_getsigmask,
+	posix_spawnattr_setsigmask, posix_spawnattr_getflags,
+	posix_spawnattr_setflags, posix_spawnattr_getpgroup,
+	posix_spawnattr_setpgroup, posix_spawn_file_actions_init,
+	posix_spawn_file_actions_destroy, posix_spawn_file_actions_addchdir,
+	posix_spawn_file_actions_addfchdir): Disable _GL_CXXALIASWARN invocation
+	on non-glibc systems.
+
 	* m4/glob.m4 (gl_GLOB): Conditionally set REPLACE_GLOB.
 	* lib/glob.in.h (glob): Disable _GL_CXXALIASWARN invocation on non-glibc
 	systems.
diff --git a/lib/spawn.in.h b/lib/spawn.in.h
index 38cdf09912..958464a7d2 100644
--- a/lib/spawn.in.h
+++ b/lib/spawn.in.h
@@ -144,26 +144,26 @@ typedef struct
 
 /* Flags to be set in the 'posix_spawnattr_t'.  */
 #if @HAVE_POSIX_SPAWN@
+# if !@REPLACE_POSIX_SPAWN@
 /* Use the values from the system, but provide the missing ones.  */
-# ifndef POSIX_SPAWN_SETSCHEDPARAM
-#  define POSIX_SPAWN_SETSCHEDPARAM 0
-# endif
-# ifndef POSIX_SPAWN_SETSCHEDULER
-#  define POSIX_SPAWN_SETSCHEDULER 0
-# endif
-#else
-# if @REPLACE_POSIX_SPAWN@
+#  ifndef POSIX_SPAWN_SETSCHEDPARAM
+#   define POSIX_SPAWN_SETSCHEDPARAM 0
+#  endif
+#  ifndef POSIX_SPAWN_SETSCHEDULER
+#   define POSIX_SPAWN_SETSCHEDULER 0
+#  endif
+# else /* @REPLACE_POSIX_SPAWN@ */
 /* Use the values from the system, for better compatibility.  */
 /* But this implementation does not support AIX extensions.  */
-#  undef POSIX_SPAWN_FORK_HANDLERS
-# else
-#  define POSIX_SPAWN_RESETIDS           0x01
-#  define POSIX_SPAWN_SETPGROUP          0x02
-#  define POSIX_SPAWN_SETSIGDEF          0x04
-#  define POSIX_SPAWN_SETSIGMASK         0x08
-#  define POSIX_SPAWN_SETSCHEDPARAM      0x10
-#  define POSIX_SPAWN_SETSCHEDULER       0x20
+#   undef POSIX_SPAWN_FORK_HANDLERS
 # endif
+#else /* !@HAVE_POSIX_SPAWN@ */
+# define POSIX_SPAWN_RESETIDS           0x01
+# define POSIX_SPAWN_SETPGROUP          0x02
+# define POSIX_SPAWN_SETSIGDEF          0x04
+# define POSIX_SPAWN_SETSIGMASK         0x08
+# define POSIX_SPAWN_SETSCHEDPARAM      0x10
+# define POSIX_SPAWN_SETSCHEDULER       0x20
 #endif
 /* A GNU extension.  Use the next free bit position.  */
 #ifndef POSIX_SPAWN_USEVFORK
@@ -234,7 +234,9 @@ _GL_CXXALIAS_SYS (posix_spawn, int,
                    char *const argv[_Restrict_arr_],
                    char *const envp[_Restrict_arr_]));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawn);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawn
 # if HAVE_RAW_DECL_POSIX_SPAWN
@@ -278,7 +280,9 @@ _GL_CXXALIAS_SYS (posix_spawnp, int,
                    const posix_spawnattr_t *__attrp,
                    char *const argv[], char *const envp[]));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnp);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnp
 # if HAVE_RAW_DECL_POSIX_SPAWNP
@@ -304,7 +308,9 @@ _GL_FUNCDECL_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr)
 #  endif
 _GL_CXXALIAS_SYS (posix_spawnattr_init, int, (posix_spawnattr_t *__attr));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnattr_init);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnattr_init
 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_INIT
@@ -329,7 +335,9 @@ _GL_FUNCDECL_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr)
 #  endif
 _GL_CXXALIAS_SYS (posix_spawnattr_destroy, int, (posix_spawnattr_t *__attr));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnattr_destroy);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnattr_destroy
 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_DESTROY
@@ -364,7 +372,9 @@ _GL_CXXALIAS_SYS (posix_spawnattr_getsigdefault, int,
                   (const posix_spawnattr_t *_Restrict_ __attr,
                    sigset_t *_Restrict_ __sigdefault));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnattr_getsigdefault);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnattr_getsigdefault
 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGDEFAULT
@@ -398,7 +408,9 @@ _GL_CXXALIAS_SYS (posix_spawnattr_setsigdefault, int,
                   (posix_spawnattr_t *_Restrict_ __attr,
                    const sigset_t *_Restrict_ __sigdefault));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnattr_setsigdefault);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnattr_setsigdefault
 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGDEFAULT
@@ -432,7 +444,9 @@ _GL_CXXALIAS_SYS (posix_spawnattr_getsigmask, int,
                   (const posix_spawnattr_t *_Restrict_ __attr,
                    sigset_t *_Restrict_ __sigmask));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnattr_getsigmask);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnattr_getsigmask
 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETSIGMASK
@@ -466,7 +480,9 @@ _GL_CXXALIAS_SYS (posix_spawnattr_setsigmask, int,
                   (posix_spawnattr_t *_Restrict_ __attr,
                    const sigset_t *_Restrict_ __sigmask));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnattr_setsigmask);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnattr_setsigmask
 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETSIGMASK
@@ -500,7 +516,9 @@ _GL_CXXALIAS_SYS (posix_spawnattr_getflags, int,
                   (const posix_spawnattr_t *_Restrict_ __attr,
                    short int *_Restrict_ __flags));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnattr_getflags);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnattr_getflags
 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETFLAGS
@@ -530,7 +548,9 @@ _GL_FUNCDECL_SYS (posix_spawnattr_setflags, int,
 _GL_CXXALIAS_SYS (posix_spawnattr_setflags, int,
                   (posix_spawnattr_t *__attr, short int __flags));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnattr_setflags);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnattr_setflags
 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETFLAGS
@@ -564,7 +584,9 @@ _GL_CXXALIAS_SYS (posix_spawnattr_getpgroup, int,
                   (const posix_spawnattr_t *_Restrict_ __attr,
                    pid_t *_Restrict_ __pgroup));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnattr_getpgroup);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnattr_getpgroup
 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_GETPGROUP
@@ -594,7 +616,9 @@ _GL_FUNCDECL_SYS (posix_spawnattr_setpgroup, int,
 _GL_CXXALIAS_SYS (posix_spawnattr_setpgroup, int,
                   (posix_spawnattr_t *__attr, pid_t __pgroup));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawnattr_setpgroup);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawnattr_setpgroup
 # if HAVE_RAW_DECL_POSIX_SPAWNATTR_SETPGROUP
@@ -765,7 +789,9 @@ _GL_FUNCDECL_SYS (posix_spawn_file_actions_init, int,
 _GL_CXXALIAS_SYS (posix_spawn_file_actions_init, int,
                   (posix_spawn_file_actions_t *__file_actions));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawn_file_actions_init);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawn_file_actions_init
 # if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_INIT
@@ -795,7 +821,9 @@ _GL_FUNCDECL_SYS (posix_spawn_file_actions_destroy, int,
 _GL_CXXALIAS_SYS (posix_spawn_file_actions_destroy, int,
                   (posix_spawn_file_actions_t *__file_actions));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawn_file_actions_destroy);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawn_file_actions_destroy
 # if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_DESTROY
@@ -941,7 +969,9 @@ _GL_CXXALIAS_SYS (posix_spawn_file_actions_addchdir, int,
                   (posix_spawn_file_actions_t *_Restrict_ __file_actions,
                    const char *_Restrict_ __path));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawn_file_actions_addchdir);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawn_file_actions_addchdir
 # if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
@@ -976,7 +1006,9 @@ _GL_CXXALIAS_SYS (posix_spawn_file_actions_addfchdir, int,
                   (posix_spawn_file_actions_t *_Restrict_ __file_actions,
                    int __fd));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (posix_spawn_file_actions_addfchdir);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef posix_spawn_file_actions_addfchdir
 # if HAVE_RAW_DECL_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR
diff --git a/m4/spawn_h.m4 b/m4/spawn_h.m4
index 3bee0f7be4..b7b9a61342 100644
--- a/m4/spawn_h.m4
+++ b/m4/spawn_h.m4
@@ -1,4 +1,4 @@
-# spawn_h.m4 serial 23
+# spawn_h.m4 serial 24
 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,
@@ -79,6 +79,9 @@ AC_DEFUN([gl_HAVE_POSIX_SPAWN],
 
   if test $ac_cv_func_posix_spawn != yes; then
     HAVE_POSIX_SPAWN=0
+    case "$gl_cv_onwards_func_posix_spawn" in
+      future*) REPLACE_POSIX_SPAWN=1 ;;
+    esac
   fi
 ])
 
-- 
2.34.1


[-- Attachment #44: 0043-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2221 bytes --]

From 3056396bd90cf910aa761a25be735ef0327f6516 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:43:32 +0100
Subject: [PATCH 43/47] Resolve conflicts for functions introduced in Android
 API level 28.

* m4/getlogin_r.m4 (gl_FUNC_GETLOGIN_R): Conditionally set
REPLACE_GETLOGIN_R.
* lib/unistd.in.h (getlogin_r): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog        | 5 +++++
 lib/unistd.in.h  | 2 ++
 m4/getlogin_r.m4 | 5 ++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 5d85124904..5d89546b44 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
 	Resolve conflicts for functions introduced in Android API level 28.
 
+	* m4/getlogin_r.m4 (gl_FUNC_GETLOGIN_R): Conditionally set
+	REPLACE_GETLOGIN_R.
+	* lib/unistd.in.h (getlogin_r): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* m4/spawn_h.m4 (gl_HAVE_POSIX_SPAWN): Conditionally set
 	REPLACE_POSIX_SPAWN.
 	* lib/spawn.in.h: Adapt logic for defining the POSIX_SPAWN_* constants.
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 8016f7345e..bfc501e5a7 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1356,7 +1356,9 @@ _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
                                                      int size.  */
 _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (getlogin_r);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef getlogin_r
 # if HAVE_RAW_DECL_GETLOGIN_R
diff --git a/m4/getlogin_r.m4 b/m4/getlogin_r.m4
index cbfe255ee1..4383ea6a02 100644
--- a/m4/getlogin_r.m4
+++ b/m4/getlogin_r.m4
@@ -1,4 +1,4 @@
-#serial 14
+#serial 15
 
 # Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc.
 #
@@ -28,6 +28,9 @@ AC_DEFUN([gl_FUNC_GETLOGIN_R],
   gl_CHECK_FUNCS_ANDROID([getlogin_r], [[#include <unistd.h>]])
   if test $ac_cv_func_getlogin_r = no; then
     HAVE_GETLOGIN_R=0
+    case "$gl_cv_onwards_func_getlogin_r" in
+      future*) REPLACE_GETLOGIN_R=1 ;;
+    esac
   else
     HAVE_GETLOGIN_R=1
     dnl On Mac OS X 10.13 and OSF/1 5.1, getlogin_r returns a truncated result
-- 
2.34.1


[-- Attachment #45: 0044-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2488 bytes --]

From 99acf8c353e544dd7894ec5e192cdb1aee52a55c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:44:44 +0100
Subject: [PATCH 44/47] Resolve conflicts for functions introduced in Android
 API level 28.

* m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Conditionally set
REPLACE_ALIGNED_ALLOC.
* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Conditionally set
REPLACE_GETRANDOM.
---
 ChangeLog           | 5 +++++
 m4/aligned_alloc.m4 | 5 ++++-
 m4/getrandom.m4     | 5 ++++-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5d89546b44..d06ffacce2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
 	Resolve conflicts for functions introduced in Android API level 28.
 
+	* m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Conditionally set
+	REPLACE_ALIGNED_ALLOC.
+	* m4/getrandom.m4 (gl_FUNC_GETRANDOM): Conditionally set
+	REPLACE_GETRANDOM.
+
 	* m4/getlogin_r.m4 (gl_FUNC_GETLOGIN_R): Conditionally set
 	REPLACE_GETLOGIN_R.
 	* lib/unistd.in.h (getlogin_r): Disable _GL_CXXALIASWARN invocation on
diff --git a/m4/aligned_alloc.m4 b/m4/aligned_alloc.m4
index d088701dbc..8b4c10102e 100644
--- a/m4/aligned_alloc.m4
+++ b/m4/aligned_alloc.m4
@@ -1,4 +1,4 @@
-# aligned_alloc.m4 serial 4
+# aligned_alloc.m4 serial 5
 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,
@@ -44,5 +44,8 @@ AC_DEFUN([gl_FUNC_ALIGNED_ALLOC],
   else
     dnl The system does not have aligned_alloc.
     HAVE_ALIGNED_ALLOC=0
+    case "$gl_cv_onwards_func_aligned_alloc" in
+      future*) REPLACE_ALIGNED_ALLOC=1 ;;
+    esac
   fi
 ])
diff --git a/m4/getrandom.m4 b/m4/getrandom.m4
index c508f1a55c..7b7f9ce2ee 100644
--- a/m4/getrandom.m4
+++ b/m4/getrandom.m4
@@ -1,4 +1,4 @@
-# getrandom.m4 serial 10
+# getrandom.m4 serial 11
 dnl Copyright 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,
@@ -18,6 +18,9 @@ AC_DEFUN([gl_FUNC_GETRANDOM],
     ]])
   if test "$ac_cv_func_getrandom" != yes; then
     HAVE_GETRANDOM=0
+    case "$gl_cv_onwards_func_getrandom" in
+      future*) REPLACE_GETRANDOM=1 ;;
+    esac
   else
     dnl On Solaris 11.4 the return type is 'int', not 'ssize_t'.
     AC_CACHE_CHECK([whether getrandom is compatible with its GNU+BSD signature],
-- 
2.34.1


[-- Attachment #46: 0045-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 8156 bytes --]

From 2eaaeea01ce0ad1bead7ffe8bfbe10f06fa8c9d2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:45:14 +0100
Subject: [PATCH 45/47] Resolve conflicts for functions introduced in Android
 API level 29.

* lib/time.in.h (timespec_get): Consider REPLACE_TIMESPEC_GET. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
* m4/time_h.m4 (gl_TIME_H_DEFAULTS): Initialize REPLACE_TIMESPEC_GET.
* modules/time (Makefile.am): Substitute REPLACE_TIMESPEC_GET.
* m4/gettime.m4 (gl_CHECK_FUNC_TIMESPEC_GET): Set also
gl_cv_onwards_func_timespec_get.
* m4/timespec_get.m4 (gl_FUNC_TIMESPEC_GET): Conditionally set
REPLACE_TIMESPEC_GET.
* modules/timespec_get (Depends-on, configure.ac): Consider
REPLACE_TIMESPEC_GET.
---
 ChangeLog            | 15 +++++++++++++++
 lib/time.in.h        | 16 ++++++++++++++--
 m4/gettime.m4        | 35 ++++++++++++++++++++++++-----------
 m4/time_h.m4         |  3 ++-
 m4/timespec_get.m4   |  5 ++++-
 modules/time         |  1 +
 modules/timespec_get |  5 +++--
 7 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d06ffacce2..1ce418acc0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 29.
+
+	* lib/time.in.h (timespec_get): Consider REPLACE_TIMESPEC_GET. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	* m4/time_h.m4 (gl_TIME_H_DEFAULTS): Initialize REPLACE_TIMESPEC_GET.
+	* modules/time (Makefile.am): Substitute REPLACE_TIMESPEC_GET.
+	* m4/gettime.m4 (gl_CHECK_FUNC_TIMESPEC_GET): Set also
+	gl_cv_onwards_func_timespec_get.
+	* m4/timespec_get.m4 (gl_FUNC_TIMESPEC_GET): Conditionally set
+	REPLACE_TIMESPEC_GET.
+	* modules/timespec_get (Depends-on, configure.ac): Consider
+	REPLACE_TIMESPEC_GET.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
 	Resolve conflicts for functions introduced in Android API level 28.
diff --git a/lib/time.in.h b/lib/time.in.h
index fa0c6351b2..87cda21413 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -112,12 +112,24 @@ struct __time_t_must_be_integral {
 /* Set *TS to the current time, and return BASE.
    Upon failure, return 0.  */
 # if @GNULIB_TIMESPEC_GET@
-#  if ! @HAVE_TIMESPEC_GET@
+#  if @REPLACE_TIMESPEC_GET@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef timespec_get
+#    define timespec_get rpl_timespec_get
+#   endif
+_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base)
+                                     _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base));
+#  else
+#   if !@HAVE_TIMESPEC_GET@
 _GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base)
                                      _GL_ARG_NONNULL ((1)));
-#  endif
+#   endif
 _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
+#  endif
+#  if __GLIBC__ >= 2
 _GL_CXXALIASWARN (timespec_get);
+#  endif
 # endif
 
 /* Set *TS to the current time resolution, and return BASE.
diff --git a/m4/gettime.m4 b/m4/gettime.m4
index 7e353fcd00..ec1f97ee0d 100644
--- a/m4/gettime.m4
+++ b/m4/gettime.m4
@@ -1,4 +1,4 @@
-# gettime.m4 serial 13
+# gettime.m4 serial 14
 dnl Copyright (C) 2002, 2004-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,
@@ -18,9 +18,11 @@ AC_DEFUN([gl_GETTIME],
 ])
 
 dnl Tests whether the function timespec_get exists.
-dnl Sets gl_cv_func_timespec_get.
+dnl Sets gl_cv_func_timespec_get and gl_cv_onwards_func_timespec_get.
 AC_DEFUN([gl_CHECK_FUNC_TIMESPEC_GET],
 [
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
   dnl Persuade OpenBSD <time.h> to declare timespec_get().
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
@@ -29,21 +31,32 @@ AC_DEFUN([gl_CHECK_FUNC_TIMESPEC_GET],
   dnl But at the same time, we need to notice a missing declaration, like
   dnl gl_CHECK_FUNCS_ANDROID does.
   AC_CHECK_DECL([timespec_get], , , [[#include <time.h>]])
-  if test $ac_cv_have_decl_timespec_get = yes; then
-    AC_CACHE_CHECK([for timespec_get], [gl_cv_func_timespec_get],
-      [AC_LINK_IFELSE(
+  AC_CACHE_CHECK([for timespec_get], [gl_cv_onwards_func_timespec_get],
+    [if test $ac_cv_have_decl_timespec_get = yes; then
+       AC_LINK_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <time.h>
               struct timespec ts;
             ]],
             [[return timespec_get (&ts, 0);]])
          ],
-         [gl_cv_func_timespec_get=yes],
-         [gl_cv_func_timespec_get=no])
-      ])
-  else
-    gl_cv_func_timespec_get=no
-  fi
+         [gl_cv_onwards_func_timespec_get=yes],
+         [gl_cv_onwards_func_timespec_get=no])
+     else
+       gl_cv_onwards_func_timespec_get=no
+     fi
+     case "$host_os" in
+       linux*-android*)
+         if test $gl_cv_onwards_func_timespec_get = no; then
+           gl_cv_onwards_func_timespec_get='future OS version'
+         fi
+         ;;
+     esac
+    ])
+  case "$gl_cv_onwards_func_timespec_get" in
+    future*) gl_cv_func_timespec_get=no ;;
+    *)       gl_cv_func_timespec_get=$gl_cv_onwards_func_timespec_get ;;
+  esac
 ])
 
 AC_DEFUN([gl_GETTIME_RES],
diff --git a/m4/time_h.m4 b/m4/time_h.m4
index f6bf3a4f30..b74870c3d0 100644
--- a/m4/time_h.m4
+++ b/m4/time_h.m4
@@ -2,7 +2,7 @@
 
 # Copyright (C) 2000-2001, 2003-2007, 2009-2023 Free Software Foundation, Inc.
 
-# serial 20
+# serial 21
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -170,6 +170,7 @@ AC_DEFUN([gl_TIME_H_DEFAULTS],
   REPLACE_NANOSLEEP=GNULIB_PORTCHECK;    AC_SUBST([REPLACE_NANOSLEEP])
   REPLACE_STRFTIME=GNULIB_PORTCHECK;     AC_SUBST([REPLACE_STRFTIME])
   REPLACE_TIMEGM=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_TIMEGM])
+  REPLACE_TIMESPEC_GET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMESPEC_GET])
   REPLACE_TZSET=GNULIB_PORTCHECK;        AC_SUBST([REPLACE_TZSET])
 
   dnl Hack so that the time module doesn't depend on the sys_time module.
diff --git a/m4/timespec_get.m4 b/m4/timespec_get.m4
index 866ba5003a..61e4bc378b 100644
--- a/m4/timespec_get.m4
+++ b/m4/timespec_get.m4
@@ -1,4 +1,4 @@
-# timespec_get.m4 serial 3
+# timespec_get.m4 serial 4
 dnl Copyright (C) 2021-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,5 +14,8 @@ AC_DEFUN([gl_FUNC_TIMESPEC_GET],
   AC_REQUIRE([gl_CHECK_FUNC_TIMESPEC_GET])
   if test $gl_cv_func_timespec_get != yes; then
     HAVE_TIMESPEC_GET=0
+    case "$gl_cv_onwards_func_timespec_get" in
+      future*) REPLACE_TIMESPEC_GET=1 ;;
+    esac
   fi
 ])
diff --git a/modules/time b/modules/time
index ae8471bb9e..75ff3a4d8c 100644
--- a/modules/time
+++ b/modules/time
@@ -60,6 +60,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
 	      -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
 	      -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \
 	      -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+	      -e 's|@''REPLACE_TIMESPEC_GET''@|$(REPLACE_TIMESPEC_GET)|g' \
 	      -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \
 	      -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
 	      -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
diff --git a/modules/timespec_get b/modules/timespec_get
index b1b33b494d..7b3dc3b01d 100644
--- a/modules/timespec_get
+++ b/modules/timespec_get
@@ -8,11 +8,12 @@ m4/timespec_get.m4
 Depends-on:
 time
 extensions
-gettime         [test $HAVE_TIMESPEC_GET = 0]
+gettime         [test $HAVE_TIMESPEC_GET = 0 || test $REPLACE_TIMESPEC_GET = 1]
 
 configure.ac:
 gl_FUNC_TIMESPEC_GET
-gl_CONDITIONAL([GL_COND_OBJ_TIMESPEC_GET], [test $HAVE_TIMESPEC_GET = 0])
+gl_CONDITIONAL([GL_COND_OBJ_TIMESPEC_GET],
+               [test $HAVE_TIMESPEC_GET = 0 || test $REPLACE_TIMESPEC_GET = 1])
 gl_TIME_MODULE_INDICATOR([timespec_get])
 
 Makefile.am:
-- 
2.34.1


[-- Attachment #47: 0046-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 6303 bytes --]

From d81d019c306caa907f8d7e978072a3bdac2c7713 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:47:09 +0100
Subject: [PATCH 46/47] Resolve conflicts for functions introduced in Android
 API level 29.

* lib/stdlib.in.h (getloadavg): Consider REPLACE_GETLOADAVG. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_GETLOADAVG.
* modules/stdlib (Makefile.am): Substitute REPLACE_GETLOADAVG.
* m4/getloadavg.m4 (gl_GETLOADAVG): Conditionally set
REPLACE_GETLOADAVG.
* modules/getloadavg (Depends-on, configure.ac): Consider
REPLACE_GETLOADAVG.
---
 ChangeLog          |  9 +++++++++
 lib/stdlib.in.h    | 16 ++++++++++++++--
 m4/getloadavg.m4   |  6 +++++-
 m4/stdlib_h.m4     |  3 ++-
 modules/getloadavg | 11 ++++++-----
 modules/stdlib     |  1 +
 6 files changed, 37 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1ce418acc0..9836300631 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,15 @@
 
 	Resolve conflicts for functions introduced in Android API level 29.
 
+	* lib/stdlib.in.h (getloadavg): Consider REPLACE_GETLOADAVG. Disable
+	_GL_CXXALIASWARN invocation on non-glibc systems.
+	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_GETLOADAVG.
+	* modules/stdlib (Makefile.am): Substitute REPLACE_GETLOADAVG.
+	* m4/getloadavg.m4 (gl_GETLOADAVG): Conditionally set
+	REPLACE_GETLOADAVG.
+	* modules/getloadavg (Depends-on, configure.ac): Consider
+	REPLACE_GETLOADAVG.
+
 	* lib/time.in.h (timespec_get): Consider REPLACE_TIMESPEC_GET. Disable
 	_GL_CXXALIASWARN invocation on non-glibc systems.
 	* m4/time_h.m4 (gl_TIME_H_DEFAULTS): Initialize REPLACE_TIMESPEC_GET.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index c03f46ee38..ba1d8bff4e 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -427,12 +427,24 @@ _GL_CXXALIASWARN (gcvt);
    The three numbers are the load average of the last 1 minute, the last 5
    minutes, and the last 15 minutes, respectively.
    LOADAVG is an array of NELEM numbers.  */
-# if !@HAVE_DECL_GETLOADAVG@
+# if @REPLACE_GETLOADAVG@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef getloadavg
+#   define getloadavg rpl_getloadavg
+#  endif
+_GL_FUNCDECL_RPL (getloadavg, int, (double loadavg[], int nelem)
+                                   _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (getloadavg, int, (double loadavg[], int nelem));
+# else
+#  if !@HAVE_DECL_GETLOADAVG@
 _GL_FUNCDECL_SYS (getloadavg, int, (double loadavg[], int nelem)
                                    _GL_ARG_NONNULL ((1)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (getloadavg, int, (double loadavg[], int nelem));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (getloadavg);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef getloadavg
 # if HAVE_RAW_DECL_GETLOADAVG
diff --git a/m4/getloadavg.m4 b/m4/getloadavg.m4
index 067f142abc..ee83b32f1e 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 11
+#serial 12
 
 # Autoconf defines AC_FUNC_GETLOADAVG, but that is obsolescent.
 # New applications should use gl_GETLOADAVG instead.
@@ -27,6 +27,10 @@ gl_save_LIBS=$LIBS
 HAVE_GETLOADAVG=1
 gl_CHECK_FUNCS_ANDROID([getloadavg], [[#include <stdlib.h>]])
 if test $ac_cv_func_getloadavg != yes; then
+   case "$gl_cv_onwards_func_getloadavg" in
+     future*) REPLACE_GETLOADAVG=1 ;;
+   esac
+
    gl_func_getloadavg_done=no
 
    # Some systems with -lutil have (and need) -lkvm as well, some do not.
diff --git a/m4/stdlib_h.m4 b/m4/stdlib_h.m4
index ee1f48ee5a..249ef65722 100644
--- a/m4/stdlib_h.m4
+++ b/m4/stdlib_h.m4
@@ -1,4 +1,4 @@
-# stdlib_h.m4 serial 70
+# stdlib_h.m4 serial 71
 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,
@@ -174,6 +174,7 @@ AC_DEFUN([gl_STDLIB_H_DEFAULTS],
   REPLACE_CALLOC_FOR_CALLOC_POSIX=0;  AC_SUBST([REPLACE_CALLOC_FOR_CALLOC_POSIX])
   REPLACE_CANONICALIZE_FILE_NAME=0;  AC_SUBST([REPLACE_CANONICALIZE_FILE_NAME])
   REPLACE_FREE=0;            AC_SUBST([REPLACE_FREE])
+  REPLACE_GETLOADAVG=0;      AC_SUBST([REPLACE_GETLOADAVG])
   REPLACE_GETPROGNAME=0;     AC_SUBST([REPLACE_GETPROGNAME])
   REPLACE_GETSUBOPT=0;       AC_SUBST([REPLACE_GETSUBOPT])
   REPLACE_INITSTATE=0;       AC_SUBST([REPLACE_INITSTATE])
diff --git a/modules/getloadavg b/modules/getloadavg
index 9a5553ebba..fcd4352d28 100644
--- a/modules/getloadavg
+++ b/modules/getloadavg
@@ -7,15 +7,16 @@ m4/getloadavg.m4
 
 Depends-on:
 extensions
-intprops  [test $HAVE_GETLOADAVG = 0]
-open      [case $host_os in mingw*) false;; *) test $HAVE_GETLOADAVG = 0;; esac]
-stdbool   [test $HAVE_GETLOADAVG = 0]
-stdlib    [test $HAVE_GETLOADAVG = 0]
+intprops  [test $HAVE_GETLOADAVG = 0 || test $REPLACE_GETLOADAVG = 1]
+open      [case $host_os in mingw*) false;; *) test $HAVE_GETLOADAVG = 0 || test $REPLACE_GETLOADAVG = 1;; esac]
+stdbool   [test $HAVE_GETLOADAVG = 0 || test $REPLACE_GETLOADAVG = 1]
+stdlib    [test $HAVE_GETLOADAVG = 0 || test $REPLACE_GETLOADAVG = 1]
 
 configure.ac:
 AC_REQUIRE([AC_CANONICAL_HOST])
 gl_GETLOADAVG
-gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG], [test $HAVE_GETLOADAVG = 0])
+gl_CONDITIONAL([GL_COND_OBJ_GETLOADAVG],
+               [test $HAVE_GETLOADAVG = 0 || test $REPLACE_GETLOADAVG = 1])
 AM_COND_IF([GL_COND_OBJ_GETLOADAVG], [
   gl_PREREQ_GETLOADAVG
 ])
diff --git a/modules/stdlib b/modules/stdlib
index 5ae3e6665d..bafeb214ee 100644
--- a/modules/stdlib
+++ b/modules/stdlib
@@ -134,6 +134,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status $(CXXDEFS_H) \
 	      -e 's|@''REPLACE_CALLOC_FOR_CALLOC_POSIX''@|$(REPLACE_CALLOC_FOR_CALLOC_POSIX)|g' \
 	      -e 's|@''REPLACE_CANONICALIZE_FILE_NAME''@|$(REPLACE_CANONICALIZE_FILE_NAME)|g' \
 	      -e 's|@''REPLACE_FREE''@|$(REPLACE_FREE)|g' \
+	      -e 's|@''REPLACE_GETLOADAVG''@|$(REPLACE_GETLOADAVG)|g' \
 	      -e 's|@''REPLACE_GETPROGNAME''@|$(REPLACE_GETPROGNAME)|g' \
 	      -e 's|@''REPLACE_GETSUBOPT''@|$(REPLACE_GETSUBOPT)|g' \
 	      -e 's|@''REPLACE_INITSTATE''@|$(REPLACE_INITSTATE)|g' \
-- 
2.34.1


[-- Attachment #48: 0047-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2368 bytes --]

From 1b410d477f4021e86f5594b84f5bd8170e676485 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 22 Jan 2023 14:49:05 +0100
Subject: [PATCH 47/47] Resolve conflicts for functions introduced in Android
 API level 29.

* m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY): Conditionally set
REPLACE_REALLOCARRAY.
* lib/stdlib.in.h (reallocarray): Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
---
 ChangeLog          | 5 +++++
 lib/stdlib.in.h    | 2 ++
 m4/reallocarray.m4 | 5 ++++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 9836300631..33473610a5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 
 	Resolve conflicts for functions introduced in Android API level 29.
 
+	* m4/reallocarray.m4 (gl_FUNC_REALLOCARRAY): Conditionally set
+	REPLACE_REALLOCARRAY.
+	* lib/stdlib.in.h (reallocarray): Disable _GL_CXXALIASWARN invocation on
+	non-glibc systems.
+
 	* lib/stdlib.in.h (getloadavg): Consider REPLACE_GETLOADAVG. Disable
 	_GL_CXXALIASWARN invocation on non-glibc systems.
 	* m4/stdlib_h.m4 (gl_STDLIB_H_DEFAULTS): Initialize REPLACE_GETLOADAVG.
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index ba1d8bff4e..a91f4e23d6 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -1280,7 +1280,9 @@ _GL_FUNCDECL_SYS (reallocarray, void *,
 _GL_CXXALIAS_SYS (reallocarray, void *,
                   (void *ptr, size_t nmemb, size_t size));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (reallocarray);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef reallocarray
 # if HAVE_RAW_DECL_REALLOCARRAY
diff --git a/m4/reallocarray.m4 b/m4/reallocarray.m4
index 4be7cd1be2..6a5b5ab344 100644
--- a/m4/reallocarray.m4
+++ b/m4/reallocarray.m4
@@ -1,4 +1,4 @@
-# reallocarray.m4 serial 4
+# reallocarray.m4 serial 5
 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,
@@ -14,6 +14,9 @@ AC_DEFUN([gl_FUNC_REALLOCARRAY],
   gl_CHECK_FUNCS_ANDROID([reallocarray], [[#include <stdlib.h>]])
   if test "$ac_cv_func_reallocarray" = no; then
     HAVE_REALLOCARRAY=0
+    case "$gl_cv_onwards_func_reallocarray" in
+      future*) REPLACE_REALLOCARRAY=1 ;;
+    esac
   elif test "$gl_cv_malloc_ptrdiff" = no; then
     REPLACE_REALLOCARRAY=1
   fi
-- 
2.34.1


                 reply	other threads:[~2023-01-22 15:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4608453.guUeLoCLYh@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).