bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Resolve conflicts for functions introduced in Android API level 34
@ 2024-01-25 23:23 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2024-01-25 23:23 UTC (permalink / raw)
  To: bug-gnulib

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

At level 34 the added functions are:

<stdio_ext.h>
__freadahead

<string.h>
memset_explicit

<spawn.h>
posix_spawn_file_actions_addchdir_np
posix_spawn_file_actions_addfchdir_np

<unistd.h>
copy_file_range
close_range

Here are the corresponding adjustments in Gnulib.


2024-01-25  Bruno Haible  <bruno@clisp.org>

	Resolve conflicts for functions introduced in Android API level 34.

	* m4/copy-file-range.m4 (gl_FUNC_COPY_FILE_RANGE): On platforms without
	glibc, test for copy_file_range using gl_CHECK_FUNCS_ANDROID instead of
	AC_CHECK_FUNCS_ONCE. Conditionally set REPLACE_COPY_FILE_RANGE.
	* doc/glibc-functions/copy_file_range.texi: Mention the Android API
	levels.

	* m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): Test for
	posix_spawn_file_actions_addchdir_np and
	posix_spawn_file_actions_addfchdir_np using gl_CHECK_FUNCS_ANDROID
	instead of AC_CHECK_FUNCS_ONCE.
	* m4/posix_spawn_faction_addchdir.m4
	(gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR): Test for
	posix_spawn_file_actions_addchdir_np using gl_CHECK_FUNCS_ANDROID
	instead of AC_CHECK_FUNCS_ONCE.
	* m4/posix_spawn_faction_addfchdir.m4
	(gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR): Test for
	posix_spawn_file_actions_addfchdir_np using gl_CHECK_FUNCS_ANDROID
	instead of AC_CHECK_FUNCS_ONCE.
	* doc/glibc-functions/posix_spawn_file_actions_addchdir_np.texi: Mention
	the Android API levels.
	* doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi:
	Likewise.

	* lib/string.in.h (memset_explicit): Consider REPLACE_MEMSET_EXPLICIT.
	* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize
	REPLACE_MEMSET_EXPLICIT.
	* modules/string (Makefile.am): Substitute REPLACE_MEMSET_EXPLICIT.
	* m4/memset_explicit.m4 (gl_FUNC_MEMSET_EXPLICIT): Test for
	memset_explicit using gl_CHECK_FUNCS_ANDROID instead of
	AC_CHECK_FUNCS_ONCE. Conditionally set REPLACE_MEMSET_EXPLICIT.
	* modules/memset_explicit (configure.ac): Consider
	REPLACE_MEMSET_EXPLICIT.
	* doc/posix-functions/memset_explicit.texi: Mention the Android API
	levels.

	* m4/freadahead.m4 (gl_FUNC_FREADAHEAD): Test for __freadahead using
	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
	* lib/freadahead.h: Update comment.


