likely/unlikely macro.

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

 



Hi,

How may I ask for your help?
Now I'm studying the linux scheduler(sched.c).
And I'm wondering what likey()/unlikely macros mean.
I could find they're defined in linux/compiler.h as follows.

/*
 * Generic compiler-dependent macros required for kernel
 * build go below this comment. Actual compiler/compiler version
 * specific implementations come from the above header files
 */

#define likely(x)	__builtin_expect(!!(x), 1)
#define unlikely(x)	__builtin_expect(!!(x), 0)

And I could find __builtin_expect()'s definition only in linux/compiler-gcc2.h as a follow.
I don't know what's going if __GNUC_MINOR__ is over 96, though...

#if __GNUC_MINOR__ < 96
# define __builtin_expect(x, expected_value) (x)
#endif

As a result, although it seems likely() and unlikely() do nothing, is my expectation correct?
If there are other references about this, please let me know.

Regards,
Shinpei Kato
--
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