From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7B32FA0564; Fri, 12 Mar 2021 01:41:04 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB71A4067E; Fri, 12 Mar 2021 01:41:03 +0100 (CET) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 17DDA4014D for ; Fri, 12 Mar 2021 01:41:01 +0100 (CET) IronPort-SDR: cdeeiV3aj3PNUc+RxbmjCeTa3Qg2WPJZV1wM9KyAFFFxjCrjYaDqwA6xTFmcnlA67T8L08291V txNqStCI2HLg== X-IronPort-AV: E=McAfee;i="6000,8403,9920"; a="185406868" X-IronPort-AV: E=Sophos;i="5.81,241,1610438400"; d="scan'208";a="185406868" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2021 16:40:58 -0800 IronPort-SDR: PB6F0KR7CN9+zntpJTQVB6f2YHqiyy90Nmt6YPib/iArQ2R7tciSO5wm7boBYfnbx57/0y1G1Z 2S3vzQcQaHaQ== X-IronPort-AV: E=Sophos;i="5.81,241,1610438400"; d="scan'208";a="448461706" Received: from rmenon-desk.amr.corp.intel.com (HELO [10.166.30.253]) ([10.166.30.253]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2021 16:40:58 -0800 To: Tyler Retzlaff , dev@dpdk.org Cc: thomas@monjalon.net References: <1615496911-7050-1-git-send-email-roretzla@linux.microsoft.com> From: Ranjit Menon Message-ID: Date: Thu, 11 Mar 2021 16:40:58 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <1615496911-7050-1-git-send-email-roretzla@linux.microsoft.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [dpdk-dev] [PATCH] eal: avoid side effects in RTE_ALIGN_MUL_NEAR(v, mul) for v and mul X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 3/11/2021 1:08 PM, Tyler Retzlaff wrote: > Avoid expanding v and mul parameters multiple times in the macro. based > on usage of the macro it seems like side effects were not intended. > > For example: > ``return RTE_ALIGN_MUL_NEAR(rte_rdtsc() - start, CYC_PER_10MHZ);'' > > Signed-off-by: Tyler Retzlaff > --- > lib/librte_eal/include/rte_common.h | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/lib/librte_eal/include/rte_common.h b/lib/librte_eal/include/rte_common.h > index 1b630baf1..640befee2 100644 > --- a/lib/librte_eal/include/rte_common.h > +++ b/lib/librte_eal/include/rte_common.h > @@ -345,9 +345,11 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void) > */ > #define RTE_ALIGN_MUL_NEAR(v, mul) \ > ({ \ > - typeof(v) ceil = RTE_ALIGN_MUL_CEIL(v, mul); \ > - typeof(v) floor = RTE_ALIGN_MUL_FLOOR(v, mul); \ > - (ceil - (v)) > ((v) - floor) ? floor : ceil; \ > + typeof(v) _v = (v); \ > + typeof(v) _m = (mul); \ For consistency sake, can this variable be changed to '_mul'? > + typeof(v) ceil = RTE_ALIGN_MUL_CEIL(_v, _m); \ > + typeof(v) floor = RTE_ALIGN_MUL_FLOOR(_v, _m); \ > + (ceil - (_v)) > ((_v) - floor) ? floor : ceil; \ > }) > > /** ranjit m.