[Mesa-dev] [PATCH] gl.h, gl2.h, gallium: use stdbool.h for GLboolean and boolean
Dave Airlie
airlied at gmail.com
Fri Oct 29 23:53:20 PDT 2010
On Sat, Oct 30, 2010 at 8:13 AM, Roland Mainz <roland.mainz at nrubsig.org> wrote:
> On Wed, Oct 13, 2010 at 9:05 PM, Brian Paul <brianp at vmware.com> wrote:
>> On 10/13/2010 12:26 PM, Nicolas Kaiser wrote:
>>>
>>> This patch adds support for the compiler built-in Boolean type
>>> to GLboolean and the "boolean" type in gallium
>>> by bringing them in line with the "bool" type in stdbool.h.
>>>
>>> Signed-off-by: Nicolas Kaiser<nikai at nikai.net>
>>
>> Every GL/gl.h file I've seen over the years defines GLboolean as-is.
>> It seems a bit risky (and unnecessary) to me to change it.
>
> Erm... using C99 |bool| from <stdbool.h> can lead to significant
> performance improvements and code size reduction if there are lots of
> bools/branches in your code because the compiler no longer has to
> guess whether the variable may be used as boolean or not, it simply
> can treat it as one even in low optimisation levels (and it helps in
> cases when code spans more than one object file because not all
> compilers do things like Sun's interprocedural optimiser (e.g. which
> optimises and inlines across all source files in one step)).
The main problem we redefining something like GLboolean is it maybe an
ABI change, the C99 bool AFAIK isn't == unsigned char,
and it may affect the function signatures to starting using it in these places.
Internally in mesa I'm less concerened.
Dave.
> This was the primary reason why Solaris got a <sys/stdbool.h> (e.g.
> that kernel code can use C99 |bool| ; see OpenSolaris PSARC/2009/429,
> http://mail.opensolaris.org/pipermail/opensolaris-arc/2009-August/017277.html
> &co. for the discussion) and why we are working on doing this on other
> larger pieces of code like AT&T AST codebase (which contains stuff
> like libast and ksh93).
>
> ----
>
> Bye,
> Roland
>
> --
> __ . . __
> (o.\ \/ /.o) roland.mainz at nrubsig.org
> \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
> /O /==\ O\ TEL +49 641 3992797
> (;O/ \/ \O;)
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
More information about the mesa-dev
mailing list