Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()

2018-01-20 Thread Thomas Monjalon
19/11/2017 23:16, Aleksey Baulin: > 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 va

Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()

2018-01-14 Thread Stephen Hemminger
On Sun, 14 Jan 2018 01:45:42 +0300 Aleksey Baulin wrote: > Please see my comments inline. > > On Sun, Jan 14, 2018 at 1:24 AM, Thomas Monjalon > wrote: > > > Hi, > > > > I moved your top-post below and did some comments inline. > > More opinions are welcome. > > > > 13/01/2018 23:05, Aleksey B

Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()

2018-01-13 Thread Aleksey Baulin
Please see my comments inline. On Sun, Jan 14, 2018 at 1:24 AM, Thomas Monjalon wrote: > Hi, > > I moved your top-post below and did some comments inline. > More opinions are welcome. > > 13/01/2018 23:05, Aleksey Baulin: > > On Fri, Jan 12, 2018 at 6:35 PM, Thomas Monjalon > > wrote: > > > 21/

Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()

2018-01-13 Thread Thomas Monjalon
Hi, I moved your top-post below and did some comments inline. More opinions are welcome. 13/01/2018 23:05, Aleksey Baulin: > On Fri, Jan 12, 2018 at 6:35 PM, Thomas Monjalon > wrote: > > 21/11/2017 08:05, Aleksey Baulin: > > > On Mon, Nov 20, 2017 at 4:36 PM, Wiles, Keith > > wrote: > > > > > O

Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()

2018-01-13 Thread Aleksey Baulin
This is an interesting question. Perhaps, even a philosophical one. :-) 'likely(pointer)' is a perfectly legal statement in C language, as well as a concise one as compared to a more explicit (and redundant/superfluous) 'likely(pointer != NULL)'. If you _require_ this kind of explicitness in cases

Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()

2018-01-12 Thread Thomas Monjalon
21/11/2017 08:05, Aleksey Baulin: > On Mon, Nov 20, 2017 at 4:36 PM, Wiles, Keith wrote: > > > On Nov 19, 2017, at 4:16 PM, Aleksey Baulin > > wrote: > > > -#define unlikely(x) __builtin_expect((x),0) > > > +#define unlikely(x) __builtin_expect(!!(x), 0) > > > > I have not looked at the generat

Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()

2017-11-20 Thread Aleksey Baulin
Sorry for late response. Jim had given the correct answer already. You won't get an extra instruction with compiler optimization turned on. Aleksey. On Mon, Nov 20, 2017 at 4:36 PM, Wiles, Keith wrote: > > > > On Nov 19, 2017, at 4:16 PM, Aleksey Baulin > wrote: > > > > A warning is issued whe

Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()

2017-11-20 Thread Jim Thompson
> On Nov 20, 2017, at 7:36 AM, Wiles, Keith wrote: > >> On Nov 19, 2017, at 4:16 PM, Aleksey Baulin wrote: >> >> #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

Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()

2017-11-20 Thread Wiles, Keith
> On Nov 19, 2017, at 4:16 PM, Aleksey Baulin wrote: > > 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

[dpdk-dev] [PATCH] eal/common: better likely() and unlikely()

2017-11-19 Thread Aleksey Baulin
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 Bau