On 2024-01-20 19:38, Po Lu wrote:
the problem affects the boot-time module rather than
readutmp, which Emacs doesn't import. And in the words of Bruno, a
functional utmp(x) might appear in Android someday, which binaries
compiled today should take advantage of wherever available.
Oh, I see I was barking up the wrong tree. How about the attached patch
instead? Again, it's not installed into Gnulib and is not tested on Android.From 5b48472effc4174d8c25bd46736fe7236ef36aae Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Sat, 20 Jan 2024 20:03:25 -0800
Subject: [PATCH] boot-time: port to Android SDK r26
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* lib/boot-time.c (get_boot_time_uncached) [__ANDROID__]: Don’t
assume UTMP_NAME_FUNCTION is defined. Problem reported by Po Lu in:
https://lists.gnu.org/r/bug-gnulib/2024-01/msg00063.html
---
ChangeLog | 7 +++++++
lib/boot-time.c | 19 +++++++++----------
2 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d8d2a13d9e..80144c14dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-01-20 Paul Eggert <egg...@cs.ucla.edu>
+
+ boot-time: port to Android SDK r26
+ * lib/boot-time.c (get_boot_time_uncached) [__ANDROID__]: Don’t
+ assume UTMP_NAME_FUNCTION is defined. Problem reported by Po Lu in:
+ https://lists.gnu.org/r/bug-gnulib/2024-01/msg00063.html
+
2024-01-19 Bruno Haible <br...@clisp.org>
fenv-environment: Fix for NetBSD/powerpc.
diff --git a/lib/boot-time.c b/lib/boot-time.c
index c1171e8024..c9dff8de4e 100644
--- a/lib/boot-time.c
+++ b/lib/boot-time.c
@@ -82,7 +82,7 @@ get_boot_time_uncached (struct timespec *p_boot_time)
/* Try to find the boot time in the /var/run/utmp file. */
-# if defined UTMP_NAME_FUNCTION /* glibc, musl, macOS, FreeBSD, NetBSD, Minix, AIX, IRIX, Solaris, Cygwin, Android */
+# if defined UTMP_NAME_FUNCTION /* glibc, musl, macOS, FreeBSD, NetBSD, Minix, AIX, IRIX, Solaris, Cygwin, Android pre-r26 */
/* Ignore the return value for now.
Solaris' utmpname returns 1 upon success -- which is contrary
@@ -147,14 +147,6 @@ get_boot_time_uncached (struct timespec *p_boot_time)
}
# endif
-# if defined __ANDROID__
- if (found_boot_time.tv_sec == 0)
- {
- /* Workaround for Android: */
- get_android_boot_time (&found_boot_time);
- }
-# endif
-
# if defined __minix
/* On Minix, during boot,
1. an entry gets written into /var/run/utmp, with ut_type = BOOT_TIME,
@@ -167,7 +159,7 @@ get_boot_time_uncached (struct timespec *p_boot_time)
found_boot_time = runlevel_ts;
# endif
-# else /* HP-UX, Haiku */
+# elif !defined __ANDROID__ /* HP-UX, Haiku */
FILE *f = fopen (UTMP_FILE, "re");
@@ -228,6 +220,13 @@ get_boot_time_uncached (struct timespec *p_boot_time)
}
# endif
+# if defined __ANDROID__
+ if (found_boot_time.tv_sec == 0)
+ {
+ get_android_boot_time (&found_boot_time);
+ }
+#endif
+
# if defined __HAIKU__
if (found_boot_time.tv_sec == 0)
{
--
2.40.1