Re: likely/unlikely macro.

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

 



In short, if there is the expression "x", when we just read over kernel
codes, we can consider "likely(x)" and "unlikely(x)" as just the
expression "x".
But we know "likely(x)" implies "x" is likely to be true and "unlikely(x)"
is likely to be false.
It makes easier to read kernel codes.

Anyway, I really appreciate your help. I could never get it without your
help.

Thanks,
Shinpei Kato

On Thu, 04 Dec 2003 16:52:56 +0300
"Ruslan U. Zakirov" <cubic@wildgate.miee.ru> wrote:

> > Shinpei Kato wrote:
> > Thank you for your reply.
> > 
> > So, for example, the expression "if (likely(prev != next))" is same as "if
> > ((prev != next) == 1)", isn't it?
> More correct would be next:
> if (gcc support __builtin_expect) {
> 	we do nothing and likely(prev!=next) => __builtin_expect((prev!=next),1)
> 	then gcc use this information for optimization, this branch of code 
> would be more otimized then alternatives.
> } else {
> 	likely(prev!=next) => (prev != next)
> 	so we don't break compilation and don't do any optimization.
> }
> > Then, unlikely is opposite of that.
> yes
> [snip]
> 		Best regards. Ruslan.
> 



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


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux