likely and unlikely

Ivan Voras ivoras at freebsd.org
Fri Mar 12 12:35:06 UTC 2010


On 03/12/10 13:27, Ivan Voras wrote:
> On 03/12/10 13:26, Ed Schouten wrote:
>> Hi Ivan,
>>
>> * Ivan Voras<ivoras at 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?
>
> Yes, I think you're right.

Actually, it looks like it would be best to simply add them alongside 
__predict_true and __predict_False in sys/cdefs.h:

306 #if __GNUC_PREREQ__(2, 96)
307 #define __predict_true(exp)     __builtin_expect((exp), 1)
308 #define __predict_false(exp)    __builtin_expect((exp), 0)
309 #else
310 #define __predict_true(exp)     (exp)
311 #define __predict_false(exp)    (exp)
312 #endif

(There is nothing wrong with __predict_true and __predict_false - they 
are just less convenient to type.)



More information about the freebsd-arch mailing list