]> Savannah Git Hosting - gnulib.git/commitdiff
Resolve conflicts for functions introduced in Android API level 29.
authorBruno Haible <bruno@clisp.org>
Sun, 22 Jan 2023 13:45:14 +0000 (14:45 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 22 Jan 2023 14:57:29 +0000 (15:57 +0100)
* lib/time.in.h (timespec_get): Consider REPLACE_TIMESPEC_GET. Disable
_GL_CXXALIASWARN invocation on non-glibc systems.
* m4/time_h.m4 (gl_TIME_H_DEFAULTS): Initialize REPLACE_TIMESPEC_GET.
* modules/time (Makefile.am): Substitute REPLACE_TIMESPEC_GET.
* m4/gettime.m4 (gl_CHECK_FUNC_TIMESPEC_GET): Set also
gl_cv_onwards_func_timespec_get.
* m4/timespec_get.m4 (gl_FUNC_TIMESPEC_GET): Conditionally set
REPLACE_TIMESPEC_GET.
* modules/timespec_get (Depends-on, configure.ac): Consider
REPLACE_TIMESPEC_GET.

ChangeLog
lib/time.in.h
m4/gettime.m4
m4/time_h.m4
m4/timespec_get.m4
modules/time
modules/timespec_get

index d06ffacce2d1740a7b30bd40cc7469ef1d3c6333..1ce418acc010055b330718479968ce4fb1327a2b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-01-22  Bruno Haible  <bruno@clisp.org>
+
+       Resolve conflicts for functions introduced in Android API level 29.
+
+       * lib/time.in.h (timespec_get): Consider REPLACE_TIMESPEC_GET. Disable
+       _GL_CXXALIASWARN invocation on non-glibc systems.
+       * m4/time_h.m4 (gl_TIME_H_DEFAULTS): Initialize REPLACE_TIMESPEC_GET.
+       * modules/time (Makefile.am): Substitute REPLACE_TIMESPEC_GET.
+       * m4/gettime.m4 (gl_CHECK_FUNC_TIMESPEC_GET): Set also
+       gl_cv_onwards_func_timespec_get.
+       * m4/timespec_get.m4 (gl_FUNC_TIMESPEC_GET): Conditionally set
+       REPLACE_TIMESPEC_GET.
+       * modules/timespec_get (Depends-on, configure.ac): Consider
+       REPLACE_TIMESPEC_GET.
+
 2023-01-22  Bruno Haible  <bruno@clisp.org>
 
        Resolve conflicts for functions introduced in Android API level 28.
index fa0c6351b2c4c4b80e828beb5a5b15b34f2efbb0..87cda21413b2f1b94c4b678ea39146673a023d4f 100644 (file)
@@ -112,12 +112,24 @@ struct __time_t_must_be_integral {
 /* Set *TS to the current time, and return BASE.
    Upon failure, return 0.  */
 # if @GNULIB_TIMESPEC_GET@
-#  if ! @HAVE_TIMESPEC_GET@
+#  if @REPLACE_TIMESPEC_GET@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef timespec_get
+#    define timespec_get rpl_timespec_get
+#   endif
+_GL_FUNCDECL_RPL (timespec_get, int, (struct timespec *ts, int base)
+                                     _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (timespec_get, int, (struct timespec *ts, int base));
+#  else
+#   if !@HAVE_TIMESPEC_GET@
 _GL_FUNCDECL_SYS (timespec_get, int, (struct timespec *ts, int base)
                                      _GL_ARG_NONNULL ((1)));
-#  endif
+#   endif
 _GL_CXXALIAS_SYS (timespec_get, int, (struct timespec *ts, int base));
+#  endif
+#  if __GLIBC__ >= 2
 _GL_CXXALIASWARN (timespec_get);
+#  endif
 # endif
 
 /* Set *TS to the current time resolution, and return BASE.
index 7e353fcd00eecb7ce3e9e1c78a36b13cb0451f7a..ec1f97ee0d5c87321038c73c6cc0e65083b22ac8 100644 (file)
@@ -1,4 +1,4 @@
-# gettime.m4 serial 13
+# gettime.m4 serial 14
 dnl Copyright (C) 2002, 2004-2006, 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,
@@ -18,9 +18,11 @@ AC_DEFUN([gl_GETTIME],
 ])
 
 dnl Tests whether the function timespec_get exists.
-dnl Sets gl_cv_func_timespec_get.
+dnl Sets gl_cv_func_timespec_get and gl_cv_onwards_func_timespec_get.
 AC_DEFUN([gl_CHECK_FUNC_TIMESPEC_GET],
 [
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
   dnl Persuade OpenBSD <time.h> to declare timespec_get().
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
 
@@ -29,21 +31,32 @@ AC_DEFUN([gl_CHECK_FUNC_TIMESPEC_GET],
   dnl But at the same time, we need to notice a missing declaration, like
   dnl gl_CHECK_FUNCS_ANDROID does.
   AC_CHECK_DECL([timespec_get], , , [[#include <time.h>]])
-  if test $ac_cv_have_decl_timespec_get = yes; then
-    AC_CACHE_CHECK([for timespec_get], [gl_cv_func_timespec_get],
-      [AC_LINK_IFELSE(
+  AC_CACHE_CHECK([for timespec_get], [gl_cv_onwards_func_timespec_get],
+    [if test $ac_cv_have_decl_timespec_get = yes; then
+       AC_LINK_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <time.h>
               struct timespec ts;
             ]],
             [[return timespec_get (&ts, 0);]])
          ],
-         [gl_cv_func_timespec_get=yes],
-         [gl_cv_func_timespec_get=no])
-      ])
-  else
-    gl_cv_func_timespec_get=no
-  fi
+         [gl_cv_onwards_func_timespec_get=yes],
+         [gl_cv_onwards_func_timespec_get=no])
+     else
+       gl_cv_onwards_func_timespec_get=no
+     fi
+     case "$host_os" in
+       linux*-android*)
+         if test $gl_cv_onwards_func_timespec_get = no; then
+           gl_cv_onwards_func_timespec_get='future OS version'
+         fi
+         ;;
+     esac
+    ])
+  case "$gl_cv_onwards_func_timespec_get" in
+    future*) gl_cv_func_timespec_get=no ;;
+    *)       gl_cv_func_timespec_get=$gl_cv_onwards_func_timespec_get ;;
+  esac
 ])
 
 AC_DEFUN([gl_GETTIME_RES],
index f6bf3a4f30e980f2fa328af392cb07a0a7bdf686..b74870c3d0e8348655154027323d89faa8adf32b 100644 (file)
@@ -2,7 +2,7 @@
 
 # Copyright (C) 2000-2001, 2003-2007, 2009-2023 Free Software Foundation, Inc.
 
-# serial 20
+# serial 21
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -170,6 +170,7 @@ AC_DEFUN([gl_TIME_H_DEFAULTS],
   REPLACE_NANOSLEEP=GNULIB_PORTCHECK;    AC_SUBST([REPLACE_NANOSLEEP])
   REPLACE_STRFTIME=GNULIB_PORTCHECK;     AC_SUBST([REPLACE_STRFTIME])
   REPLACE_TIMEGM=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_TIMEGM])
+  REPLACE_TIMESPEC_GET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMESPEC_GET])
   REPLACE_TZSET=GNULIB_PORTCHECK;        AC_SUBST([REPLACE_TZSET])
 
   dnl Hack so that the time module doesn't depend on the sys_time module.
index 866ba5003a7fd7114deeb2e08166c0749516f9ba..61e4bc378bba0ededa3239244fcf4a347d033c0d 100644 (file)
@@ -1,4 +1,4 @@
-# timespec_get.m4 serial 3
+# timespec_get.m4 serial 4
 dnl Copyright (C) 2021-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,8 @@ AC_DEFUN([gl_FUNC_TIMESPEC_GET],
   AC_REQUIRE([gl_CHECK_FUNC_TIMESPEC_GET])
   if test $gl_cv_func_timespec_get != yes; then
     HAVE_TIMESPEC_GET=0
+    case "$gl_cv_onwards_func_timespec_get" in
+      future*) REPLACE_TIMESPEC_GET=1 ;;
+    esac
   fi
 ])
index ae8471bb9e3a5a20cf8f1c887d483d73d1eb720b..75ff3a4d8ca0bb8b5fd846eb33600633f0a3553e 100644 (file)
@@ -60,6 +60,7 @@ time.h: time.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(
              -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
              -e 's|@''REPLACE_STRFTIME''@|$(REPLACE_STRFTIME)|g' \
              -e 's|@''REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+             -e 's|@''REPLACE_TIMESPEC_GET''@|$(REPLACE_TIMESPEC_GET)|g' \
              -e 's|@''REPLACE_TZSET''@|$(REPLACE_TZSET)|g' \
              -e 's|@''PTHREAD_H_DEFINES_STRUCT_TIMESPEC''@|$(PTHREAD_H_DEFINES_STRUCT_TIMESPEC)|g' \
              -e 's|@''SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
index b1b33b494dcee4a9b7108d64cd718a5e0a7ed3c4..7b3dc3b01dda198f5002ae01b0248a7e4f77d55c 100644 (file)
@@ -8,11 +8,12 @@ m4/timespec_get.m4
 Depends-on:
 time
 extensions
-gettime         [test $HAVE_TIMESPEC_GET = 0]
+gettime         [test $HAVE_TIMESPEC_GET = 0 || test $REPLACE_TIMESPEC_GET = 1]
 
 configure.ac:
 gl_FUNC_TIMESPEC_GET
-gl_CONDITIONAL([GL_COND_OBJ_TIMESPEC_GET], [test $HAVE_TIMESPEC_GET = 0])
+gl_CONDITIONAL([GL_COND_OBJ_TIMESPEC_GET],
+               [test $HAVE_TIMESPEC_GET = 0 || test $REPLACE_TIMESPEC_GET = 1])
 gl_TIME_MODULE_INDICATOR([timespec_get])
 
 Makefile.am: