unofficial mirror of emacs-devel@gnu.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 16:16:02 +0200	[thread overview]
Message-ID: <4560195.WI5mOJET8L@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.)...
> 
> In file included from boot-time.c:54:0:
> boot-time-aux.h: In function 'get_linux_uptime':
> boot-time-aux.h:70:3: error: implicit declaration of function 'sysinfo' [-Werror=implicit-function-declaration]
>    if (sysinfo (&info) >= 0)
>    ^

Should be fixed by the patch below.

Paul Eggert wrote:
> Gnulib should bypass sysinfo unless it's available.

Yes. Note that it's available in Android libc already at API level 3. It's only
the declaration that was added in API level 9.

Also, if we write '#if HAVE_DECL_SYSINFO' instead of '9 <= __ANDROID_API__',
the change might be helpful also with other Linux-based libcs that may be
developed in the future.


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.

diff --git a/doc/glibc-functions/sysinfo.texi b/doc/glibc-functions/sysinfo.texi
index 3b1ade31a6..16e12b12ac 100644
--- a/doc/glibc-functions/sysinfo.texi
+++ b/doc/glibc-functions/sysinfo.texi
@@ -17,4 +17,7 @@
 @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
diff --git a/lib/boot-time-aux.h b/lib/boot-time-aux.h
index 348611fc85..e59a0fd03c 100644
--- a/lib/boot-time-aux.h
+++ b/lib/boot-time-aux.h
@@ -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;
 }
diff --git a/m4/readutmp.m4 b/m4/readutmp.m4
index 9dffe981b8..0a47f4bb77 100644
--- a/m4/readutmp.m4
+++ b/m4/readutmp.m4
@@ -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_DEFUN_ONCE([gl_PREREQ_READUTMP_H]
     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],,,






  parent reply	other threads:[~2023-08-13 14:16 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
2023-08-13 14:16     ` Bruno Haible [this message]
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=4560195.WI5mOJET8L@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 public inbox

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

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).