From 134320a310c64fc3b497618cabc2749bd98735fb Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 22 Jan 2023 13:05:19 +0100 Subject: [PATCH 30/47] Resolve conflicts for functions introduced in Android API level 23. * lib/unistd.in.h (sethostname): Consider REPLACE_SETHOSTNAME. Disable _GL_CXXALIASWARN invocation on non-glibc systems. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_SETHOSTNAME. * modules/unistd (Makefile.am): Substitute REPLACE_SETHOSTNAME. * m4/sethostname.m4 (gl_FUNC_SETHOSTNAME): Conditionally set REPLACE_SETHOSTNAME. * modules/sethostname (Depends-on, configure.ac): Consider REPLACE_SETHOSTNAME. --- ChangeLog | 9 +++++++++ lib/unistd.in.h | 16 ++++++++++++++-- m4/sethostname.m4 | 5 ++++- m4/unistd_h.m4 | 3 ++- modules/sethostname | 7 ++++--- modules/unistd | 1 + 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3accc92f95..a39769fb47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,15 @@ Resolve conflicts for functions introduced in Android API level 23. + * lib/unistd.in.h (sethostname): Consider REPLACE_SETHOSTNAME. Disable + _GL_CXXALIASWARN invocation on non-glibc systems. + * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_SETHOSTNAME. + * modules/unistd (Makefile.am): Substitute REPLACE_SETHOSTNAME. + * m4/sethostname.m4 (gl_FUNC_SETHOSTNAME): Conditionally set + REPLACE_SETHOSTNAME. + * modules/sethostname (Depends-on, configure.ac): Consider + REPLACE_SETHOSTNAME. + * 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. diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 2a6d4ce743..9930a11c19 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -2029,15 +2029,27 @@ _GL_CXXALIASWARN (rmdir); Platforms with no ability to set the hostname return -1 and set errno = ENOSYS. */ -# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ +# if @REPLACE_SETHOSTNAME@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef sethostname +# define sethostname rpl_sethostname +# endif +_GL_FUNCDECL_RPL (sethostname, int, (const char *name, size_t len) + _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (sethostname, int, (const char *name, size_t len)); +# else +# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@ _GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len) _GL_ARG_NONNULL ((1))); -# endif +# endif /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5 and FreeBSD 6.4 the second parameter is int. On Solaris 11 2011-10, the first parameter is not const. */ _GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (sethostname); +# endif #elif defined GNULIB_POSIXCHECK # undef sethostname # if HAVE_RAW_DECL_SETHOSTNAME diff --git a/m4/sethostname.m4 b/m4/sethostname.m4 index 8f3cd18c6c..c3dea59464 100644 --- a/m4/sethostname.m4 +++ b/m4/sethostname.m4 @@ -1,4 +1,4 @@ -# sethostname.m4 serial 2 +# sethostname.m4 serial 3 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, @@ -16,6 +16,9 @@ AC_DEFUN([gl_FUNC_SETHOSTNAME], gl_CHECK_FUNCS_ANDROID([sethostname], [[#include ]]) if test $ac_cv_func_sethostname = no; then HAVE_SETHOSTNAME=0 + case "$gl_cv_onwards_func_sethostname" in + future*) REPLACE_SETHOSTNAME=1 ;; + esac fi AC_CHECK_DECLS([sethostname]) diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index 8fbd82b2b7..fc8e2a58f3 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 92 +# unistd_h.m4 serial 93 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, @@ -257,6 +257,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK]) REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT]) REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR]) + REPLACE_SETHOSTNAME=0; AC_SUBST([REPLACE_SETHOSTNAME]) REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP]) REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK]) REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT]) diff --git a/modules/sethostname b/modules/sethostname index 56b68b2ad4..6057ef06cd 100644 --- a/modules/sethostname +++ b/modules/sethostname @@ -8,12 +8,13 @@ m4/gethostname.m4 Depends-on: unistd -errno [test $HAVE_SETHOSTNAME = 0] -fopen-gnu [test $HAVE_SETHOSTNAME = 0] +errno [test $HAVE_SETHOSTNAME = 0 || test $REPLACE_SETHOSTNAME = 1] +fopen-gnu [test $HAVE_SETHOSTNAME = 0 || test $REPLACE_SETHOSTNAME = 1] configure.ac: gl_FUNC_SETHOSTNAME -gl_CONDITIONAL([GL_COND_OBJ_SETHOSTNAME], [test $HAVE_SETHOSTNAME = 0]) +gl_CONDITIONAL([GL_COND_OBJ_SETHOSTNAME], + [test $HAVE_SETHOSTNAME = 0 || test $REPLACE_SETHOSTNAME = 1]) gl_UNISTD_MODULE_INDICATOR([sethostname]) Makefile.am: diff --git a/modules/unistd b/modules/unistd index 065e4ad52e..ddb0991f85 100644 --- a/modules/unistd +++ b/modules/unistd @@ -211,6 +211,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_READLINK''@|$(REPLACE_READLINK)|g' \ -e 's|@''REPLACE_READLINKAT''@|$(REPLACE_READLINKAT)|g' \ -e 's|@''REPLACE_RMDIR''@|$(REPLACE_RMDIR)|g' \ + -e 's|@''REPLACE_SETHOSTNAME''@|$(REPLACE_SETHOSTNAME)|g' \ -e 's|@''REPLACE_SLEEP''@|$(REPLACE_SLEEP)|g' \ -e 's|@''REPLACE_SYMLINK''@|$(REPLACE_SYMLINK)|g' \ -e 's|@''REPLACE_SYMLINKAT''@|$(REPLACE_SYMLINKAT)|g' \ -- 2.34.1