all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: Paul Eggert <eggert@cs.ucla.edu>, Po Lu <luangruo@yahoo.com>
Cc: bug-gnulib@gnu.org, Emacs-devel@gnu.org
Subject: Re: boot-time: straighten code
Date: Sun, 13 Aug 2023 15:45:23 +0200	[thread overview]
Message-ID: <3848098.Sr9nCIn9ua@nimes> (raw)
In-Reply-To: <87v8djoc6n.fsf@yahoo.com>

Po Lu wrote:
> During the automated build of the Android port, the following errors
> were encountered with the Android NDK r10b and __ANDROID_API__ set to 8
> (which is the oldest configuration Emacs supports.)
> ...
> boot-time.c:111:26: note: each undeclared identifier is reported only once for each function it appears in
> boot-time.c:126:3: error: implicit declaration of function 'endutent' [-Werror=implicit-function-declaration]
>    END_UTMP_ENT ();
>    ^

endutent() exists in Android, already in API 8. It's just that its declaration
is missing from <utmp.h> until ca. 2015.

Should be fixed through this patch. Also, it removes a declaration that was
needed only for Ultrix 4.3. Gnulib dropped Ultrix support in 2018.

Paul Eggert wrote:
> As I understand it, the utmp/utmpx functions 
> are a losing cause on Android since they never return anything. If so, 
> it's simpler to bypass these functions on that platform.

It's more future-proof to continue to use the API that they have. Who knows,
they might add useful data into the UTMP_FILE at some point. (E.g. they had a
broken localeconv() function for a long time; then they actually fixed it.)


2023-08-13  Bruno Haible  <bruno@clisp.org>

	readutmp, boot-time: Fix compilation error on old Android.
	Reported by Po Lu in
	<https://lists.gnu.org/archive/html/bug-gnulib/2023-08/msg00108.html>.
	* lib/readutmp.c (endutent): New fallback declaration, for Android.
	(getutent): Remove Ultrix workaround from 2000-04-05.
	* lib/boot-time.c: Likewise.
	* m4/readutmp.m4 (gl_PREREQ_READUTMP_H): Test whether endutent is
	declared, not getutent.
	* doc/glibc-functions/endutent.texi: Mention the Android bug.

diff --git a/doc/glibc-functions/endutent.texi b/doc/glibc-functions/endutent.texi
index 5e12e23c44..b4f3dd397a 100644
--- a/doc/glibc-functions/endutent.texi
+++ b/doc/glibc-functions/endutent.texi
@@ -28,4 +28,7 @@
 @item
 This function is missing on some platforms:
 macOS 11.1, FreeBSD 13.0, OpenBSD 6.7, Minix 3.1.8, mingw, MSVC 14.
+@item
+This function is not declared on some platforms:
+Android before ca.@: 2015.
 @end itemize
diff --git a/lib/boot-time.c b/lib/boot-time.c
index d813bfa582..c359954f19 100644
--- a/lib/boot-time.c
+++ b/lib/boot-time.c
@@ -65,8 +65,10 @@
 # define UT_USER(UT) ((UT)->ut_user)
 #endif
 
-#if !HAVE_UTMPX_H && HAVE_UTMP_H && defined UTMP_NAME_FUNCTION && !HAVE_DECL_GETUTENT
-struct utmp *getutent (void);
+#if !HAVE_UTMPX_H && HAVE_UTMP_H && defined UTMP_NAME_FUNCTION
+# if !HAVE_DECL_ENDUTENT /* Android */
+void endutent (void);
+# endif
 #endif
 
 #if defined __linux__ || HAVE_UTMPX_H || HAVE_UTMP_H || defined __CYGWIN__ || defined _WIN32
diff --git a/lib/readutmp.c b/lib/readutmp.c
index ef9f0aff43..0b7732b165 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -314,9 +314,11 @@ have_boot_time (struct utmp_alloc a)
   return false;
 }
 
-# if !HAVE_UTMPX_H && HAVE_UTMP_H && defined UTMP_NAME_FUNCTION && !HAVE_DECL_GETUTENT
-struct utmp *getutent (void);
+#if !HAVE_UTMPX_H && HAVE_UTMP_H && defined UTMP_NAME_FUNCTION
+# if !HAVE_DECL_ENDUTENT /* Android */
+void endutent (void);
 # endif
+#endif
 
 static int
 read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf,
diff --git a/m4/readutmp.m4 b/m4/readutmp.m4
index fff8d4eb7b..9dffe981b8 100644
--- a/m4/readutmp.m4
+++ b/m4/readutmp.m4
@@ -1,4 +1,4 @@
-# readutmp.m4 serial 28
+# readutmp.m4 serial 29
 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,
@@ -55,7 +55,7 @@ AC_DEFUN_ONCE([gl_PREREQ_READUTMP_H]
   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
     dnl Prerequisites of lib/readutmp.h and lib/readutmp.c.
     AC_CHECK_FUNCS_ONCE([utmpname utmpxname])
-    AC_CHECK_DECLS([getutent],,,[[
+    AC_CHECK_DECLS([endutent],,,[[
 /* <sys/types.h> is a prerequisite of <utmp.h> on FreeBSD 8.0, OpenBSD 4.6.  */
 #include <sys/types.h>
 #ifdef HAVE_UTMP_H






  parent reply	other threads:[~2023-08-13 13:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4536176.VaOIPsP7d9@nimes>
2023-08-13  2:49 ` boot-time: straighten code Paul Eggert
2023-08-13  3:26   ` Po Lu
2023-08-13  6:35     ` Paul Eggert
2023-08-13 13:45     ` Bruno Haible [this message]
2023-08-13 14:16     ` Bruno Haible
2023-08-13 14:36     ` Bruno Haible
2023-08-13 23:44       ` Po Lu
2023-08-13 23:59         ` Bruno Haible
2023-08-14  1:07           ` Po Lu
2023-08-14  2:14             ` Corwin Brust
2023-08-15 19:57               ` Windows port binaries Bruno Haible
2023-08-16  6:45                 ` Po Lu
2023-08-16 11:36                 ` Eli Zaretskii
2023-08-17 14:01                   ` Bruno Haible
2023-08-17 14:14                     ` Eli Zaretskii
2023-08-14  8:02   ` boot-time: straighten code Andreas Schwab
2023-08-14  9:15     ` Bruno Haible
2023-08-14  9:20       ` Andreas Schwab
2023-08-14 10:19         ` Bruno Haible
2023-08-14 10:33           ` Andreas Schwab
2023-08-14 13:51             ` Bruno Haible
2023-08-15 23:03               ` Paul Eggert
2023-08-15 21:12   ` Bruno Haible
2023-08-16 10:13     ` 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

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

  git send-email \
    --in-reply-to=3848098.Sr9nCIn9ua@nimes \
    --to=bruno@clisp.org \
    --cc=Emacs-devel@gnu.org \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    --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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.