]> Savannah Git Hosting - gnulib.git/commitdiff
Resolve conflicts for functions introduced in Android API level 23.
authorBruno Haible <bruno@clisp.org>
Sun, 22 Jan 2023 12:05:19 +0000 (13:05 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 22 Jan 2023 14:56:55 +0000 (15:56 +0100)
* 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
lib/unistd.in.h
m4/sethostname.m4
m4/unistd_h.m4
modules/sethostname
modules/unistd

index 3accc92f951f64ee6a9bd8f8fa8c840bd856c841..a39769fb4740c039af11f8797f76735ea2cbfae5 100644 (file)
--- 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.
index 2a6d4ce743bb47b87a19d7248fe04eba29677395..9930a11c19f634b08623b7d8ec4931f051ff8c61 100644 (file)
@@ -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
index 8f3cd18c6c7808c8f3345ba871d5a16b7f8c4df5..c3dea5946494e53f5b072557c6f0e2997128adf9 100644 (file)
@@ -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 <unistd.h>]])
   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])
index 8fbd82b2b73a8b5520057d2fa99d8c180e6c60e3..fc8e2a58f30239968dc775df289e5e55b5f0a094 100644 (file)
@@ -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])
index 56b68b2ad4907dd01a0727e34ca2811f7b703694..6057ef06cd344b44278e8b80869c4196bdddd1f2 100644 (file)
@@ -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:
index 065e4ad52ea6f040a5847b0e0f076960882aaccc..ddb0991f851f1d575684e740f43b49f7532370e6 100644 (file)
@@ -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' \