UNLIKELY

Anthony Green green@moxielogic.com
Mon Jan 23 18:48:00 GMT 2012


On Mon, Jan 9, 2012 at 8:38 AM, Dmitry Nadezhin
<dmitry.nadezhin@gmail.com> wrote:
> The ffi_common.h contains definitions:
>
> #define LIKELY(x) __builtin_expect((x),1)
> #define UNLIKELY(x) __builtin_expect((x),1)
>
> I guess that the definition of UNLIKELY should be:
>
> #define UNLIKELY(x) __builtin_expect((x),0)

Oops!  Nice catch.

Thanks,

Anthony Green



>
> Also some libraries prefer to define LIKELY like this:
> #define _X_LIKELY(x) __builtin_expect(!!(x), 1)
> #define __GMP_LIKELY(cond) __builtin_expect ((cond) != 0, 1)
> but I'm not sure if it changes the generated code on any platform.



More information about the Libffi-discuss mailing list