[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using __builtin_expect (likely/unlikely macros)

From: Andy Moreton
Subject: Re: Using __builtin_expect (likely/unlikely macros)
Date: Thu, 18 Apr 2019 18:56:22 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (windows-nt)

On Thu 18 Apr 2019, Paul Eggert wrote:

> On 4/18/19 6:47 AM, Andy Moreton wrote:
>> Please don't use this macro, as it makes the code much less readable.
>> It is reasonable to have a macro that combines the '_Noreturn' and
>> 'ATTRIBUTE_COLD' decorations, but that should not be combined with the
>> return type.
> Actually I first tried it the way that you suggested, but found that
> having a single macro improved readability for me, partly because
> _Noreturn functions don't return anything so their return type doesn't
> matter except for static type checking. 'AVOID' lets a traditionalist
> reader easily see that the type 'void' is intended, while also connoting
> that the function is rarely used because calls to it are normally
> avoided. (I tried to shoehorn "cold" and "does not return" into the
> macro's name too, but couldn't come up with anything better than

I had an entirely different impression: AVOID is a weird name for a
return type, so where is the return type, and does this even compile ?

In addition, using this macro makes it entirely non-obvious that the
function has a "_NoReturn" specifier, making it harder for the reader to
understand the intended semantics.

I have no objection to adding "noreturn" and "noreturn_cold" macros if
that helps, but the "AVOID" macro should be avoided as harmful to


reply via email to

[Prev in Thread] Current Thread [Next in Thread]