From 04e2eaf51c15e5242e0fa695a784a72d6b62c5e9 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 26 Jan 2024 00:18:49 +0100 Subject: [PATCH] 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 | 8 ++++++-- m4/string_h.m4 | 3 ++- modules/memset_explicit | 3 ++- modules/string | 1 + 7 files changed, 36 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7748cbed4f..de43b8db1d 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 @@ Portability problems fixed by Gnulib: @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 9dcd89a758..19514ff917 100644 --- a/m4/memset_explicit.m4 +++ b/m4/memset_explicit.m4 @@ -1,4 +1,5 @@ -dnl Copyright 2022-2023 Free Software Foundation, Inc. +# 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, dnl with or without modifications, as long as this notice is preserved. @@ -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 ]]) 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.39.5