From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Bruno Haible Newsgroups: gmane.comp.lib.gnulib.bugs,gmane.emacs.devel Subject: Re: boot-time: straighten code Date: Sun, 13 Aug 2023 16:16:02 +0200 Message-ID: <4560195.WI5mOJET8L@nimes> References: <4536176.VaOIPsP7d9@nimes> <5a77c0b9-8692-83bf-1aca-2f1d27122877@cs.ucla.edu> <87v8djoc6n.fsf@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8903"; mail-complaints-to="usenet@ciao.gmane.io" Cc: bug-gnulib@gnu.org, Emacs-devel@gnu.org To: Paul Eggert , Po Lu Original-X-From: bug-gnulib-bounces+gnu-bug-gnulib=m.gmane-mx.org@gnu.org Sun Aug 13 16:17:34 2023 Return-path: Envelope-to: gnu-bug-gnulib@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qVBuP-00025v-Ms for gnu-bug-gnulib@m.gmane-mx.org; Sun, 13 Aug 2023 16:17:33 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qVBtG-0001h4-9X; Sun, 13 Aug 2023 10:16:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVBt5-0001gW-MC; Sun, 13 Aug 2023 10:16:11 -0400 Original-Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qVBt0-0001WW-GF; Sun, 13 Aug 2023 10:16:11 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1691936162; cv=none; d=strato.com; s=strato-dkim-0002; b=rqVefq3rwejyczHVtri4i5AQVlL5wQG2KvtuPOSMzBMRAN9SZmmWH3SyniKmQVFA6A bbtRPc26YdmnHebN6BN4s3ate3o8CfWj9Z4jN1+w+R7tue7b/jzzS3nDko5P9rhMA7m6 ANMdSswjEME+eODD0BslPrn1leGQO4JC8NHOhWcTAZThnuBKX9vlxImhW0Hrbn4JAbsr LcMy+25aT12FK4eaz676ByV5bP95sDUNrq5srI5PPdGhuckzdYEWz3n7KlN+4GEv7e9V 4rqxz6UqZyqhcqWULqE7mNzFQ9Lb9E81s6/FpLqbd+oV2I1cPnssBakVoHO1cYYC0HHf xcfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1691936162; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=gGBzUR0nIVGODWKIeWH+IFjYRfnsayfk9uzLOYdlE1w=; b=AcY90EL86ZUoGP8IsUBmEuZ7wwWbbpbNxuI0j4Pm4pXDs6WBlGITdSlEjU9gbWHWDj l9FMpFLCQn/3qIWxsVbo0v78XVJX+KZaI3zHrCi+bxm4uby2AfwKTfI5n+jN8mRY6vtt 8ECZMyVQaU0P+xUUjVIRMtOyQe15sU4U5UKCHCJ9JuH88M837BhPvD+Tv4FFhRQSwHvl 5ZrgBNLeMCy0sDw/Ne1KMq9jCvuvjIgpKSs7fTz8qBP/iHF/4bweGdXlBV3QeasIgZRm g4B1dvnwxySSzexTykb1diCLr2REdkMIKw+i1ryA+P7DEA932JB99H1z6PIRpXU1gFI0 RCHQ== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1691936162; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=gGBzUR0nIVGODWKIeWH+IFjYRfnsayfk9uzLOYdlE1w=; b=tfDWpzZaQrBpvJ/5ZACua3Q44D/xgouPHpKvjxMmApbl0fxrjelXDdktvgDMhpSpJs vcgeMU9VBuR0XpAyMBtnMR604bdFcC9uDLSkgT1Od/6oCAsIid+TZpjFtGSZa5YlAAfu M6rY+q1F+1KUPcVASudIAzc9cK3tyyCHMTS9gDcU5zkP6E3AmSeczR3P+/nkNHBtnE52 IX7tTPo9rqWm6p7pyx5lRxaZ4dkqvEqp0enZCMXPnwT/EyxD6w1EWF5vE7nCEl/OvQ+P StY4rdTZpCe7reh6LGfzfo2l9FDKgISXAelPjvuNLrv7Jji4pwA04OIP3Jenfvo9zZHE zzEA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1691936162; s=strato-dkim-0003; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=gGBzUR0nIVGODWKIeWH+IFjYRfnsayfk9uzLOYdlE1w=; b=ndkzotTAzgN4JdDOyWqGgj58hL/Hv4Frgbi+fWhS5Nxl41NDm9zVYTusVUPQIgU97T S6vGHjYLhpkVR43KFdBg== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpPF3fYsxbAVaMn7wIQE2qpZc5CC1Q==" Original-Received: from nimes.localnet by smtp.strato.de (RZmta 49.6.6 AUTH) with ESMTPSA id x129eaz7DEG2AYW (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Sun, 13 Aug 2023 16:16:02 +0200 (CEST) In-Reply-To: <87v8djoc6n.fsf@yahoo.com> Received-SPF: none client-ip=85.215.255.50; envelope-from=bruno@clisp.org; helo=mo4-p01-ob.smtp.rzone.de X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+gnu-bug-gnulib=m.gmane-mx.org@gnu.org Original-Sender: bug-gnulib-bounces+gnu-bug-gnulib=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.comp.lib.gnulib.bugs:48174 gmane.emacs.devel:308679 Archived-At: 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 readutmp, boot-time: Fix compilation error on Android API 8. Reported by Po Lu in . * 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 + ]]) + AC_CHECK_HEADERS_ONCE([sys/param.h]) dnl requires on OpenBSD 4.0. AC_CHECK_HEADERS([sys/sysctl.h],,,