diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2014-03-06 23:59:52 +0100 |
|---|---|---|
| committer | Pierre Bourdon <delroth@gmail.com> | 2014-03-06 23:59:52 +0100 |
| commit | c7b8c75d383311a2b5abe12ce9ad535f40b6ebce (patch) | |
| tree | f1f302ff3104dbfa8a5e0ffebffdd181b7ab55e8 /Source/Core/Common/XSaveWorkaround.cpp | |
| parent | e5b250fa792ab48f8c4d6adb94c544312f13acd1 (diff) | |
| parent | 932945d4808e37ba0ca1a953571187f445e24f41 (diff) | |
Merge pull request #140 from shuffle2/master
Implement workaround for Windows versions which do not support XSAVE.
Diffstat (limited to 'Source/Core/Common/XSaveWorkaround.cpp')
| -rw-r--r-- | Source/Core/Common/XSaveWorkaround.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/Core/Common/XSaveWorkaround.cpp b/Source/Core/Common/XSaveWorkaround.cpp new file mode 100644 index 0000000000..30a2a42b2b --- /dev/null +++ b/Source/Core/Common/XSaveWorkaround.cpp @@ -0,0 +1,40 @@ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#if defined(_WIN32) && defined(_ARCH_64) + +#include <math.h> +#include <Windows.h> + +// This puts the rest of this translation unit into a segment which is +// initialized by the CRT *before* any of the other code (including C++ +// static initializers). +#pragma warning(disable : 4075) +#pragma init_seg(".CRT$XCB") + +struct EnableXSaveWorkaround +{ + EnableXSaveWorkaround() + { + // Some Windows environments may have hardware support for AVX/FMA, + // but the OS does not support it. The CRT math library does not support + // this scenario, so we have to manually tell it not to use FMA3 + // instructions. + + // The API name is somewhat misleading - we're testing for OS support + // here. + if (!IsProcessorFeaturePresent(PF_XSAVE_ENABLED)) + { + _set_FMA3_enable(0); + } + } +}; + +static EnableXSaveWorkaround enableXSaveWorkaround; + +// N.B. Any code after this will still be in the .CRT$XCB segment. Please just +// do not append any code here unless it is intended to be executed before +// static initializers. + +#endif |
