From 9746be9cd8ccaebc0e1052c19da8d5644766caad Mon Sep 17 00:00:00 2001 From: Bruno Haible 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 ]]) 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