[-- Attachment #2: 0001-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 2064 bytes --]

From 22c809356688118b5fcc96229788150ed780a747 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Fri, 26 Jan 2024 00:18:45 +0100
Subject: [PATCH 1/4] Resolve conflicts for functions introduced in Android API
 level 34.

* m4/freadahead.m4 (gl_FUNC_FREADAHEAD): Test for __freadahead using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
* lib/freadahead.h: Update comment.
---
 ChangeLog        | 8 ++++++++
 lib/freadahead.h | 2 +-
 m4/freadahead.m4 | 4 ++--
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 46dcdf9c4e..5e7b4d90b4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-01-25  Bruno Haible  <bruno@clisp.org>
+
+	Resolve conflicts for functions introduced in Android API level 34.
+
+	* m4/freadahead.m4 (gl_FUNC_FREADAHEAD): Test for __freadahead using
+	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
+	* lib/freadahead.h: Update comment.
+
 2024-01-25  Bruno Haible  <bruno@clisp.org>
 
 	Doc regarding functions introduced in Android API level 33.
diff --git a/lib/freadahead.h b/lib/freadahead.h
index 35052c1c19..f4fc26cbd7 100644
--- a/lib/freadahead.h
+++ b/lib/freadahead.h
@@ -32,7 +32,7 @@
 
    STREAM must not be wide-character oriented.  */
 
-#if HAVE___FREADAHEAD /* musl libc */
+#if HAVE___FREADAHEAD /* musl libc, Android API level ≥ 33 */
 
 # include <stdio_ext.h>
 # define freadahead(stream) __freadahead (stream)
diff --git a/m4/freadahead.m4 b/m4/freadahead.m4
index c2352b4616..df7aaa29fe 100644
--- a/m4/freadahead.m4
+++ b/m4/freadahead.m4
@@ -1,4 +1,4 @@
-# freadahead.m4 serial 1
+# freadahead.m4 serial 2
 dnl Copyright (C) 2012-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,5 +6,5 @@
 
 AC_DEFUN([gl_FUNC_FREADAHEAD],
 [
-  AC_CHECK_FUNCS_ONCE([__freadahead])
+  gl_CHECK_FUNCS_ANDROID([__freadahead], [[#include <stdio_ext.h>]])
 ])
-- 
2.34.1


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

From 2f4edab08c40fa0206d0fca7cee99346a156e1ab Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Fri, 26 Jan 2024 00:18:49 +0100
Subject: [PATCH 2/4] Resolve conflicts for functions introduced in Android API
 level 34.

* lib/string.in.h (memset_explicit): Consider REPLACE_MEMSET_EXPLICIT.
* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize
REPLACE_MEMSET_EXPLICIT.
* modules/string (Makefile.am): Substitute REPLACE_MEMSET_EXPLICIT.
* m4/memset_explicit.m4 (gl_FUNC_MEMSET_EXPLICIT): Test for
memset_explicit using gl_CHECK_FUNCS_ANDROID instead of
AC_CHECK_FUNCS_ONCE. Conditionally set REPLACE_MEMSET_EXPLICIT.
* modules/memset_explicit (configure.ac): Consider
REPLACE_MEMSET_EXPLICIT.
* doc/posix-functions/memset_explicit.texi: Mention the Android API
levels.
---
 ChangeLog                                | 12 ++++++++++++
 doc/posix-functions/memset_explicit.texi |  2 +-
 lib/string.in.h                          | 14 ++++++++++++--
 m4/memset_explicit.m4                    |  6 +++++-
 m4/string_h.m4                           |  3 ++-
 modules/memset_explicit                  |  3 ++-
 modules/string                           |  1 +
 7 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5e7b4d90b4..c46cb60b31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,18 @@
 
 	Resolve conflicts for functions introduced in Android API level 34.
 
+	* lib/string.in.h (memset_explicit): Consider REPLACE_MEMSET_EXPLICIT.
+	* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize
+	REPLACE_MEMSET_EXPLICIT.
+	* modules/string (Makefile.am): Substitute REPLACE_MEMSET_EXPLICIT.
+	* m4/memset_explicit.m4 (gl_FUNC_MEMSET_EXPLICIT): Test for
+	memset_explicit using gl_CHECK_FUNCS_ANDROID instead of
+	AC_CHECK_FUNCS_ONCE. Conditionally set REPLACE_MEMSET_EXPLICIT.
+	* modules/memset_explicit (configure.ac): Consider
+	REPLACE_MEMSET_EXPLICIT.
+	* doc/posix-functions/memset_explicit.texi: Mention the Android API
+	levels.
+
 	* m4/freadahead.m4 (gl_FUNC_FREADAHEAD): Test for __freadahead using
 	gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE.
 	* lib/freadahead.h: Update comment.
diff --git a/doc/posix-functions/memset_explicit.texi b/doc/posix-functions/memset_explicit.texi
index 2bfe82932a..cca6296b49 100644
--- a/doc/posix-functions/memset_explicit.texi
+++ b/doc/posix-functions/memset_explicit.texi
@@ -29,7 +29,7 @@
 @itemize
 @item
 This function is missing on some platforms:
-glibc 2.36, FreeBSD 13.1, NetBSD 9.3, OpenBSD 7.2, macOS 13, Solaris 11.4, Android 13,
+glibc 2.36, FreeBSD 13.1, NetBSD 9.3, OpenBSD 7.2, macOS 13, Solaris 11.4, Android API level 33,
 and many other systems.
 @end itemize
 
diff --git a/lib/string.in.h b/lib/string.in.h
index 01ea3e3913..44ec2e7ecd 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -414,11 +414,21 @@ _GL_WARN_ON_USE (memrchr, "memrchr is unportable - "
 /* Overwrite a block of memory.  The compiler will not optimize
    effects away, even if the block is dead after the call.  */
 #if @GNULIB_MEMSET_EXPLICIT@
-# if ! @HAVE_MEMSET_EXPLICIT@
+# if @REPLACE_MEMSET_EXPLICIT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef memset_explicit
+#   define memset_explicit rpl_memset_explicit
+#  endif
+_GL_FUNCDECL_RPL (memset_explicit, void *,
+                  (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (memset_explicit, void *, (void *__dest, int __c, size_t __n));
+# else
+#  if !@HAVE_MEMSET_EXPLICIT@
 _GL_FUNCDECL_SYS (memset_explicit, void *,
                   (void *__dest, int __c, size_t __n) _GL_ARG_NONNULL ((1)));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (memset_explicit, void *, (void *__dest, int __c, size_t __n));
+# endif
 _GL_CXXALIASWARN (memset_explicit);
 #elif defined GNULIB_POSIXCHECK
 # undef memset_explicit
diff --git a/m4/memset_explicit.m4 b/m4/memset_explicit.m4
index 6ac798d455..19514ff917 100644
--- a/m4/memset_explicit.m4
+++ b/m4/memset_explicit.m4
@@ -1,3 +1,4 @@
+# memset_explicit.m4 serial 2
 dnl Copyright 2022-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,9 +8,12 @@ AC_DEFUN([gl_FUNC_MEMSET_EXPLICIT]
 [
   AC_REQUIRE([gl_STRING_H_DEFAULTS])
 
-  AC_CHECK_FUNCS_ONCE([memset_explicit])
+  gl_CHECK_FUNCS_ANDROID([memset_explicit], [[#include <string.h>]])
   if test $ac_cv_func_memset_explicit = no; then
     HAVE_MEMSET_EXPLICIT=0
+    case "$gl_cv_onwards_func_memset_explicit" in
+      future*) REPLACE_MEMSET_EXPLICIT=1 ;;
+    esac
   fi
 ])
 
diff --git a/m4/string_h.m4 b/m4/string_h.m4
index 8b12101447..9ea748cc77 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 38
+# serial 39
 
 # Written by Paul Eggert.
 
@@ -132,6 +132,7 @@ AC_DEFUN([gl_STRING_H_DEFAULTS]
   REPLACE_MEMCHR=0;             AC_SUBST([REPLACE_MEMCHR])
   REPLACE_MEMMEM=0;             AC_SUBST([REPLACE_MEMMEM])
   REPLACE_MEMPCPY=0;            AC_SUBST([REPLACE_MEMPCPY])
+  REPLACE_MEMSET_EXPLICIT=0;    AC_SUBST([REPLACE_MEMSET_EXPLICIT])
   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/memset_explicit b/modules/memset_explicit
index 3290bd3679..da16edefd6 100644
--- a/modules/memset_explicit
+++ b/modules/memset_explicit
@@ -10,7 +10,8 @@ string
 
 configure.ac:
 gl_FUNC_MEMSET_EXPLICIT
-gl_CONDITIONAL([GL_COND_OBJ_MEMSET_EXPLICIT], [test $HAVE_MEMSET_EXPLICIT = 0])
+gl_CONDITIONAL([GL_COND_OBJ_MEMSET_EXPLICIT],
+               [test $HAVE_MEMSET_EXPLICIT = 0 || test $REPLACE_MEMSET_EXPLICIT = 1])
 AM_COND_IF([GL_COND_OBJ_MEMSET_EXPLICIT], [
   gl_PREREQ_MEMSET_EXPLICIT
 ])
diff --git a/modules/string b/modules/string
index acbd614dcd..eb0b215437 100644
--- a/modules/string
+++ b/modules/string
@@ -110,6 +110,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_MEMPCPY''@|$(REPLACE_MEMPCPY)|g' \
+	      -e 's|@''REPLACE_MEMSET_EXPLICIT''@|$(REPLACE_MEMSET_EXPLICIT)|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 #4: 0003-Resolve-conflicts-for-functions-introduced-in-Androi.patch --]
[-- Type: text/x-patch, Size: 8167 bytes --]

From 884c299e8121681d6c5b23878f34c604bed1c5a9 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Fri, 26 Jan 2024 00:18:52 +0100
Subject: [PATCH 3/4] Resolve conflicts for functions introduced in Android API
 level 34.

* m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): Test for
posix_spawn_file_actions_addchdir_np and
posix_spawn_file_actions_addfchdir_np using gl_CHECK_FUNCS_ANDROID
instead of AC_CHECK_FUNCS_ONCE.
* m4/posix_spawn_faction_addchdir.m4
(gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR): Test for
posix_spawn_file_actions_addchdir_np using gl_CHECK_FUNCS_ANDROID
instead of AC_CHECK_FUNCS_ONCE.
* m4/posix_spawn_faction_addfchdir.m4
(gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR): Test for
posix_spawn_file_actions_addfchdir_np using gl_CHECK_FUNCS_ANDROID
instead of AC_CHECK_FUNCS_ONCE.
* doc/glibc-functions/posix_spawn_file_actions_addchdir_np.texi: Mention
the Android API levels.
* doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi:
Likewise.
---
 ChangeLog                                       | 17 +++++++++++++++++
 .../posix_spawn_file_actions_addchdir_np.texi   |  4 ++--
 .../posix_spawn_file_actions_addfchdir_np.texi  |  4 ++--
 m4/posix_spawn.m4                               |  8 +++++---
 m4/posix_spawn_faction_addchdir.m4              |  6 ++++--
 m4/posix_spawn_faction_addfchdir.m4             |  6 ++++--
 6 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c46cb60b31..7dbf07fe1c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,23 @@
 
 	Resolve conflicts for functions introduced in Android API level 34.
 
+	* m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): Test for
+	posix_spawn_file_actions_addchdir_np and
+	posix_spawn_file_actions_addfchdir_np using gl_CHECK_FUNCS_ANDROID
+	instead of AC_CHECK_FUNCS_ONCE.
+	* m4/posix_spawn_faction_addchdir.m4
+	(gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR): Test for
+	posix_spawn_file_actions_addchdir_np using gl_CHECK_FUNCS_ANDROID
+	instead of AC_CHECK_FUNCS_ONCE.
+	* m4/posix_spawn_faction_addfchdir.m4
+	(gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR): Test for
+	posix_spawn_file_actions_addfchdir_np using gl_CHECK_FUNCS_ANDROID
+	instead of AC_CHECK_FUNCS_ONCE.
+	* doc/glibc-functions/posix_spawn_file_actions_addchdir_np.texi: Mention
+	the Android API levels.
+	* doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi:
+	Likewise.
+
 	* lib/string.in.h (memset_explicit): Consider REPLACE_MEMSET_EXPLICIT.
 	* m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize
 	REPLACE_MEMSET_EXPLICIT.
diff --git a/doc/glibc-functions/posix_spawn_file_actions_addchdir_np.texi b/doc/glibc-functions/posix_spawn_file_actions_addchdir_np.texi
index 7d50ca8091..a55b4517de 100644
--- a/doc/glibc-functions/posix_spawn_file_actions_addchdir_np.texi
+++ b/doc/glibc-functions/posix_spawn_file_actions_addchdir_np.texi
@@ -13,8 +13,8 @@
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on many non-glibc platforms:
-glibc 2.28, macOS 10.13, FreeBSD 13.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 3.4.6, mingw, MSVC 14, Android 9.0.
+This function is missing on many platforms:
+glibc 2.28, macOS 10.13, FreeBSD 13.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 3.4.6, mingw, MSVC 14, Android API level 33.
 @end itemize
 
 Note: Gnulib has a module @code{posix_spawn_file_actions_addchdir} that
diff --git a/doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi b/doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi
index 8a98195de9..10f66e0a04 100644
--- a/doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi
+++ b/doc/glibc-functions/posix_spawn_file_actions_addfchdir_np.texi
@@ -13,8 +13,8 @@
 Portability problems not fixed by Gnulib:
 @itemize
 @item
-This function is missing on all non-glibc platforms:
-glibc 2.28, macOS 10.13, FreeBSD 13.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Cygwin 3.4.6, mingw, MSVC 14, Android 9.0.
+This function is missing on many platforms:
+glibc 2.28, macOS 10.13, FreeBSD 13.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Cygwin 3.4.6, mingw, MSVC 14, Android API level 33.
 @end itemize
 
 Note: Gnulib has a module @code{posix_spawn_file_actions_addfchdir} that
diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4
index e66da765ad..0066a45c8b 100644
--- a/m4/posix_spawn.m4
+++ b/m4/posix_spawn.m4
@@ -1,4 +1,4 @@
-# posix_spawn.m4 serial 24
+# posix_spawn.m4 serial 25
 dnl Copyright (C) 2008-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -36,7 +36,8 @@ AC_DEFUN([gl_POSIX_SPAWN_BODY]
   if test $ac_cv_func_posix_spawn = yes; then
     m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR],
       [dnl Module 'posix_spawn_file_actions_addchdir' is present.
-       AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir_np])
+       gl_CHECK_FUNCS_ANDROID([posix_spawn_file_actions_addchdir_np],
+         [[#include <spawn.h>]])
        if test $ac_cv_func_posix_spawn_file_actions_addchdir_np = no; then
          dnl In order to implement the posix_spawn_file_actions_addchdir
          dnl function, we need to replace the entire posix_spawn facility.
@@ -45,7 +46,8 @@ AC_DEFUN([gl_POSIX_SPAWN_BODY]
       ])
     m4_ifdef([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR],
       [dnl Module 'posix_spawn_file_actions_addfchdir' is present.
-       AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addfchdir_np])
+       gl_CHECK_FUNCS_ANDROID([posix_spawn_file_actions_addfchdir_np],
+         [[#include <spawn.h>]])
        if test $ac_cv_func_posix_spawn_file_actions_addfchdir_np = no; then
          dnl In order to implement the posix_spawn_file_actions_addfchdir
          dnl function, we need to replace the entire posix_spawn facility.
diff --git a/m4/posix_spawn_faction_addchdir.m4 b/m4/posix_spawn_faction_addchdir.m4
index a65e87c6bb..a22e3a5323 100644
--- a/m4/posix_spawn_faction_addchdir.m4
+++ b/m4/posix_spawn_faction_addchdir.m4
@@ -1,4 +1,4 @@
-# posix_spawn_faction_addchdir.m4 serial 1
+# posix_spawn_faction_addchdir.m4 serial 2
 dnl Copyright (C) 2018-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,9 @@ AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR]
   AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
   AC_REQUIRE([AC_PROG_CC])
   gl_POSIX_SPAWN
-  AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir posix_spawn_file_actions_addchdir_np])
+  AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addchdir])
+  gl_CHECK_FUNCS_ANDROID([posix_spawn_file_actions_addchdir_np],
+    [[#include <spawn.h>]])
   if test $ac_cv_func_posix_spawn_file_actions_addchdir = yes; then
     dnl This function is not yet standardized. Therefore override the
     dnl system's implementation always.
diff --git a/m4/posix_spawn_faction_addfchdir.m4 b/m4/posix_spawn_faction_addfchdir.m4
index a0eafe438a..9bddad5378 100644
--- a/m4/posix_spawn_faction_addfchdir.m4
+++ b/m4/posix_spawn_faction_addfchdir.m4
@@ -1,4 +1,4 @@
-# posix_spawn_faction_addfchdir.m4 serial 1
+# posix_spawn_faction_addfchdir.m4 serial 2
 dnl Copyright (C) 2018-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,7 +9,9 @@ AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDFCHDIR]
   AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
   AC_REQUIRE([AC_PROG_CC])
   gl_POSIX_SPAWN
-  AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addfchdir posix_spawn_file_actions_addfchdir_np])
+  AC_CHECK_FUNCS_ONCE([posix_spawn_file_actions_addfchdir])
+  gl_CHECK_FUNCS_ANDROID([posix_spawn_file_actions_addfchdir_np],
+    [[#include <spawn.h>]])
   if test $ac_cv_func_posix_spawn_file_actions_addfchdir = yes; then
     dnl This function is not yet standardized. Therefore override the
     dnl system's implementation always.
-- 
2.34.1


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

From 6143e4217b409336967a7bf38b79f62d9fa9bd6f Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Fri, 26 Jan 2024 00:18:55 +0100
Subject: [PATCH 4/4] Resolve conflicts for functions introduced in Android API
 level 34.

* m4/copy-file-range.m4 (gl_FUNC_COPY_FILE_RANGE): On platforms without
glibc, test for copy_file_range using gl_CHECK_FUNCS_ANDROID instead of
AC_CHECK_FUNCS_ONCE. Conditionally set REPLACE_COPY_FILE_RANGE.
* doc/glibc-functions/copy_file_range.texi: Mention the Android API
levels.
---
 ChangeLog                                |  6 ++++
 doc/glibc-functions/copy_file_range.texi |  4 +--
 m4/copy-file-range.m4                    | 41 +++++++++++++++---------
 3 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7dbf07fe1c..d4716bdf9e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
 
 	Resolve conflicts for functions introduced in Android API level 34.
 
+	* m4/copy-file-range.m4 (gl_FUNC_COPY_FILE_RANGE): On platforms without
+	glibc, test for copy_file_range using gl_CHECK_FUNCS_ANDROID instead of
+	AC_CHECK_FUNCS_ONCE. Conditionally set REPLACE_COPY_FILE_RANGE.
+	* doc/glibc-functions/copy_file_range.texi: Mention the Android API
+	levels.
+
 	* m4/posix_spawn.m4 (gl_POSIX_SPAWN_BODY): Test for
 	posix_spawn_file_actions_addchdir_np and
 	posix_spawn_file_actions_addfchdir_np using gl_CHECK_FUNCS_ANDROID
diff --git a/doc/glibc-functions/copy_file_range.texi b/doc/glibc-functions/copy_file_range.texi
index f10271c157..979a3ffd69 100644
--- a/doc/glibc-functions/copy_file_range.texi
+++ b/doc/glibc-functions/copy_file_range.texi
@@ -21,8 +21,8 @@
 @itemize
 @item
 This function exists only on Linux and FreeBSD and is therefore
-missing on many non-glibc platforms:
-glibc 2.26, macOS 11.1, FreeBSD 12.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Cygwin 2.9, mingw, MSVC 14, Android 9.0.
+missing on many platforms:
+glibc 2.26, macOS 11.1, FreeBSD 12.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.4, Cygwin 2.9, mingw, MSVC 14, Android API level 33.
 But the replacement function is only a stub: It always fails with error ENOSYS.
 
 @item
diff --git a/m4/copy-file-range.m4 b/m4/copy-file-range.m4
index e919854951..443e598ba5 100644
--- a/m4/copy-file-range.m4
+++ b/m4/copy-file-range.m4
@@ -1,4 +1,4 @@
-# copy-file-range.m4
+# copy-file-range.m4 serial 5
 dnl Copyright 2019-2024 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,22 +17,33 @@ AC_DEFUN([gl_FUNC_COPY_FILE_RANGE]
   dnl Programs that use copy_file_range must fall back on read+write
   dnl anyway, and there's little point to substituting the Gnulib stub
   dnl for a glibc stub.
-  AC_CACHE_CHECK([for copy_file_range], [gl_cv_func_copy_file_range],
-    [AC_LINK_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[#include <unistd.h>
-          ]],
-          [[ssize_t (*func) (int, off_t *, int, off_t *, size_t, unsigned)
-              = copy_file_range;
-            return func (0, 0, 0, 0, 0, 0) & 127;
-          ]])
-       ],
-       [gl_cv_func_copy_file_range=yes],
-       [gl_cv_func_copy_file_range=no])
-    ])
-
+  case "$host_os" in
+    *-gnu* | gnu*)
+      AC_CACHE_CHECK([for copy_file_range], [gl_cv_func_copy_file_range],
+        [AC_LINK_IFELSE(
+           [AC_LANG_PROGRAM(
+              [[#include <unistd.h>
+              ]],
+              [[ssize_t (*func) (int, off_t *, int, off_t *, size_t, unsigned)
+                  = copy_file_range;
+                return func (0, 0, 0, 0, 0, 0) & 127;
+              ]])
+           ],
+           [gl_cv_func_copy_file_range=yes],
+           [gl_cv_func_copy_file_range=no])
+        ])
+      gl_cv_onwards_func_copy_file_range="$gl_cv_func_copy_file_range"
+      ;;
+    *)
+      gl_CHECK_FUNCS_ANDROID([copy_file_range], [[#include <unistd.h>]])
+      gl_cv_func_copy_file_range="$ac_cv_func_copy_file_range"
+      ;;
+  esac
   if test "$gl_cv_func_copy_file_range" != yes; then
     HAVE_COPY_FILE_RANGE=0
+    case "$gl_cv_onwards_func_copy_file_range" in
+      future*) REPLACE_COPY_FILE_RANGE=1 ;;
+    esac
   else
     AC_DEFINE([HAVE_COPY_FILE_RANGE], 1,
       [Define to 1 if the function copy_file_range exists.])
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-25 23:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-25 23:23 Resolve conflicts for functions introduced in Android API level 34 Bruno Haible

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