Re: [PATCH] scripts: coccinelle: check for !(un)?likely usage

From: Denis Efremov
Date: Wed Aug 28 2019 - 09:59:01 EST


On 8/28/19 3:41 PM, Denis Efremov wrote:
>
>>
>> As a human I am confused. Is !likely(x) equivalent to x or !x?
>>
>> Julia
>>
>
> As far as I could understand it:
>
> # define likely(x) __builtin_expect(!!(x), 1)
> !likely(x)
> !__builtin_expect(!!(x), 1)
> !((!!(x)) == 1)
> (!!(x)) != 1, since !! could result in 0 or 1
> (!!(x)) == 0
> !(!!(x))
> !!!(x)
> !(x)
>

Thanks Rasmus for the explanation, this should be:
!likely(x)
!__builtin_expect(!!(x), 1)
!(!!(x))
!!!(x)
!(x)

Denis