[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Android NDK r26 and utmpx
From: |
Bruno Haible |
Subject: |
Re: Android NDK r26 and utmpx |
Date: |
Sun, 21 Jan 2024 17:54:48 +0100 |
Hi Po Lu,
> utmpx.h is provided by this new release of the Android NDK, defining
> functions as nonfunctional as utmp.h does.
So, HAVE_UTMPX_H now is 1.
And utmpname exists but utmpxname does not exist. Therefore UTMP_NAME_FUNCTION
is no longer defined.
> The more pressing problem is that its presence suppresses the definition
> of UTMP_NAME_FUNCTION when a program is built with an __ANDROID_API__
> lower than 34, where the utmpx* series of functions were introduced,
> because the conditional for HAVE_UTMPX_H in readutmp.h does not search
> for a `utmpname' function if `utmpxname' is unavailable, with the result
> that get_android_boot_time is never invoked. Here are the relevant
> portions of config.log:
>
> configure:9462: checking for utmpx.h
> configure:9462:
> /opt/android/ndk/android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android22-clang
> -c -O2 -g3 -Werror=implicit-function-declaration conftest.c >&5
> configure:9462: $? = 0
> configure:9462: result: yes
>
> configure:16416:
> /opt/android/ndk/android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android22-clang
> -o conftest -O2 -g3 -Werror=implicit-function-declaration conftest.c
> >&5
> ld.lld: error: undefined symbol: utmpxname
> >>> referenced by conftest.c:116
> >>> /tmp/conftest-c4f4cf.o:(main)
> >>> did you mean: utmpname
> >>> defined in:
> >>> /opt/android/ndk/android-ndk-r26/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/lib/aarch64-linux-android/22/libc.so
>
> I will install a workaround in Emacs, but it ought to be fixed at the
> source.
This patch should fix it, in the simplest possible way. Committing it.
2024-01-21 Bruno Haible <bruno@clisp.org>
readutmp, boot-time: Port to Android NDK r26.
Reported by Po Lu <luangruo@yahoo.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-01/msg00063.html>.
* lib/readutmp.h: Update comments.
(UTMP_NAME_FUNCTION): Define as a no-op for Android with HAVE_UTMPX_H.
diff --git a/lib/readutmp.h b/lib/readutmp.h
index b62eb3beaa..dcfd44dbbc 100644
--- a/lib/readutmp.h
+++ b/lib/readutmp.h
@@ -114,21 +114,21 @@ enum { UT_HOST_SIZE = -1 };
Field Type Platforms
---------- ------ ---------
- ⎡ ut_user char[] glibc, musl, macOS, FreeBSD, AIX,
HP-UX, IRIX, Solaris, Cygwin
+ ⎡ ut_user char[] glibc, musl, macOS, FreeBSD, AIX,
HP-UX, IRIX, Solaris, Cygwin, Android
⎣ ut_name char[] NetBSD, Minix
- ut_id char[] glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
- ut_line char[] glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
- ut_pid pid_t glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
- ut_type short glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
- ⎡ ut_tv struct glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
+ ut_id char[] glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
+ ut_line char[] glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
+ ut_pid pid_t glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
+ ut_type short glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
+ ⎡ ut_tv struct glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
⎢ { tv_sec; tv_usec; }
⎣ ut_time time_t Cygwin
- ut_host char[] glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin
- ut_exit struct glibc, musl, NetBSD, Minix,
HP-UX, IRIX, Solaris
+ ut_host char[] glibc, musl, macOS, FreeBSD,
NetBSD, Minix, AIX, HP-UX, IRIX, Solaris, Cygwin, Android
+ ut_exit struct glibc, musl, NetBSD, Minix,
HP-UX, IRIX, Solaris, Android
{ e_termination; e_exit; }
- ut_session [long] int glibc, musl, NetBSD, Minix, IRIX,
Solaris
+ ut_session [long] int glibc, musl, NetBSD, Minix, IRIX,
Solaris, Android
⎡ ut_addr [long] int HP-UX, Cygwin
- ⎢ ut_addr_v6 [u]int[4] glibc, musl
+ ⎢ ut_addr_v6 [u]int[4] glibc, musl, Android
⎣ ut_ss struct sockaddr_storage NetBSD, Minix
*/
@@ -177,6 +177,10 @@ struct utmpx32
# define UTMP_NAME_FUNCTION utmpxname
# elif defined UTXDB_ACTIVE /* FreeBSD */
# define UTMP_NAME_FUNCTION(x) setutxdb (UTXDB_ACTIVE, x)
+# elif defined __ANDROID__ /* Android */
+/* As of Android NDK r26, the getutxent, setutxent functions are no-ops.
+ Therefore we can ignore the file name. */
+# define UTMP_NAME_FUNCTION(x) ((void) (x))
# endif
#elif HAVE_UTMP_H