bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Po Lu <luangruo@yahoo.com>
Cc: bug-gnulib@gnu.org
Subject: Re: Android NDK r26 and utmpx
Date: Sat, 20 Jan 2024 20:04:14 -0800	[thread overview]
Message-ID: <a6019e22-2b2d-4301-866f-81dd8fe38fc9@cs.ucla.edu> (raw)
In-Reply-To: <87r0ibtkyh.fsf@yahoo.com>

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

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.

[-- Attachment #2: 0001-boot-time-port-to-Android-SDK-r26.patch --]
[-- Type: text/x-patch, Size: 2686 bytes --]

From 5b48472effc4174d8c25bd46736fe7236ef36aae Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@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  <eggert@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  <bruno@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


  reply	other threads:[~2024-01-21  4:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87v87ntq4m.fsf.ref@yahoo.com>
2024-01-21  1:46 ` Android NDK r26 and utmpx Po Lu
2024-01-21  3:04   ` Paul Eggert
2024-01-21  3:38     ` Po Lu
2024-01-21  4:04       ` Paul Eggert [this message]
2024-01-21  5:11         ` Po Lu
2024-01-21 16:54   ` Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a6019e22-2b2d-4301-866f-81dd8fe38fc9@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=bug-gnulib@gnu.org \
    --cc=luangruo@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).