[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

solved: {un}likely macros?



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thursday 01 July 2004 09:35, Borislav Petkov wrote:
> Hi there people,
> first of all i would like to thank everybody for their help in figuring out
> the yesterday's asm oneliner. I have another q, though :)
> The kernel extensively uses these macros.
<snip>

Forget it, i found it in the gcc manual. It uses a builtin function in gcc to 
do better branch prediction, so when we do likely(x), we actually do 
__builtin_expect(!!(x),1) which means that it is likely that x is true, i.e., 
x == 1 and the code after it is (more :)) likely to get executed so that the 
branch prediction algorithm in the processor runs faster.

However, what's with the double negation of x - !!(x)?

Regards,
Boris.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA48IhiBySr3Fn37QRAupkAJ9M4k9+aHvoFd1l/dI0G8WjuWwCZwCdHPca
B6CBl89LoMsmc5C3w1P2LPI=
=gOCR
-----END PGP SIGNATURE-----

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/