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 1C9B5A0564; Thu, 11 Mar 2021 22:08:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EA2884014D; Thu, 11 Mar 2021 22:08:37 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 624A340141 for ; Thu, 11 Mar 2021 22:08:36 +0100 (CET) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id A7BED208D370; Thu, 11 Mar 2021 13:08:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A7BED208D370 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1615496915; bh=8KfNyRZf1sDNb42HhOd2oiptmrJR8EDqXyg4rqQUON4=; h=From:To:Cc:Subject:Date:From; b=EcTYoZkmxClbM0jLMzsm7Giy/u4+O2lpCTTxDCk62+UAWbrlN7JyspYG0QE4ppqqs U5fIHfQxDz9dAizpkZiFs8mKmROKI1o9y3Mo/eHyTgW7vSb7HFsFjVypZVIbStISzt G+Xdgcv0q5USx4w1i5uz1pz4DSNSdBzvFpQQxaGw= From: Tyler Retzlaff To: dev@dpdk.org Cc: thomas@monjalon.net Date: Thu, 11 Mar 2021 13:08:31 -0800 Message-Id: <1615496911-7050-1-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 Subject: [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" 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); \ + typeof(v) ceil = RTE_ALIGN_MUL_CEIL(_v, _m); \ + typeof(v) floor = RTE_ALIGN_MUL_FLOOR(_v, _m); \ + (ceil - (_v)) > ((_v) - floor) ? floor : ceil; \ }) /** -- 2.30.0.vfs.0.2