[mips-gnu-discuss] IEEE math support

Joseph S. Myers joseph at codesourcery.com
Fri Sep 30 19:27:07 UTC 2011


On Fri, 30 Sep 2011, Martin Herrman wrote:

> I think that I cannot be more specific than the test done in the
> configure script:
> 
> int main(void){

(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.

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.

-- 
Joseph S. Myers
joseph at codesourcery.com


More information about the mips-gnu-discuss mailing list