Aww great work !
I looked at bit at your changes, most of them should be harmless, in fact for some of them it's my fault (like the "struct export export" which is ok in my compiler but bad practice).
Are templates better than defines for things like min/max/clamp ?
The only potentially problematic thing is :
/* avoid slow float denormals + round floats down (needed if program compiled with QIfist option (FISTP) fast int/float conversion) */
+ #ifdef _WIN32
_control87(_RC_DOWN, _MCW_RC);
+ #endif
FM Composer is expected to be compiled with the QIfist flag (probably VC++ specific) that allow to speed up float to int conversions by using faster FISTP assembly calls than the slow ftol() from the C library. This method also rounds floats instead of trucating them down as a collateral effect, thus this _control87 force floats to be rounded down again. There are two possible choices :
- Use default C int/float conversions and remove _control87 like you did, which works but worse performance (would be nice to see how much worse it is, maybe it's acceptable)
- Find some way to do it on Linux. I don't know if some compiler flag exists like MSVC's QiFist, but basically it does something like this for conversion :
int convert(float x)
{
int n;
__asm {
fld x
fistp n
}
return n;
}
Then we'd need to find a way to tell the fpu to round down the floats, like _control87 did.
I'd be happy to try your code and integrate it into the main branch once we've tested it !