]> Savannah Git Hosting - gnulib.git/commitdiff
readutmp, boot-time: Fix compilation error on Android API 8.
authorBruno Haible <bruno@clisp.org>
Sun, 13 Aug 2023 14:08:33 +0000 (16:08 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 13 Aug 2023 14:08:33 +0000 (16:08 +0200)
Reported by Po Lu in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-08/msg00108.html>.

* m4/readutmp.m4 (gl_PREREQ_READUTMP_H): Test whether sysinfo is
declared.
* lib/boot-time-aux.h (get_linux_uptime): Invoke sysinfo only if it is
declared.
* doc/glibc-functions/sysinfo.texi: Mention the Android problem.

ChangeLog
doc/glibc-functions/sysinfo.texi
lib/boot-time-aux.h
m4/readutmp.m4

index 9b4f07a2b1ada3693c6f67c53873768c6701f0a7..3b651bb4b82bfbe9953d376bb3c925d3898c5901 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-08-13  Bruno Haible  <bruno@clisp.org>
+
+       readutmp, boot-time: Fix compilation error on Android API 8.
+       Reported by Po Lu in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2023-08/msg00108.html>.
+       * m4/readutmp.m4 (gl_PREREQ_READUTMP_H): Test whether sysinfo is
+       declared.
+       * lib/boot-time-aux.h (get_linux_uptime): Invoke sysinfo only if it is
+       declared.
+       * doc/glibc-functions/sysinfo.texi: Mention the Android problem.
+
 2023-08-13  Bruno Haible  <bruno@clisp.org>
 
        readutmp, boot-time: Fix compilation error on old Android.
index 3b1ade31a665f48cc3634d61492efded22574930..16e12b12ac89aabcaa7d2d2936f4e56921b0afb6 100644 (file)
@@ -17,4 +17,7 @@ Portability problems not fixed by Gnulib:
 @item
 This function is missing on some platforms:
 macOS 11.1, FreeBSD 13.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 5.1, Cygwin 1.7.9, mingw, MSVC 14.
+@item
+This function is not declared and thus not part of the Android API
+for Android API levels < 9.
 @end itemize
index 348611fc85c9d469072f94910a213bd6a5571a17..e59a0fd03c7ce514d89553d34913a32c8e2d558c 100644 (file)
@@ -65,6 +65,7 @@ get_linux_uptime (struct timespec *p_uptime)
     }
 # endif
 
+# if HAVE_DECL_SYSINFO /* not available in Android API < 9 */
   /* The sysinfo call returns the uptime with a resolution of 1 sec only.  */
   struct sysinfo info;
   if (sysinfo (&info) >= 0)
@@ -73,6 +74,7 @@ get_linux_uptime (struct timespec *p_uptime)
       p_uptime->tv_nsec = 0;
       return 0;
     }
+# endif
 
   return -1;
 }
index 9dffe981b8cafda48660c722d6f2baae7d8d0a00..0a47f4bb77d91edaf85be168caee37c40023e6e2 100644 (file)
@@ -1,4 +1,4 @@
-# readutmp.m4 serial 29
+# readutmp.m4 serial 30
 dnl Copyright (C) 2002-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,
@@ -103,6 +103,10 @@ AC_INCLUDES_DEFAULT
     AC_CHECK_MEMBERS([struct utmp.ut_exit.e_termination],,,[$utmp_includes])
   fi
 
+  AC_CHECK_DECLS([sysinfo],,,[[
+    #include <sys/sysinfo.h>
+    ]])
+
   AC_CHECK_HEADERS_ONCE([sys/param.h])
   dnl <sys/sysctl.h> requires <sys/param.h> on OpenBSD 4.0.
   AC_CHECK_HEADERS([sys/sysctl.h],,,