svn commit: trunk/uClibc/test/math

Rob Landley rob at landley.net
Mon Feb 23 06:48:12 UTC 2009


On Wednesday 18 February 2009 08:27:09 Bernhard Reutner-Fischer wrote:
> On Wed, Feb 18, 2009 at 02:04:18PM +0000, vda at uclibc.org wrote:
> >Author: vda
> >Date: 2009-02-18 14:04:17 +0000 (Wed, 18 Feb 2009)
> >New Revision: 25359
> >
> >--- trunk/uClibc/test/math/compile_test.c	2009-02-18 14:04:02 UTC (rev
> > 25358) +++ trunk/uClibc/test/math/compile_test.c	2009-02-18 14:04:17 UTC
> > (rev 25359) @@ -134,5 +134,6 @@
> >
> > int main(int argc, char **argv)
> > {
> >-	return (long) &testf + (long) &testl;
> >+        /* Always 0 but gcc hopefully won't be able to notice */
> >+        return 5 & ((long)&testf) & ((long)&testl) & 2;
>
> Perhaps you could mark them volatile instead or compile the testcase
> with -O0 to turn off DF and DCE et al?
> Do you compile that testcase with -fno-builtin to make sure we really
> end up calling into libm ?

Actually constant propogation and certain arithmetic simplifications are
mandated by the c99 spec.  (I had to know this to fix something in my tinycc 
fork back before the CVS archive killed that project.)

  http://busybox.net/~landley/c99-draft.html#6.6

So the 5 & and & 2 at the end are likely to get stripped off even with -O0 
because that's a translation time optimization thingy.  (It's necessary to do 
that because you can initialize global variables with constant expressions 
outside of any function scope, but not with something that results in actual 
code generation.)

Rob


More information about the uClibc mailing list