On Thursday 21 September 2006 17:57, Brian Paul wrote:
> Interestingly, these two variations produce different code (gcc -O2):
>
> static INLINE GLboolean
> _mesa_little_endian(void)
> {
> static const GLuint ui = 1; // NOTE: static
> return *((const GLubyte *) &ui);
> }
>
> static INLINE GLboolean
> _mesa_little_endian(void)
> {
> const GLuint ui = 1;
> return *((const GLubyte *) &ui);
> }
>
>
> If you have code such as:
>
> if (_mesa_little_endian())
> foo();
> else
> bar();
>
>
> The version without 'static' is evaluated at compile time and the
> branch code is optimized away. With 'static' the compiler still
> generates the conditional code.Interesting. Perhaps the compiler treats the static variable as a global variable. The compiler then assumes the worst, which is that the global variable could be accessed and modified by some outside code. Tricky... cu, Nicolai
pgpLsd5fSYorB.pgp
Description: PGP signature
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Mesa3d-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mesa3d-dev
