[Mesa-dev] [PATCH 1/2] mesa: Detect and provide macros for function attributes pure and const.

Jose Fonseca jfonseca at vmware.com
Sat Jul 18 00:13:10 PDT 2015

On 18/07/15 01:38, Eric Anholt wrote:
> Emil Velikov <emil.l.velikov at gmail.com> writes:
>> On 14/07/15 19:45, Eric Anholt wrote:
>>> These are really useful hints to the compiler in the absence of link-time
>>> optimization, and I'm going to use them in VC4.
>>> I've made the const attribute be ATTRIBUTE_CONST unlike other function
>>> attributes, because we have other things in the tree #defining CONST for
>>> their own unrelated purposes.
>> Mindly related: how people feel about making these macros less screamy,
>> by following the approach used in the kernel: PURE -> __pure and so on ?
> I'd love it.

Less screamy is fine, but beware prefixing double underscore: the C 
standard stipulates that its use is reserved for for C/C++ runtime. [1]

Look at stdlibc++ implementation: every internal variable has a double 
underscore prefix.

Maybe kernel gets away on GLIBC (and because it doesn't use C++), but 
there's no guarantee it will work on other C runtimes, and even if it 
does, it could start failing anytime.


[1] http://stackoverflow.com/a/224420

More information about the mesa-dev mailing list