2021-04-28 12:43:51 +08:00
|
|
|
#ifndef CORE_FPU_CTRL_H
|
|
|
|
#define CORE_FPU_CTRL_H
|
|
|
|
|
|
|
|
class FPUCtl {
|
|
|
|
#if defined(HAVE_SSE_INTRINSICS) || (defined(__GNUC__) && defined(HAVE_SSE))
|
|
|
|
unsigned int sse_state{};
|
|
|
|
#endif
|
|
|
|
bool in_mode{};
|
|
|
|
|
|
|
|
public:
|
2022-04-25 12:02:45 +08:00
|
|
|
FPUCtl() noexcept { enter(); in_mode = true; }
|
2021-04-28 12:43:51 +08:00
|
|
|
~FPUCtl() { if(in_mode) leave(); }
|
|
|
|
|
|
|
|
FPUCtl(const FPUCtl&) = delete;
|
|
|
|
FPUCtl& operator=(const FPUCtl&) = delete;
|
|
|
|
|
|
|
|
void enter() noexcept;
|
|
|
|
void leave() noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* CORE_FPU_CTRL_H */
|