[Mesa-dev] [PATCH] gl.h, gl2.h, gallium: use stdbool.h for GLboolean and boolean
roland.mainz at nrubsig.org
Fri Oct 29 15:13:44 PDT 2010
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)).
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,
&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).
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
More information about the mesa-dev