[cairo] Re: Re: Re: cairo c++ bindings

Mike Emmel mike.emmel at gmail.com
Mon Nov 28 05:29:08 PST 2005


On 11/28/05, Murray Cumming <murrayc at murrayc.com> wrote:
> > Can't you just use the gcc extension unlikely  for the branch ?
> > Then it won't stall I think of couse I don't know the vodoo of those
> > attributes.
> > Some of the gcc extension attributes like this may even be useful in
> > other parts of the
> > cairo code that branch since almost all calls end up testing the
> > existance or result of a backend function.
>
> I've no idea what that is, but I suggest that you show us with a patch.
>

Here is one url explaining the attributes the example is near the bottom.
I include it since its got most of the header junk needed to do a
clean compile on
old or non gcc systems.

http://rlove.org/log/2005102601

The gcc reference page

http://www.imodulo.com/GNU/gcc/Other-Builtins.html

Note there are a bunch of other performance directives there my point is
it may prove useful esp with profile information to sprinkle a few of
these in the right places.

Here is the content for builtin_expect

- Built-in Function: long __builtin_expect (long exp, long c)

    You may use __builtin_expect to provide the compiler with branch
prediction information. In general, you should prefer to use actual
profile feedback for this (-fprofile-arcs), as programmers are
notoriously bad at predicting how their programs actually perform.
However, there are applications in which this data is hard to collect.

    The return value is the value of exp, which should be an integral
expression. The value of c must be a compile-time constant. The
semantics of the built-in are that it is expected that exp == c. For
example:

if (__builtin_expect (x, 0))
  foo ();

    would indicate that we do not expect to call foo, since we expect
x to be zero. Since you are limited to integral expressions for exp,
you should use constructions such as

if (__builtin_expect (ptr != NULL, 1))
  error ();

    when testing pointer or floating-point values.


> Murray Cumming
> murrayc at murrayc.com
> www.murrayc.com
> www.openismus.com
>
>


More information about the cairo mailing list