diff options
author | Chris Robinson <[email protected]> | 2020-12-31 18:20:05 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-12-31 18:23:59 -0800 |
commit | 87a862199d6e64e8be9909657288ffa66b1c40fb (patch) | |
tree | e9c567fb024024463588a4c9082192cace899498 | |
parent | 20ef8bf390541339f068676f9d14061fe2f5e115 (diff) |
Make FPUCtl methods noexcept
-rw-r--r-- | core/fpu_ctrl.cpp | 10 | ||||
-rw-r--r-- | core/fpu_ctrl.h | 12 |
2 files changed, 10 insertions, 12 deletions
diff --git a/core/fpu_ctrl.cpp b/core/fpu_ctrl.cpp index 24021c7d..b12f2c96 100644 --- a/core/fpu_ctrl.cpp +++ b/core/fpu_ctrl.cpp @@ -13,11 +13,13 @@ #include "cpu_caps.h" -FPUCtl::FPUCtl() +void FPUCtl::enter() noexcept { + if(this->in_mode) return; + #if defined(HAVE_SSE_INTRINSICS) this->sse_state = _mm_getcsr(); - unsigned int sseState = this->sse_state; + unsigned int sseState{this->sse_state}; sseState |= 0x8000; /* set flush-to-zero */ sseState |= 0x0040; /* set denormals-are-zero */ _mm_setcsr(sseState); @@ -27,7 +29,7 @@ FPUCtl::FPUCtl() if((CPUCapFlags&CPU_CAP_SSE)) { __asm__ __volatile__("stmxcsr %0" : "=m" (*&this->sse_state)); - unsigned int sseState = this->sse_state; + unsigned int sseState{this->sse_state}; sseState |= 0x8000; /* set flush-to-zero */ if((CPUCapFlags&CPU_CAP_SSE2)) sseState |= 0x0040; /* set denormals-are-zero */ @@ -38,7 +40,7 @@ FPUCtl::FPUCtl() this->in_mode = true; } -void FPUCtl::leave() +void FPUCtl::leave() noexcept { if(!this->in_mode) return; diff --git a/core/fpu_ctrl.h b/core/fpu_ctrl.h index 20bd2772..e6dc1fb2 100644 --- a/core/fpu_ctrl.h +++ b/core/fpu_ctrl.h @@ -8,18 +8,14 @@ class FPUCtl { bool in_mode{}; public: - FPUCtl(); - /* HACK: 32-bit targets for GCC seem to have a problem here with certain - * noexcept methods (which destructors are) causing an internal compiler - * error. No idea why it's these methods specifically, but this is needed - * to get it to compile. - */ - ~FPUCtl() noexcept(false) { leave(); } + FPUCtl() noexcept { enter(); in_mode = true; }; + ~FPUCtl() { if(in_mode) leave(); } FPUCtl(const FPUCtl&) = delete; FPUCtl& operator=(const FPUCtl&) = delete; - void leave(); + void enter() noexcept; + void leave() noexcept; }; #endif /* CORE_FPU_CTRL_H */ |