diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-01-09 15:06:21 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-01-10 03:18:57 +0100 |
commit | 9911a09fc51bedc00cdad2ce8651fc0802c10b1e (patch) | |
tree | 2a01a9b0c422a03770c5b5d5227efedb834122f4 | |
parent | bd3370d4ef79ed5e0713a6446889cca6f5a4d5e2 (diff) |
gui/main: disable denormals on win32
-rw-r--r-- | gui/main.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/gui/main.cpp b/gui/main.cpp index 5d43cc14..d07e0d27 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -7,8 +7,6 @@ # include <QString> # include <QSysInfo> # include <QtGlobal> -#else -# include <unistd.h> #endif #include "migration/migration.hpp" @@ -26,6 +24,32 @@ using namespace options; #include <memory> #include <cstring> +#if /* denormal control */ \ + /* GNU */ defined __x86_64__ || defined __SSE2__ || \ + /* MSVC */ defined _M_AMD64 || (defined _M_IX86_FP && _M_IX86_FP >= 2) +# include <xmmintrin.h> +# include <pmmintrin.h> +# include <float.h> + +#define OTR_HAS_DENORM_CONTROL +void set_fp_mask() +{ + unsigned old_mask = _mm_getcsr(); + (void) old_mask; + + _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); + _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); + _MM_SET_ROUNDING_MODE(_MM_ROUND_NEAREST); + _MM_SET_EXCEPTION_MASK(_MM_MASK_MASK); + +#if 0 + unsigned new_mask = _mm_getcsr(); + + qDebug() << "old" << (void*) old_mask << "new" << (void*) new_mask; +#endif +} +#endif + void set_qt_style() { #if defined _WIN32 @@ -144,6 +168,10 @@ main(int argc, char** argv) attach_parent_console(); #endif +#if defined OTR_HAS_DENORM_CONTROL + set_fp_mask(); +#endif + #if QT_VERSION >= 0x050600 // flag introduced in QT 5.6. It is non-essential so might as well allow compilation on older systems. QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif |