>From 31617d81c53135e56f943299f54fd26acc3afe79 Mon Sep 17 00:00:00 2001 From: Bruno Haible 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 + + 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 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