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 <aleksey.baulin@gmail.com>
This commit is contained in:
parent
cd7fc8a84b
commit
7a89f8eedc
@ -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_ */
|
||||
|
Loading…
Reference in New Issue
Block a user