diff options
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alc.cpp | 2 | ||||
-rw-r--r-- | alc/alu.cpp | 2 | ||||
-rw-r--r-- | alc/converter.cpp | 2 | ||||
-rw-r--r-- | alc/fpu_ctrl.cpp | 54 | ||||
-rw-r--r-- | alc/fpu_ctrl.h (renamed from alc/fpu_modes.h) | 6 | ||||
-rw-r--r-- | alc/helpers.cpp | 45 |
6 files changed, 60 insertions, 51 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 0962276d..9ce1fa65 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -79,7 +79,7 @@ #include "effects/base.h" #include "filters/nfc.h" #include "filters/splitter.h" -#include "fpu_modes.h" +#include "fpu_ctrl.h" #include "hrtf.h" #include "inprogext.h" #include "intrusive_ptr.h" diff --git a/alc/alu.cpp b/alc/alu.cpp index ae65fbcb..d3a0a858 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -65,7 +65,7 @@ #include "filters/biquad.h" #include "filters/nfc.h" #include "filters/splitter.h" -#include "fpu_modes.h" +#include "fpu_ctrl.h" #include "hrtf.h" #include "inprogext.h" #include "mastering.h" diff --git a/alc/converter.cpp b/alc/converter.cpp index 553bad58..38b8bedb 100644 --- a/alc/converter.cpp +++ b/alc/converter.cpp @@ -11,7 +11,7 @@ #include "albyte.h" #include "alu.h" -#include "fpu_modes.h" +#include "fpu_ctrl.h" #include "mixer/defs.h" diff --git a/alc/fpu_ctrl.cpp b/alc/fpu_ctrl.cpp new file mode 100644 index 00000000..24021c7d --- /dev/null +++ b/alc/fpu_ctrl.cpp @@ -0,0 +1,54 @@ + +#include "config.h" + +#include "fpu_ctrl.h" + +#ifdef HAVE_INTRIN_H +#include <intrin.h> +#endif +#ifdef HAVE_SSE_INTRINSICS +#include <xmmintrin.h> +#endif + +#include "cpu_caps.h" + + +FPUCtl::FPUCtl() +{ +#if defined(HAVE_SSE_INTRINSICS) + this->sse_state = _mm_getcsr(); + unsigned int sseState = this->sse_state; + sseState |= 0x8000; /* set flush-to-zero */ + sseState |= 0x0040; /* set denormals-are-zero */ + _mm_setcsr(sseState); + +#elif defined(__GNUC__) && defined(HAVE_SSE) + + if((CPUCapFlags&CPU_CAP_SSE)) + { + __asm__ __volatile__("stmxcsr %0" : "=m" (*&this->sse_state)); + unsigned int sseState = this->sse_state; + sseState |= 0x8000; /* set flush-to-zero */ + if((CPUCapFlags&CPU_CAP_SSE2)) + sseState |= 0x0040; /* set denormals-are-zero */ + __asm__ __volatile__("ldmxcsr %0" : : "m" (*&sseState)); + } +#endif + + this->in_mode = true; +} + +void FPUCtl::leave() +{ + if(!this->in_mode) return; + +#if defined(HAVE_SSE_INTRINSICS) + _mm_setcsr(this->sse_state); + +#elif defined(__GNUC__) && defined(HAVE_SSE) + + if((CPUCapFlags&CPU_CAP_SSE)) + __asm__ __volatile__("ldmxcsr %0" : : "m" (*&this->sse_state)); +#endif + this->in_mode = false; +} diff --git a/alc/fpu_modes.h b/alc/fpu_ctrl.h index 5465e9cf..e89bdc29 100644 --- a/alc/fpu_modes.h +++ b/alc/fpu_ctrl.h @@ -1,5 +1,5 @@ -#ifndef FPU_MODES_H -#define FPU_MODES_H +#ifndef FPU_CTRL_H +#define FPU_CTRL_H class FPUCtl { #if defined(HAVE_SSE_INTRINSICS) || (defined(__GNUC__) && defined(HAVE_SSE)) @@ -22,4 +22,4 @@ public: void leave(); }; -#endif /* FPU_MODES_H */ +#endif /* FPU_CTRL_H */ diff --git a/alc/helpers.cpp b/alc/helpers.cpp index 4ea94c7d..5006bc51 100644 --- a/alc/helpers.cpp +++ b/alc/helpers.cpp @@ -46,9 +46,6 @@ #ifdef HAVE_CPUID_H #include <cpuid.h> #endif -#ifdef HAVE_SSE_INTRINSICS -#include <xmmintrin.h> -#endif #ifdef HAVE_SYS_SYSCONF_H #include <sys/sysconf.h> #endif @@ -75,7 +72,6 @@ #include "alstring.h" #include "compat.h" #include "cpu_caps.h" -#include "fpu_modes.h" #include "logging.h" #include "strutils.h" #include "vector.h" @@ -207,47 +203,6 @@ void FillCPUCaps(int capfilter) } -FPUCtl::FPUCtl() -{ -#if defined(HAVE_SSE_INTRINSICS) - this->sse_state = _mm_getcsr(); - unsigned int sseState = this->sse_state; - sseState |= 0x8000; /* set flush-to-zero */ - sseState |= 0x0040; /* set denormals-are-zero */ - _mm_setcsr(sseState); - -#elif defined(__GNUC__) && defined(HAVE_SSE) - - if((CPUCapFlags&CPU_CAP_SSE)) - { - __asm__ __volatile__("stmxcsr %0" : "=m" (*&this->sse_state)); - unsigned int sseState = this->sse_state; - sseState |= 0x8000; /* set flush-to-zero */ - if((CPUCapFlags&CPU_CAP_SSE2)) - sseState |= 0x0040; /* set denormals-are-zero */ - __asm__ __volatile__("ldmxcsr %0" : : "m" (*&sseState)); - } -#endif - - this->in_mode = true; -} - -void FPUCtl::leave() -{ - if(!this->in_mode) return; - -#if defined(HAVE_SSE_INTRINSICS) - _mm_setcsr(this->sse_state); - -#elif defined(__GNUC__) && defined(HAVE_SSE) - - if((CPUCapFlags&CPU_CAP_SSE)) - __asm__ __volatile__("ldmxcsr %0" : : "m" (*&this->sse_state)); -#endif - this->in_mode = false; -} - - #ifdef _WIN32 const PathNamePair &GetProcBinary() |