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:
parent
71d10e750a
commit
e2c8e30d72
10 changed files with 73 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue