>From 0244a842e9d5c0670c7ff2bc1cf90a23cbc251ab Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 22 Jan 2023 11:55:01 +0100 Subject: [PATCH 19/47] Resolve conflicts for functions introduced in Android API level 21. * lib/unistd.in.h (dup3): Consider REPLACE_DUP3. Disable _GL_CXXALIASWARN invocation on non-glibc systems. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_DUP3. * modules/unistd (Makefile.am): Substitute REPLACE_DUP3. * m4/dup3.m4 (gl_FUNC_DUP3): Conditionally set REPLACE_DUP3. --- ChangeLog | 6 ++++++ lib/unistd.in.h | 7 ++++++- m4/dup3.m4 | 7 ++++++- m4/unistd_h.m4 | 3 ++- modules/unistd | 1 + 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1cf4f77554..22a28b2fd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ Resolve conflicts for functions introduced in Android API level 21. + * lib/unistd.in.h (dup3): Consider REPLACE_DUP3. Disable + _GL_CXXALIASWARN invocation on non-glibc systems. + * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_DUP3. + * modules/unistd (Makefile.am): Substitute REPLACE_DUP3. + * m4/dup3.m4 (gl_FUNC_DUP3): Conditionally set REPLACE_DUP3. + * lib/string.in.h (stpcpy): Consider REPLACE_STPCPY. Disable _GL_CXXALIASWARN invocation on non-glibc systems. * m4/string_h.m4 (gl_STRING_H_DEFAULTS): Initialize REPLACE_STPCPY. diff --git a/lib/unistd.in.h b/lib/unistd.in.h index df095ba479..345b73945a 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -541,17 +541,22 @@ _GL_CXXALIASWARN (dup2); Return newfd if successful, otherwise -1 and errno set. See the Linux man page at . */ -# if @HAVE_DUP3@ +# if @REPLACE_DUP3@ # if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef dup3 # define dup3 rpl_dup3 # endif _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags)); _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags)); # else +# if !@HAVE_DUP3@ _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags)); +# endif _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (dup3); +# endif #elif defined GNULIB_POSIXCHECK # undef dup3 # if HAVE_RAW_DECL_DUP3 diff --git a/m4/dup3.m4 b/m4/dup3.m4 index 644a172006..602222e925 100644 --- a/m4/dup3.m4 +++ b/m4/dup3.m4 @@ -1,4 +1,4 @@ -# dup3.m4 serial 6 +# dup3.m4 serial 7 dnl Copyright (C) 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, @@ -15,6 +15,11 @@ AC_DEFUN([gl_FUNC_DUP3], gl_CHECK_FUNCS_ANDROID([dup3], [[#include ]]) if test $ac_cv_func_dup3 != yes; then HAVE_DUP3=0 + case "$gl_cv_onwards_func_dup3" in + future*) REPLACE_DUP3=1 ;; + esac + else + REPLACE_DUP3=1 fi dnl Not needed yet, because dup3 is unconditionally replaced. diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index c7ef46c26d..8fbd82b2b7 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 91 +# unistd_h.m4 serial 92 dnl Copyright (C) 2006-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, @@ -225,6 +225,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE]) REPLACE_DUP=0; AC_SUBST([REPLACE_DUP]) REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2]) + REPLACE_DUP3=0; AC_SUBST([REPLACE_DUP3]) REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL]) REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE]) REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP]) diff --git a/modules/unistd b/modules/unistd index 80080ede9e..065e4ad52e 100644 --- a/modules/unistd +++ b/modules/unistd @@ -179,6 +179,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_COPY_FILE_RANGE''@|$(REPLACE_COPY_FILE_RANGE)|g' \ -e 's|@''REPLACE_DUP''@|$(REPLACE_DUP)|g' \ -e 's|@''REPLACE_DUP2''@|$(REPLACE_DUP2)|g' \ + -e 's|@''REPLACE_DUP3''@|$(REPLACE_DUP3)|g' \ -e 's|@''REPLACE_EXECL''@|$(REPLACE_EXECL)|g' \ -e 's|@''REPLACE_EXECLE''@|$(REPLACE_EXECLE)|g' \ -e 's|@''REPLACE_EXECLP''@|$(REPLACE_EXECLP)|g' \ -- 2.34.1