[mips-gnu-discuss] IEEE math support

Martin Herrman martin at herrman.nl
Sat Oct 1 18:06:00 UTC 2011


2011/9/30 Joseph S. Myers <joseph at codesourcery.com>:

Hi Joseph,

> (This code has undefined behavior unless you include <math.h> and
> <stdio.h> first for declarations of the various functions used.)
>
>>     double rrdnan,rrdinf,rrdc,rrdzero;
>>     ;
>>     /* some math to see if we get a floating point exception */
>>     rrdzero=sin(0.0); /* don't let the compiler optimize us away */
>>     rrdnan=0.0/rrdzero; /* especially here */
>>     rrdinf=1.0/rrdzero; /* and here. I want to know if it can do the magic */
>>                   /* at run time without sig fpe */
>>     rrdc = rrdinf + rrdnan;
>>     rrdc = rrdinf / rrdnan;
>>     if (! isnan(rrdnan)) {printf ("not isnan(NaN) ... "); return 1;}
>>     if (rrdnan == rrdnan) {printf ("nan == nan ... "); return 1;}
>>     if (! isinf(rrdinf)) {printf ("not isinf(oo) ... "); return 1;}
>>     if (! isinf(-rrdinf)) {printf ("not isinf(-oo) ... "); return 1;}
>>     if (! rrdinf > 0) {printf ("not inf > 0 ... "); return 1;}
>>     if (! -rrdinf < 0) {printf ("not -inf < 0 ... "); return 1;}
>>     return 0;
>>  }
>
> At least with those declarations added, this test works fine with our
> tools, both big and little endian, hard and soft float.

thanks for the confirmation.

> These tools are of course cross compilers, and configure can't generally
> run tests on the target when cross compiling, so you'll need to look in
> more detail at what the configure script does when cross compiling.

damn.. I should have noticed that, done it before with other apps.
Thanks for pointing me out!

Martin


More information about the mips-gnu-discuss mailing list