Separate ALCdevice from the implementation
[openal-soft.git] / core / fpu_ctrl.h
blobd4f75ec3146c1934414ecf741416e5cd93d46d1f
1 #ifndef CORE_FPU_CTRL_H
2 #define CORE_FPU_CTRL_H
4 class FPUCtl {
5 unsigned int sse_state{};
6 bool in_mode{};
8 static unsigned int Set() noexcept;
9 static void Reset(unsigned int state) noexcept;
11 public:
12 FPUCtl() noexcept : sse_state{Set()}, in_mode{true} { }
13 ~FPUCtl() { if(in_mode) Reset(sse_state); }
15 FPUCtl(const FPUCtl&) = delete;
16 FPUCtl& operator=(const FPUCtl&) = delete;
18 void enter() noexcept
20 if(!in_mode)
21 sse_state = Set();
22 in_mode = true;
24 void leave() noexcept
26 if(in_mode)
27 Reset(sse_state);
28 in_mode = false;
32 #endif /* CORE_FPU_CTRL_H */