[PATCH] Wrap the DEBUG checks in a "unlikely"

Stefan (metze) Metzmacher metze at samba.org
Fri Dec 28 08:27:47 GMT 2007


Volker Lendecke schrieb:
> On Fri, Dec 28, 2007 at 07:51:08AM +0100, Stefan (metze) Metzmacher wrote:
>>>  #define DEBUGADDC( dbgc_class, level, body ) \
>>>    (void)( ((level) <= MAX_DEBUG_LEVEL) && \
>>> -          ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
>>> +          unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
>>>             (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
>>>              DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
>>>         && (dbgtext body) )
>> wouldn't it make sense to put the whole logic into the unlikely?
>>
>>     (void)(unlikely( ((level) <= MAX_DEBUG_LEVEL) && \
>>             ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
>>              (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
>>               DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level)) )) \
>>            && (dbgtest body) )
> 
> No, I don't think so. ((level) <= MAX_DEBUG_LEVEL) only sees
> constants. A compiler not able to optimize away a if (1<100)
> is probably too stupid to know about unlikely.

Ah, sorry I thought only this one line that was changed whould get the
unlikely too many parentheses...

metze
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : http://lists.samba.org/archive/samba-technical/attachments/20071228/54b91a56/signature.bin


More information about the samba-technical mailing list