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