From patchwork Thu Oct 20 09:25:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 6081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp153185wrs; Thu, 20 Oct 2022 02:27:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4I77e4Q7Sb6IsWnt88tkf/0gnflHiPV8NIi/MXvX3/k+v+O7pbj9gjV1orHcQBjYJDG7o6 X-Received: by 2002:a17:907:805:b0:782:1a0d:337f with SMTP id wv5-20020a170907080500b007821a0d337fmr10285560ejb.475.1666258044369; Thu, 20 Oct 2022 02:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666258044; cv=none; d=google.com; s=arc-20160816; b=QuhzjzVB9GFuSTh4CA52OE0L+yeRZ/nBJTeKCY7LKEkRZU+zseNczOA3kuAspK+Ks8 VhINp9uypvQpp2ruZCylyMQRIDGm7jtWNtT5oSNwSzBlXd7oOKbxMR1KMXd9legA9TTR 6VwDSxMzhYmGtvv8GGtGyx3LJOaM5bL+vBfpLNP/1cQDmrdJUhyXHms4gFn9WBdlJpj2 5ucVdhe4MW++Te/btVljzEj4GiTe4IKdEuUoFYdbKMdslBJgJMtjVcLA1ziuNRUBUsdz S5use195JAd4co98nSwKsEbiFZ/dmVpGdGda3OICZpeAqkLxJLro33Xzu9xf30tqGqP0 lsRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=a39D+JEBFWkt60Xlc0Ik9VXp/KP0HhLBkvIl/XwRUvo=; b=nD3XKNzONj/Ode2y5gfo/lzmoVInzrU5smMhj6leleBv6KaZ/WB4CQ16/ZQhNURrU6 6NAIJfAZkFlaSaSHOr1AkrHG36doCC3x6F7mHy1CuTbWvz6QhGmv5ITbLdhkMl2PZFH8 7OCxYcPN5OIOIUC40PHscgZ+cA9E/xh7G3S2jU8Y1+uziQJeMwAJ/7PPFMhoGSulsbwf HCova/WZLczF7/260UKLU4CTniuSihOfsxrEElsm6fKdKMvk/W38K6aSOWQLs2fLgbM4 5WjmZjjw2By/f2j/ubRApEjF04Dco2pzIu+MizYsESv0BAMnvMEE0F+xvgrSgeOgv5+f K9pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=TLEAjQQ2; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id y6-20020a50e606000000b004573c1ae3fasi14361980edm.285.2022.10.20.02.27.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 02:27:24 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=TLEAjQQ2; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 92BB5385141D for ; Thu, 20 Oct 2022 09:27:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92BB5385141D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666258028; bh=a39D+JEBFWkt60Xlc0Ik9VXp/KP0HhLBkvIl/XwRUvo=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=TLEAjQQ2ApvqYwU5uyeQ0zmMgE/37RFomoXLlT0VhMyC9LX4I87yPuNAxRGE5eS1m jzV/TlvJ2DvpPcxtI0V449k159xom4f0m8tUIhtWQWHykhne960aT1mRGxL0BqbF5M 46XbfsPHcGAw/JKla4qB3MVgFu+XUsNYjWL3rslQ= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id A3EA63860759 for ; Thu, 20 Oct 2022 09:26:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A3EA63860759 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 04F47300089; Thu, 20 Oct 2022 09:26:58 +0000 (UTC) To: Tsukasa OI , Andrew Burgess , Mike Frysinger , Nick Clifton Subject: [PATCH 02/40] sim: Check known getrusage declaration existence Date: Thu, 20 Oct 2022 09:25:48 +0000 Message-Id: In-Reply-To: References: Mime-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tsukasa OI via Binutils From: Tsukasa OI Reply-To: Tsukasa OI Cc: binutils@sourceware.org Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747198194668252129?= X-GMAIL-MSGID: =?utf-8?q?1747198194668252129?= 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 in the expected format? */ #undef HAVE_DECL_GETOPT +/* Is the prototype for getrusage in 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 +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 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 ], [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 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