aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/fpu_modes.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-11 08:44:52 -0800
committerChris Robinson <[email protected]>2018-01-11 08:44:52 -0800
commit15ad5245bfa498dff729d2bb1cd91fad161cc806 (patch)
treeb5f0d36fe916d81e498c7c18278ed7b40f7cf00d /Alc/fpu_modes.h
parent8aa9e35f8c743c1336142a0a49eaeee19a6d33d3 (diff)
Move the FPU mode declarations to a separate header
Also don't use inheritance with FPUCtl.
Diffstat (limited to 'Alc/fpu_modes.h')
-rw-r--r--Alc/fpu_modes.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/Alc/fpu_modes.h b/Alc/fpu_modes.h
new file mode 100644
index 00000000..750252fc
--- /dev/null
+++ b/Alc/fpu_modes.h
@@ -0,0 +1,37 @@
+#ifndef FPU_MODES_H
+#define FPU_MODES_H
+
+#ifdef HAVE_FENV_H
+#include <fenv.h>
+#endif
+
+
+typedef struct FPUCtl {
+#ifdef HAVE_FENV_H
+ fenv_t flt_env;
+#ifdef _WIN32
+ int round_mode;
+#endif
+#else
+ int state;
+#endif
+#ifdef HAVE_SSE
+ int sse_state;
+#endif
+} FPUCtl;
+void SetMixerFPUMode(FPUCtl *ctl);
+void RestoreFPUMode(const FPUCtl *ctl);
+
+#ifdef __GNUC__
+/* Use an alternate macro set with GCC to avoid accidental continue or break
+ * statements within the mixer mode.
+ */
+#define START_MIXER_MODE() __extension__({ FPUCtl _oldMode; SetMixerFPUMode(&_oldMode)
+#define END_MIXER_MODE() RestoreFPUMode(&_oldMode); })
+#else
+#define START_MIXER_MODE() do { FPUCtl _oldMode; SetMixerFPUMode(&_oldMode)
+#define END_MIXER_MODE() RestoreFPUMode(&_oldMode); } while(0)
+#endif
+#define LEAVE_MIXER_MODE() RestoreFPUMode(&_oldMode)
+
+#endif /* FPU_MODES_H */