Hi,

In my testing with mingw-w64 on ARM, I've run into a number of issues with 
the implementation of the math routines. Some of these issues are:

The whole family of log functions is problematic (even after my fix for 
the number of iterations in 41de4baaccba), e.g. log2() only returns values 
in the range -17.6 - 7.73, for values outside.

For some values, it even crashes. IIRC, the issue iss an infinite 
recursion; bsd__ieee754_powf calls scalbnf, which calls bsd__ieee754_powf. 
E.g. log2f(strtod("1.225000", NULL)) will show this behaviour (using 
strtod to avoid any risk of the compiler evaluating it at compile time).

Likewise sin/cos and pow also have implementation accuracy issues - I 
haven't dug quite as deep into these, but just removing them (and linking 
to the msvcrt.dll versions instead) make the remaining libav testsuite 
failures go away. (Tested on wine though, whose msvcrt implementation 
might be better in some aspects than the real msvcrt.dll.)

Functions like floor and ceil are implemented using vcvtr.s32.f64, which 
effectively limits the range of these functions to what is expressible 
with signed 32 bits. This isn't that I've run into in actual real world 
code though, but it was noted at some point that it could be an issue.


I understand that mingw-w64 wants to reimplement math functions instead of 
linking to msvcrt in order to get proper C99 compliance. For the mentioned 
families of functions (log, pow, sin, cos), what C99 compliance issues are 
there with the msvcrt.dll implementations?

For functions that don't exist in the plain msvcrt.dll, like log2 and 
exp2, we can easily call the normal log/exp and multiply with a constant.

For functions that do exist in the normal msvcrt.dll, if those individual 
functions don't need any extra C99 conformance, we can just leave them out 
from libmingwex.a and link to msvcrt.dll instead. If some extra C99 
functionality is needed (perhaps handling of edge cases?), it's a bit 
trickier - can one do something like this?

double log(double x) {
     if (isnan(x))
        return x;
     return __imp_log(x);
}

Locally when testing this, I've left out all of 
mingw-w64-crt/math/softfloat/*, and changed the log2/exp2 functions to 
just call log/exp, and gotten it working. But what would be required in 
order to get this fixed up upstream?

// Martin

------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to