From: Aleksey Baulin Date: Sun, 19 Nov 2017 22:16:04 +0000 (+0300) Subject: eal: improve likely and unlikely macros X-Git-Tag: spdx-start~130 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7a89f8eedc052f7c4030e980bdac25ff489efbb0;p=dpdk.git eal: improve likely and unlikely macros 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 --- diff --git a/lib/librte_eal/common/include/rte_branch_prediction.h b/lib/librte_eal/common/include/rte_branch_prediction.h index bb26f415f2..854ef9e5dd 100644 --- a/lib/librte_eal/common/include/rte_branch_prediction.h +++ b/lib/librte_eal/common/include/rte_branch_prediction.h @@ -21,7 +21,7 @@ * */ #ifndef likely -#define likely(x) __builtin_expect((x),1) +#define likely(x) __builtin_expect(!!(x), 1) #endif /* likely */ /** @@ -35,7 +35,7 @@ * */ #ifndef unlikely -#define unlikely(x) __builtin_expect((x),0) +#define unlikely(x) __builtin_expect(!!(x), 0) #endif /* unlikely */ #endif /* _RTE_BRANCH_PREDICTION_H_ */