The online docs at
http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Other-Builtins.html
has a confusing (to me) example of __builtin_expect. Could someone
take a look at this?
<start quote from above-referenced page>
Since you are limited to integral expressions for exp, you should
use constructions such as
if (__builtin_expect (ptr != NULL, 1))
error ();
<end quote>
This seems backwards. The return value of __builtin_expect
is the first argument, namely (ptr != NULL), which presumably is
true in the NON-error case. The following example might be more
helpful:
if (__builtin_expect (ptr == NULL, 0))
error ();
Apologies if I'm not reading this correctly.
The point of the example is that you cannot write
if (__builtin_expect (ptr, 1))
error ();
so the "!= NULL" is important here. But you are right that
"error ()" is a bit unexpected; care to send a patch that changes
it to e.g. "do_something ()"?
Segher