From: ilikepie420@live.com (bob)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Re Likely and Unlikely Macro
Date: Mon, 10 Oct 2011 03:29:03 -0400 [thread overview]
Message-ID: <20111010072903.GA14410@thinkpad> (raw)
In-Reply-To: <CAA=bF1R-ALms0a3C_8c3ONgQy7hixyUsmKyaH6wXYFED4DuL4w@mail.gmail.com>
It's a shorter way of casting a pointer to an integer with boolean
values.
On Mon, Oct 10, 2011 at 11:49:54AM +0530, Asutosh Das wrote:
> Hi
> In lxr, I saw the likely and unlikely macro defined as (compiler.h)
>
> # define likely(x) (__builtin_constant_p(x) ? !!(x) :
> __branch_check__(x, 1))
> 116# endif
> 117# ifndef unlikely
> 118# define unlikely(x) (__builtin_constant_p(x) ? !!(x) :
> __branch_check__(x, 0))
> 119# endif
> 120
> ..... some other defines
>
> #else
> 146# define likely(x) __builtin_expect(!!(x), 1)
> 147# define unlikely(x) __builtin_expect(!!(x), 0)
> 148#endif
>
> I cannot understand the intention behind !!(x).
> Please can you let me know why !!(x) is required here.
>
> TIA
> --
> ~/asd
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
next prev parent reply other threads:[~2011-10-10 7:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-10 6:19 Re Likely and Unlikely Macro Asutosh Das
2011-10-10 7:29 ` bob [this message]
2011-10-10 15:52 ` Mulyadi Santosa
2011-10-11 4:18 ` Asutosh Das
2011-10-12 4:36 ` pankaj singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111010072903.GA14410@thinkpad \
--to=ilikepie420@live.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.