From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 9183E7CC4 for ; Mon, 20 Nov 2017 14:36:32 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Nov 2017 05:36:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,427,1505804400"; d="scan'208";a="1246388139" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga002.fm.intel.com with ESMTP; 20 Nov 2017 05:36:29 -0800 Received: from fmsmsx117.amr.corp.intel.com ([169.254.3.51]) by FMSMSX105.amr.corp.intel.com ([169.254.4.92]) with mapi id 14.03.0319.002; Mon, 20 Nov 2017 05:36:29 -0800 From: "Wiles, Keith" To: Aleksey Baulin CC: Thomas Monjalon , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely() Thread-Index: AQHTYYQK7ofnBlbLF06caME5wJhlOKMdzDYA Date: Mon, 20 Nov 2017 13:36:28 +0000 Message-ID: References: <1511129764-23123-1-git-send-email-Aleksey.Baulin@gmail.com> In-Reply-To: <1511129764-23123-1-git-send-email-Aleksey.Baulin@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.28.182] Content-Type: text/plain; charset="us-ascii" Content-ID: <2FCE45E63032B74B81E855C0CEFD4EB1@intel.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Nov 2017 13:36:34 -0000 > On Nov 19, 2017, at 4:16 PM, Aleksey Baulin wr= ote: >=20 > A warning is issued when using an argument to likely() or unlikely() > builtins which is evaluated to a pointer value, as __builtin_expect() > expects a 'long int' type for its first argument. With this fix > a pointer value is converted to an integer with the value of 0 or 1. >=20 > Signed-off-by: Aleksey Baulin > --- > lib/librte_eal/common/include/rte_branch_prediction.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_eal/common/include/rte_branch_prediction.h b/lib/= librte_eal/common/include/rte_branch_prediction.h > index a6a56d1..2e7dc69 100644 > --- a/lib/librte_eal/common/include/rte_branch_prediction.h > +++ b/lib/librte_eal/common/include/rte_branch_prediction.h > @@ -50,7 +50,7 @@ > * > */ > #ifndef likely > -#define likely(x) __builtin_expect((x),1) > +#define likely(x) __builtin_expect(!!(x), 1) > #endif /* likely */ >=20 > /** > @@ -64,7 +64,7 @@ > * > */ > #ifndef unlikely > -#define unlikely(x) __builtin_expect((x),0) > +#define unlikely(x) __builtin_expect(!!(x), 0) I have not looked at the generated code, but does this add some extra instr= uction now to do the !!(x) ? > #endif /* unlikely */ >=20 > #endif /* _RTE_BRANCH_PREDICTION_H_ */ > --=20 > 2.7.4 >=20 Regards, Keith