From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aleksey Baulin Subject: [PATCH] eal/common: better likely() and unlikely() Date: Mon, 20 Nov 2017 01:16:04 +0300 Message-ID: <1511129764-23123-1-git-send-email-Aleksey.Baulin@gmail.com> Cc: dev@dpdk.org To: Thomas Monjalon Return-path: Received: from mail-lf0-f68.google.com (mail-lf0-f68.google.com [209.85.215.68]) by dpdk.org (Postfix) with ESMTP id 924C47D06 for ; Sun, 19 Nov 2017 23:16:06 +0100 (CET) Received: by mail-lf0-f68.google.com with SMTP id a132so8009190lfa.7 for ; Sun, 19 Nov 2017 14:16:06 -0800 (PST) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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. Signed-off-by: Aleksey Baulin --- lib/librte_eal/common/include/rte_branch_prediction.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 */ /** @@ -64,7 +64,7 @@ * */ #ifndef unlikely -#define unlikely(x) __builtin_expect((x),0) +#define unlikely(x) __builtin_expect(!!(x), 0) #endif /* unlikely */ #endif /* _RTE_BRANCH_PREDICTION_H_ */ -- 2.7.4