Make FPUCtl methods noexcept
This commit is contained in:
+6
-4
@@ -13,11 +13,13 @@
|
|||||||
#include "cpu_caps.h"
|
#include "cpu_caps.h"
|
||||||
|
|
||||||
|
|
||||||
FPUCtl::FPUCtl()
|
void FPUCtl::enter() noexcept
|
||||||
{
|
{
|
||||||
|
if(this->in_mode) return;
|
||||||
|
|
||||||
#if defined(HAVE_SSE_INTRINSICS)
|
#if defined(HAVE_SSE_INTRINSICS)
|
||||||
this->sse_state = _mm_getcsr();
|
this->sse_state = _mm_getcsr();
|
||||||
unsigned int sseState = this->sse_state;
|
unsigned int sseState{this->sse_state};
|
||||||
sseState |= 0x8000; /* set flush-to-zero */
|
sseState |= 0x8000; /* set flush-to-zero */
|
||||||
sseState |= 0x0040; /* set denormals-are-zero */
|
sseState |= 0x0040; /* set denormals-are-zero */
|
||||||
_mm_setcsr(sseState);
|
_mm_setcsr(sseState);
|
||||||
@@ -27,7 +29,7 @@ FPUCtl::FPUCtl()
|
|||||||
if((CPUCapFlags&CPU_CAP_SSE))
|
if((CPUCapFlags&CPU_CAP_SSE))
|
||||||
{
|
{
|
||||||
__asm__ __volatile__("stmxcsr %0" : "=m" (*&this->sse_state));
|
__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 */
|
sseState |= 0x8000; /* set flush-to-zero */
|
||||||
if((CPUCapFlags&CPU_CAP_SSE2))
|
if((CPUCapFlags&CPU_CAP_SSE2))
|
||||||
sseState |= 0x0040; /* set denormals-are-zero */
|
sseState |= 0x0040; /* set denormals-are-zero */
|
||||||
@@ -38,7 +40,7 @@ FPUCtl::FPUCtl()
|
|||||||
this->in_mode = true;
|
this->in_mode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FPUCtl::leave()
|
void FPUCtl::leave() noexcept
|
||||||
{
|
{
|
||||||
if(!this->in_mode) return;
|
if(!this->in_mode) return;
|
||||||
|
|
||||||
|
|||||||
+4
-8
@@ -8,18 +8,14 @@ class FPUCtl {
|
|||||||
bool in_mode{};
|
bool in_mode{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FPUCtl();
|
FPUCtl() noexcept { enter(); in_mode = true; };
|
||||||
/* HACK: 32-bit targets for GCC seem to have a problem here with certain
|
~FPUCtl() { if(in_mode) leave(); }
|
||||||
* 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(const FPUCtl&) = delete;
|
FPUCtl(const FPUCtl&) = delete;
|
||||||
FPUCtl& operator=(const FPUCtl&) = delete;
|
FPUCtl& operator=(const FPUCtl&) = delete;
|
||||||
|
|
||||||
void leave();
|
void enter() noexcept;
|
||||||
|
void leave() noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CORE_FPU_CTRL_H */
|
#endif /* CORE_FPU_CTRL_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user