Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Mar 2010 15:13:38 +0100
From:      Max Laier <max@love2party.net>
To:        freebsd-arch@freebsd.org
Subject:   Re: likely and unlikely
Message-ID:  <201003121513.38721.max@love2party.net>
In-Reply-To: <20100312124258.GE1738@mole.fafoe.narf.at>
References:  <hndbed$vok$1@dough.gmane.org> <20100312122559.GU8200@hoeg.nl> <20100312124258.GE1738@mole.fafoe.narf.at>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 12 March 2010 13:42:59 Stefan Farfeleder wrote:
> On Fri, Mar 12, 2010 at 01:26:08PM +0100, Ed Schouten wrote:
> > Hi Ivan,
> >
> > * Ivan Voras <ivoras@freebsd.org> wrote:
> > > Wouldn't it be more convenient to have a single global definition of
> > > them, under #ifdef __GNUC__ for example in sys/stddef.h ?
> >
> > Wouldn't it be better to have them in sys/cdefs.h?
> 
> Putting macros 'likely' and 'unlikely' into sys/cdefs.h creates a big
> namespace violation problem; C code using those identifiers will break.

In addition, I don't think it's a good thing to make these too easy to use ... 
I found that they are a pessimisation more often than not.  In addition, it 
seems that at least our base gcc version does forget to apply any other 
optimizations if it encounters one of these.

My point is: Handle with care!!!  Trust your compiler/CPU predictors/... - 
most of the time, they are smarter than you are ;)

Regards,
  Max



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003121513.38721.max>