public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tsukasa OI <research_trasio@irq.a4lg.com>
To: Tsukasa OI <research_trasio@irq.a4lg.com>,
	Andrew Burgess <aburgess@redhat.com>,
	Mike Frysinger <vapier@gentoo.org>,
	Nick Clifton <nickc@redhat.com>
Cc: binutils@sourceware.org
Subject: [PATCH 02/40] sim: Check known getrusage declaration existence
Date: Thu, 20 Oct 2022 09:25:48 +0000	[thread overview]
Message-ID: <b05adb17e401d621dbdad791281bc7af7806906e.1666257885.git.research_trasio@irq.a4lg.com> (raw)
In-Reply-To: <cover.1666257885.git.research_trasio@irq.a4lg.com>

Clang generates a warning if there is a function declaration/definition
with zero arguments. Such declarations/definitions without a prototype (an
argument list) are deprecated forms of indefinite arguments
("-Wdeprecated-non-prototype"). On the default configuration, it causes a
build failure (unless "--disable-werror" is specified).

Such getrusage function declarations are placed in three files under sim/ppc
and to avoid defining those on the modern environments, this commit will
make the configuration script to find the known declaration of getrusage
and defines HAVE_DECL_GETRUSAGE if it finds one.

If we find one (and we *will* in most modern environments), we don't need
to rely on the deprecated declarations.
---
 sim/config.h.in  |  4 ++++
 sim/configure    | 32 ++++++++++++++++++++++++++++++++
 sim/configure.ac | 10 ++++++++++
 3 files changed, 46 insertions(+)

diff --git a/sim/config.h.in b/sim/config.h.in
index 9a94b289e46..bc7ec588ec6 100644
--- a/sim/config.h.in
+++ b/sim/config.h.in
@@ -44,6 +44,10 @@
 /* Is the prototype for getopt in <unistd.h> in the expected format? */
 #undef HAVE_DECL_GETOPT
 
+/* Is the prototype for getrusage in <sys/resource.h> in the expected format?
+   */
+#undef HAVE_DECL_GETRUSAGE
+
 /* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
    */
 #undef HAVE_DECL_TZNAME
diff --git a/sim/configure b/sim/configure
index dac7f085be1..fbdd256d374 100755
--- a/sim/configure
+++ b/sim/configure
@@ -16460,6 +16460,38 @@ $as_echo "#define HAVE_DECL_GETOPT 1" >>confdefs.h
 
 fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a known getrusage prototype in sys/resource.h" >&5
+$as_echo_n "checking for a known getrusage prototype in sys/resource.h... " >&6; }
+if ${sim_cv_decl_getrusage_sys_resource_h+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/resource.h>
+int
+main ()
+{
+extern int getrusage (int, struct rusage *);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  sim_cv_decl_getrusage_sys_resource_h=yes
+else
+  sim_cv_decl_getrusage_sys_resource_h=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sim_cv_decl_getrusage_sys_resource_h" >&5
+$as_echo "$sim_cv_decl_getrusage_sys_resource_h" >&6; }
+if test $sim_cv_decl_getrusage_sys_resource_h = yes; then
+
+$as_echo "#define HAVE_DECL_GETRUSAGE 1" >>confdefs.h
+
+fi
+
 
 
 
diff --git a/sim/configure.ac b/sim/configure.ac
index be0cfdbea32..9411fc10f9d 100644
--- a/sim/configure.ac
+++ b/sim/configure.ac
@@ -187,6 +187,16 @@ if test $sim_cv_decl_getopt_unistd_h = yes; then
 	    [Is the prototype for getopt in <unistd.h> in the expected format?])
 fi
 
+AC_MSG_CHECKING(for a known getrusage prototype in sys/resource.h)
+AC_CACHE_VAL(sim_cv_decl_getrusage_sys_resource_h,
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/resource.h>], [extern int getrusage (int, struct rusage *);])],
+sim_cv_decl_getrusage_sys_resource_h=yes, sim_cv_decl_getrusage_sys_resource_h=no)])
+AC_MSG_RESULT($sim_cv_decl_getrusage_sys_resource_h)
+if test $sim_cv_decl_getrusage_sys_resource_h = yes; then
+  AC_DEFINE([HAVE_DECL_GETRUSAGE], 1,
+	    [Is the prototype for getrusage in <sys/resource.h> in the expected format?])
+fi
+
 dnl These are unfortunate.  They are conditionally called by other sim macros
 dnl but always used by common/Make-common.in.  So we have to subst here even
 dnl when the rest of the code is in the respective macros.  Once we merge the
-- 
2.34.1


  parent reply	other threads:[~2022-10-20  9:26 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20  9:25 [PATCH 00/40] sim+gdb: Suppress warnings if built with Clang (big batch 1) Tsukasa OI
2022-10-20  9:25 ` [PATCH 01/40] gdb/unittests: PR28413, suppress warnings generated by Gnulib Tsukasa OI
2022-10-20  9:25 ` Tsukasa OI [this message]
2022-10-20  9:25 ` [PATCH 03/40] sim/aarch64: Remove unused functions Tsukasa OI
2022-10-20  9:25 ` [PATCH 04/40] cpu/cris: Initialize some variables on CRIS CPU Tsukasa OI
2022-10-22  1:59   ` Hans-Peter Nilsson
2022-10-20  9:25 ` [PATCH 05/40] cpu/cris: Add u-stall virtual unit to CRIS v32 Tsukasa OI
2022-10-22  1:44   ` Hans-Peter Nilsson
2022-10-20  9:25 ` [PATCH 06/40] sim/cris: Move declarations of f_specific_init Tsukasa OI
2022-10-22  1:46   ` Hans-Peter Nilsson
2022-10-20  9:25 ` [PATCH 07/40] sim/cris: Regenerate with CGEN Tsukasa OI
2022-10-22  2:02   ` Hans-Peter Nilsson
2022-10-20  9:25 ` [PATCH 08/40] sim/erc32: Insert void parameter Tsukasa OI
2022-10-20  9:25 ` [PATCH 09/40] sim/erc32: Use int32_t as event callback argument Tsukasa OI
2022-10-20  9:25 ` [PATCH 10/40] sim/erc32: Use int32_t as IRQ " Tsukasa OI
2022-10-20  9:25 ` [PATCH 11/40] cpu/frv: Initialize some variables Tsukasa OI
2022-10-20  9:25 ` [PATCH 12/40] sim/frv: Initialize nesr variable Tsukasa OI
2022-10-20  9:25 ` [PATCH 13/40] sim/frv: Initialize some variables Tsukasa OI
2022-10-20  9:26 ` [PATCH 14/40] sim/frv: Add explicit casts Tsukasa OI
2022-10-20  9:26 ` [PATCH 15/40] sim/h8300: Add "+ 0x0" to avoid self-assignments Tsukasa OI
2022-10-25 13:54   ` Jeff Law
2022-10-20  9:26 ` [PATCH 16/40] sim/lm32: fix some missing function declaration warnings Tsukasa OI
2022-10-20  9:26 ` [PATCH 17/40] sim/lm32: Add explicit casts Tsukasa OI
2022-10-20  9:32 ` [PATCH 00/40] sim+gdb: Suppress warnings if built with Clang (big batch 1) Tsukasa OI
2022-10-22 19:01 ` Mike Frysinger
2022-10-24  7:59   ` Tsukasa OI

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=b05adb17e401d621dbdad791281bc7af7806906e.1666257885.git.research_trasio@irq.a4lg.com \
    --to=research_trasio@irq.a4lg.com \
    --cc=aburgess@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=nickc@redhat.com \
    --cc=vapier@gentoo.org \
    /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).