Commit 510519fe authored by David Reid's avatar David Reid

Fix denormal control with VC6.

parent d0285d6b
...@@ -9663,32 +9663,68 @@ static MA_INLINE unsigned int ma_disable_denormals() ...@@ -9663,32 +9663,68 @@ static MA_INLINE unsigned int ma_disable_denormals()
{ {
unsigned int prevState; unsigned int prevState;
#if defined(MA_X86) || defined(MA_X64) #if defined(_MSC_VER)
prevState = _mm_getcsr(); {
_mm_setcsr(prevState | _MM_DENORMALS_ZERO_MASK | _MM_FLUSH_ZERO_MASK); /*
#elif defined(_MSC_VER) Older versions of Visual Studio don't support the "safe" versions of _controlfp_s(). I don't
unsigned int unused; know which version of Visual Studio first added support for _controlfp_s(), but I do know
_controlfp_s(&prevState, 0, 0); that VC6 lacks support. _MSC_VER = 1200 is VC6, but if you get compilation errors on older
_controlfp_s(&unused, prevState | _DN_FLUSH, _MCW_DN); versions of Visual Studio, let me know and I'll make the necessary adjustment.
#else */
/* Unknown or unsupported architecture. No-op. */ #if _MSC_VER <= 1200
prevState = 0; {
#endif prevState = _statusfp();
_controlfp(prevState | _DN_FLUSH, _MCW_DN);
}
#else
{
unsigned int unused;
_controlfp_s(&prevState, 0, 0);
_controlfp_s(&unused, prevState | _DN_FLUSH, _MCW_DN);
}
#endif
}
#elif defined(MA_X86) || defined(MA_X64)
{
prevState = _mm_getcsr();
_mm_setcsr(prevState | _MM_DENORMALS_ZERO_MASK | _MM_FLUSH_ZERO_MASK);
}
#else
{
/* Unknown or unsupported architecture. No-op. */
prevState = 0;
}
#endif
return prevState; return prevState;
} }
static MA_INLINE void ma_restore_denormals(unsigned int prevState) static MA_INLINE void ma_restore_denormals(unsigned int prevState)
{ {
#if defined(MA_X86) || defined(MA_X64) #if defined(_MSC_VER)
_mm_setcsr(prevState); {
#elif defined(_MSC_VER) /* Older versions of Visual Studio do not support _controlfp_s(). See ma_disable_denormals(). */
unsigned int unused; #if _MSC_VER <= 1200
_controlfp_s(&unused, prevState, _MCW_DN); {
#else _controlfp(prevState, _MCW_DN);
/* Unknown or unsupported architecture. No-op. */ }
(void)prevState; #else
#endif {
unsigned int unused;
_controlfp_s(&unused, prevState, _MCW_DN);
}
#endif
}
#elif defined(MA_X86) || defined(MA_X64)
{
_mm_setcsr(prevState);
}
#else
{
/* Unknown or unsupported architecture. No-op. */
(void)prevState;
}
#endif
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment