DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()
@ 2017-11-19 22:16 Aleksey Baulin
  2017-11-20 13:36 ` Wiles, Keith
  2018-01-20 16:28 ` Thomas Monjalon
  0 siblings, 2 replies; 10+ messages in thread
From: Aleksey Baulin @ 2017-11-19 22:16 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: 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 <Aleksey.Baulin@gmail.com>
---
 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-01-20 16:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-19 22:16 [dpdk-dev] [PATCH] eal/common: better likely() and unlikely() Aleksey Baulin
2017-11-20 13:36 ` Wiles, Keith
2017-11-20 17:21   ` Jim Thompson
2017-11-21  7:05   ` Aleksey Baulin
2018-01-12 15:35     ` Thomas Monjalon
2018-01-13 22:05       ` Aleksey Baulin
2018-01-13 22:24         ` Thomas Monjalon
2018-01-13 22:45           ` Aleksey Baulin
2018-01-14 17:17             ` Stephen Hemminger
2018-01-20 16:28 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).