mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 01:04:02 +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 <strings.h> /* For strcasecmp(). */
|
||||||
#include <wchar.h> /* For wcslen(), wcsrtombs() */
|
#include <wchar.h> /* For wcslen(), wcsrtombs() */
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <float.h> /* For _controlfp_s constants */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MA_WIN32
|
#ifdef MA_WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -9544,6 +9547,10 @@ static MA_INLINE unsigned int ma_disable_denormals()
|
|||||||
#if defined(MA_X86) || defined(MA_X64)
|
#if defined(MA_X86) || defined(MA_X64)
|
||||||
prevState = _mm_getcsr();
|
prevState = _mm_getcsr();
|
||||||
_mm_setcsr(prevState | _MM_DENORMALS_ZERO_MASK | _MM_FLUSH_ZERO_MASK);
|
_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
|
#else
|
||||||
/* Unknown or unsupported architecture. No-op. */
|
/* Unknown or unsupported architecture. No-op. */
|
||||||
prevState = 0;
|
prevState = 0;
|
||||||
@@ -9556,6 +9563,9 @@ static MA_INLINE void ma_restore_denormals(unsigned int prevState)
|
|||||||
{
|
{
|
||||||
#if defined(MA_X86) || defined(MA_X64)
|
#if defined(MA_X86) || defined(MA_X64)
|
||||||
_mm_setcsr(prevState);
|
_mm_setcsr(prevState);
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
unsigned int unused;
|
||||||
|
_controlfp_s(&unused, prevState, _MCW_DN);
|
||||||
#else
|
#else
|
||||||
/* Unknown or unsupported architecture. No-op. */
|
/* Unknown or unsupported architecture. No-op. */
|
||||||
(void)prevState;
|
(void)prevState;
|
||||||
|
|||||||
Reference in New Issue
Block a user