]> Savannah Git Hosting - gnulib.git/commitdiff
Resolve conflicts for functions introduced in Android API level 9.
authorBruno Haible <bruno@clisp.org>
Sun, 22 Jan 2023 00:23:47 +0000 (01:23 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 22 Jan 2023 14:55:56 +0000 (15:55 +0100)
* lib/unistd.in.h (fdatasync): Consider REPLACE_FDATASYNC. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
(pipe2): Consider REPLACE_PIPE2. Disable _GL_CXXALIASWARN invocation on
non-glibc systems.
* m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_FDATASYNC,
REPLACE_PIPE2.
* modules/unistd (Makefile.am): Substitute REPLACE_FDATASYNC,
REPLACE_PIPE2.
* m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Test for fdatasync using
gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS. Conditionally set
REPLACE_FDATASYNC.
* modules/fdatasync (Depends-on, configure.ac): Consider
REPLACE_FDATASYNC.
* m4/pipe2.m4 (gl_FUNC_PIPE2): Conditionally set REPLACE_PIPE2.

ChangeLog
lib/unistd.in.h
m4/fdatasync.m4
m4/pipe2.m4
m4/unistd_h.m4
modules/fdatasync
modules/unistd

index a491d5ab6f191a3e59900b01a6baa893870bd914..0859e1fd87dcf2203a3558139f2885c8406a36f5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+       Resolve conflicts for functions introduced in Android API level 9.
+       * lib/unistd.in.h (fdatasync): Consider REPLACE_FDATASYNC. Disable
+       _GL_CXXALIASWARN invocation on non-glibc systems.
+       (pipe2): Consider REPLACE_PIPE2. Disable _GL_CXXALIASWARN invocation on
+       non-glibc systems.
+       * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_FDATASYNC,
+       REPLACE_PIPE2.
+       * modules/unistd (Makefile.am): Substitute REPLACE_FDATASYNC,
+       REPLACE_PIPE2.
+       * m4/fdatasync.m4 (gl_FUNC_FDATASYNC): Test for fdatasync using
+       gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS. Conditionally set
+       REPLACE_FDATASYNC.
+       * modules/fdatasync (Depends-on, configure.ac): Consider
+       REPLACE_FDATASYNC.
+       * m4/pipe2.m4 (gl_FUNC_PIPE2): Conditionally set REPLACE_PIPE2.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
        Resolve conflicts for functions introduced in Android API level 8.
index f6d7c8d0a99c772fb68e2a401a69137f220b5308..9b330286e040dbae737f02cdf1e9704e8df7550a 100644 (file)
@@ -1002,11 +1002,22 @@ _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
    Return 0 if successful, otherwise -1 and errno set.
    See POSIX:2008 specification
    <https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>.  */
-# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
+# if @REPLACE_FDATASYNC@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef fdatasync
+#   define fdatasync rpl_fdatasync
+#  endif
+_GL_FUNCDECL_RPL (fdatasync, int, (int fd));
+_GL_CXXALIAS_RPL (fdatasync, int, (int fd));
+# else
+#  if !@HAVE_FDATASYNC@|| !@HAVE_DECL_FDATASYNC@
 _GL_FUNCDECL_SYS (fdatasync, int, (int fd));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (fdatasync, int, (int fd));
+# endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (fdatasync);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef fdatasync
 # if HAVE_RAW_DECL_FDATASYNC
@@ -1742,8 +1753,9 @@ _GL_WARN_ON_USE (pipe, "pipe is unportable - "
    Return 0 upon success, or -1 with errno set upon failure.
    See also the Linux man page at
    <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>.  */
-# if @HAVE_PIPE2@
+# if @REPLACE_PIPE2@
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef pipe2
 #   define pipe2 rpl_pipe2
 #  endif
 _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
@@ -1752,7 +1764,9 @@ _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
 _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (pipe2);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef pipe2
 # if HAVE_RAW_DECL_PIPE2
index 201d7ffb27d6e0c90322cb5e1894905319f149b0..17cf64cc1d177337ff1f4fff9210684819d87670 100644 (file)
@@ -1,4 +1,4 @@
-# fdatasync.m4 serial 8
+# fdatasync.m4 serial 9
 dnl Copyright (C) 2008-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,
@@ -17,10 +17,13 @@ AC_DEFUN([gl_FUNC_FDATASYNC],
   if test $ac_cv_have_decl_fdatasync = no; then
     HAVE_DECL_FDATASYNC=0
     dnl Mac OS X 10.7 has fdatasync but does not declare it.
-    dnl Likewise Android with API level < 9. Cf. gl_CHECK_FUNCS_ANDROID.
-    AC_CHECK_FUNCS([fdatasync])
+    dnl Likewise Android with API level < 9.
+    gl_CHECK_FUNCS_ANDROID([fdatasync], [[#include <unistd.h>]])
     if test $ac_cv_func_fdatasync = no; then
       HAVE_FDATASYNC=0
+      case "$gl_cv_onwards_func_fdatasync" in
+        future*) REPLACE_FDATASYNC=1 ;;
+      esac
     fi
   else
     case "$host_os" in
@@ -35,10 +38,14 @@ AC_DEFUN([gl_FUNC_FDATASYNC],
         LIBS=$gl_saved_libs
         ;;
       *)
-        dnl Android 4.3 does not have fdatasync but declares it.
-        AC_CHECK_FUNCS([fdatasync])
+        dnl Android 4.3 does not have fdatasync but declares it, and future
+        dnl Android versions have it.
+        gl_CHECK_FUNCS_ANDROID([fdatasync], [[#include <unistd.h>]])
         if test $ac_cv_func_fdatasync = no; then
           HAVE_FDATASYNC=0
+          case "$gl_cv_onwards_func_fdatasync" in
+            future*) REPLACE_FDATASYNC=1 ;;
+          esac
         fi
         ;;
     esac
index c7ec02e8736773432fad44360156b1a1368f3d64..79de69cd1a4a00db9a77bb7be95f8add0355e7d6 100644 (file)
@@ -1,4 +1,4 @@
-# pipe2.m4 serial 3
+# pipe2.m4 serial 4
 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,
@@ -14,5 +14,10 @@ AC_DEFUN([gl_FUNC_PIPE2],
   gl_CHECK_FUNCS_ANDROID([pipe2], [[#include <unistd.h>]])
   if test $ac_cv_func_pipe2 != yes; then
     HAVE_PIPE2=0
+    case "$gl_cv_onwards_func_pipe2" in
+      future*) REPLACE_PIPE2=1 ;;
+    esac
+  else
+    REPLACE_PIPE2=1
   fi
 ])
index f4384027e3776649830d42ecaeaff3b659b42340..c7ef46c26d563bbac825aaf3c3d297e7e40c2504 100644 (file)
@@ -1,4 +1,4 @@
-# unistd_h.m4 serial 90
+# unistd_h.m4 serial 91
 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,
@@ -234,6 +234,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_EXECVPE=0;                 AC_SUBST([REPLACE_EXECVPE])
   REPLACE_FACCESSAT=0;               AC_SUBST([REPLACE_FACCESSAT])
   REPLACE_FCHOWNAT=0;                AC_SUBST([REPLACE_FCHOWNAT])
+  REPLACE_FDATASYNC=0;               AC_SUBST([REPLACE_FDATASYNC])
   REPLACE_FTRUNCATE=0;               AC_SUBST([REPLACE_FTRUNCATE])
   REPLACE_GETCWD=0;                  AC_SUBST([REPLACE_GETCWD])
   REPLACE_GETDOMAINNAME=0;           AC_SUBST([REPLACE_GETDOMAINNAME])
@@ -248,6 +249,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS],
   REPLACE_LINK=0;                    AC_SUBST([REPLACE_LINK])
   REPLACE_LINKAT=0;                  AC_SUBST([REPLACE_LINKAT])
   REPLACE_LSEEK=0;                   AC_SUBST([REPLACE_LSEEK])
+  REPLACE_PIPE2=0;                   AC_SUBST([REPLACE_PIPE2])
   REPLACE_PREAD=0;                   AC_SUBST([REPLACE_PREAD])
   REPLACE_PWRITE=0;                  AC_SUBST([REPLACE_PWRITE])
   REPLACE_READ=0;                    AC_SUBST([REPLACE_READ])
index 6e0f48df213563e3fcf66ce1982aaa145705ed34..4d13a97cdb53a0b4cf80a402e59d3cbeda00558c 100644 (file)
@@ -6,12 +6,12 @@ lib/fdatasync.c
 m4/fdatasync.m4
 
 Depends-on:
-fsync         [test $HAVE_FDATASYNC = 0]
+fsync         [test $HAVE_FDATASYNC = 0 || test $REPLACE_FDATASYNC = 1]
 unistd
 
 configure.ac:
 gl_FUNC_FDATASYNC
-gl_CONDITIONAL([GL_COND_OBJ_FDATASYNC], [test $HAVE_FDATASYNC = 0])
+gl_CONDITIONAL([GL_COND_OBJ_FDATASYNC], [test $HAVE_FDATASYNC = 0 || test $REPLACE_FDATASYNC = 1])
 gl_UNISTD_MODULE_INDICATOR([fdatasync])
 
 Makefile.am:
index 01da57e23a8080d01de6214d468f31051d18de13..80080ede9ef44b7235a2bb2f3d1e9c4689f02181 100644 (file)
@@ -188,6 +188,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''REPLACE_EXECVPE''@|$(REPLACE_EXECVPE)|g' \
              -e 's|@''REPLACE_FACCESSAT''@|$(REPLACE_FACCESSAT)|g' \
              -e 's|@''REPLACE_FCHOWNAT''@|$(REPLACE_FCHOWNAT)|g' \
+             -e 's|@''REPLACE_FDATASYNC''@|$(REPLACE_FDATASYNC)|g' \
              -e 's|@''REPLACE_FTRUNCATE''@|$(REPLACE_FTRUNCATE)|g' \
              -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \
              -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \
@@ -202,6 +203,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''REPLACE_LINK''@|$(REPLACE_LINK)|g' \
              -e 's|@''REPLACE_LINKAT''@|$(REPLACE_LINKAT)|g' \
              -e 's|@''REPLACE_LSEEK''@|$(REPLACE_LSEEK)|g' \
+             -e 's|@''REPLACE_PIPE2''@|$(REPLACE_PIPE2)|g' \
              -e 's|@''REPLACE_PREAD''@|$(REPLACE_PREAD)|g' \
              -e 's|@''REPLACE_PWRITE''@|$(REPLACE_PWRITE)|g' \
              -e 's|@''REPLACE_READ''@|$(REPLACE_READ)|g' \