aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/fpu_modes.h
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/fpu_modes.h')
-rw-r--r--Alc/fpu_modes.h44
1 files changed, 14 insertions, 30 deletions
diff --git a/Alc/fpu_modes.h b/Alc/fpu_modes.h
index e8858ad9..1afd6618 100644
--- a/Alc/fpu_modes.h
+++ b/Alc/fpu_modes.h
@@ -1,41 +1,25 @@
#ifndef FPU_MODES_H
#define FPU_MODES_H
-#ifdef HAVE_FENV_H
-#include <fenv.h>
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct FPUCtl {
+class FPUCtl {
#if defined(__GNUC__) && defined(HAVE_SSE)
- unsigned int sse_state;
+ unsigned int sse_state{};
#elif defined(HAVE___CONTROL87_2)
- unsigned int state;
- unsigned int sse_state;
+ unsigned int state{};
+ unsigned int sse_state{};
#elif defined(HAVE__CONTROLFP)
- unsigned int state;
+ unsigned int state{};
#endif
-} FPUCtl;
-void SetMixerFPUMode(FPUCtl *ctl);
-void RestoreFPUMode(const FPUCtl *ctl);
+ bool in_mode{};
-#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)
+public:
+ FPUCtl() noexcept;
+ ~FPUCtl() { leave(); }
-#ifdef __cplusplus
-} // extern "C"
-#endif
+ FPUCtl(const FPUCtl&) = delete;
+ FPUCtl& operator=(const FPUCtl&) = delete;
+
+ void leave() noexcept;
+};
#endif /* FPU_MODES_H */