public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
* UNLIKELY
@ 2012-01-09 13:38 Dmitry Nadezhin
  2012-01-23 18:48 ` UNLIKELY Anthony Green
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Nadezhin @ 2012-01-09 13:38 UTC (permalink / raw)
  To: libffi-discuss

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)

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: UNLIKELY
  2012-01-09 13:38 UNLIKELY Dmitry Nadezhin
@ 2012-01-23 18:48 ` Anthony Green
  0 siblings, 0 replies; 2+ messages in thread
From: Anthony Green @ 2012-01-23 18:48 UTC (permalink / raw)
  To: Dmitry Nadezhin; +Cc: libffi-discuss

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-23 18:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-09 13:38 UNLIKELY Dmitry Nadezhin
2012-01-23 18:48 ` UNLIKELY Anthony Green

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).