diff options
Diffstat (limited to 'compat/fpu.hpp')
-rw-r--r-- | compat/fpu.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/compat/fpu.hpp b/compat/fpu.hpp new file mode 100644 index 00000000..1b3776f9 --- /dev/null +++ b/compat/fpu.hpp @@ -0,0 +1,40 @@ +#pragma once +#include "arch.hpp" + +#ifdef __MINGW32__ +extern "C" __declspec(dllimport) unsigned __cdecl _controlfp(unsigned, unsigned); +#endif + +static inline void set_fp_mask() +{ +#if defined FLOORMAT_ARCH_DENORM_DAZ + _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); +#elif defined FLOORMAT_ARCH_DENORM_FTZ + _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); +#endif + +#ifdef FLOORMAT_ARCH_FPU_MASK + _MM_SET_EXCEPTION_MASK(_MM_MASK_MASK); +#endif + +#ifdef __APPLE__ + fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV); +#endif + +#ifdef _WIN32 +# ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wreserved-id-macro" +# endif +# ifndef _DN_FLUSH +# define _DN_FLUSH 0x01000000 +# endif +# ifndef _MCW_DN +# define _MCW_DN 0x03000000 +# endif +# ifdef __clang__ +# pragma clang diagnostic pop +# endif + _controlfp(_DN_FLUSH, _MCW_DN); +#endif +} |