Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #140 from shuffle2/master
Implement workaround for Windows versions which do not support XSAVE.
- Loading branch information
Showing
5 changed files
with
45 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters