blob: d4f75ec3146c1934414ecf741416e5cd93d46d1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#ifndef CORE_FPU_CTRL_H
#define CORE_FPU_CTRL_H
class FPUCtl {
unsigned int sse_state{};
bool in_mode{};
static unsigned int Set() noexcept;
static void Reset(unsigned int state) noexcept;
public:
FPUCtl() noexcept : sse_state{Set()}, in_mode{true} { }
~FPUCtl() { if(in_mode) Reset(sse_state); }
FPUCtl(const FPUCtl&) = delete;
FPUCtl& operator=(const FPUCtl&) = delete;
void enter() noexcept
{
if(!in_mode)
sse_state = Set();
in_mode = true;
}
void leave() noexcept
{
if(in_mode)
Reset(sse_state);
in_mode = false;
}
};
#endif /* CORE_FPU_CTRL_H */
|