1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added a ScopedNoDenormal class to temporarily disable denormals

This commit is contained in:
hogliux 2017-09-12 10:46:36 +01:00
parent 71d10e750a
commit e2c8e30d72
10 changed files with 73 additions and 5 deletions

View file

@ -221,4 +221,34 @@ public:
static void JUCE_CALLTYPE disableDenormalisedNumberSupport() noexcept;
};
//==============================================================================
/**
Helper class providing an RAII-based mechanism for temporarily disabling
denormals on your CPU.
*/
class ScopedNoDenormals
{
public:
inline ScopedNoDenormals() noexcept
{
#if JUCE_USE_SSE_INTRINSICS
mxcsr = _mm_getcsr();
_mm_setcsr (mxcsr | 0x8040); // add the DAZ and FZ bits
#endif
}
inline ~ScopedNoDenormals() noexcept
{
#if JUCE_USE_SSE_INTRINSICS
_mm_setcsr (mxcsr);
#endif
}
private:
#if JUCE_USE_SSE_INTRINSICS
unsigned int mxcsr;
#endif
};
} // namespace juce