mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
denormals: enable denormal flushing on non-x86 Windows architectures as well
We can use _controlfp_s instead of _mm_getcsr/_mm_setcsr for architecture-agnostic control of denormal behavior on Windows. Signed-off-by: Steven Noonan <steven@uplinklabs.net>
This commit is contained in:
committed by
David Reid
parent
d67eefdfe4
commit
9bafb7fc2c
+10
@@ -9049,6 +9049,9 @@ IMPLEMENTATION
|
||||
#include <strings.h> /* For strcasecmp(). */
|
||||
#include <wchar.h> /* For wcslen(), wcsrtombs() */
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#include <float.h> /* For _controlfp_s constants */
|
||||
#endif
|
||||
|
||||
#ifdef MA_WIN32
|
||||
#include <windows.h>
|
||||
@@ -9544,6 +9547,10 @@ static MA_INLINE unsigned int ma_disable_denormals()
|
||||
#if defined(MA_X86) || defined(MA_X64)
|
||||
prevState = _mm_getcsr();
|
||||
_mm_setcsr(prevState | _MM_DENORMALS_ZERO_MASK | _MM_FLUSH_ZERO_MASK);
|
||||
#elif defined(_MSC_VER)
|
||||
unsigned int unused;
|
||||
_controlfp_s(&prevState, 0, 0);
|
||||
_controlfp_s(&unused, prevState | _DN_FLUSH, _MCW_DN);
|
||||
#else
|
||||
/* Unknown or unsupported architecture. No-op. */
|
||||
prevState = 0;
|
||||
@@ -9556,6 +9563,9 @@ static MA_INLINE void ma_restore_denormals(unsigned int prevState)
|
||||
{
|
||||
#if defined(MA_X86) || defined(MA_X64)
|
||||
_mm_setcsr(prevState);
|
||||
#elif defined(_MSC_VER)
|
||||
unsigned int unused;
|
||||
_controlfp_s(&unused, prevState, _MCW_DN);
|
||||
#else
|
||||
/* Unknown or unsupported architecture. No-op. */
|
||||
(void)prevState;
|
||||
|
||||
Reference in New Issue
Block a user