Re: likely, unlikely and builtin_expect()

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

 





I understand the meaning of likely() and unlikely() in linux/compiler.h,
but I don't undertand the meaning of !! in the definition.

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

why not this?:

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


!!(x) ensures, the first argument to __builtin_expect is always 0 or 1 regardless of input.

Regards,
Mohan

--
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