mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-27 03:40:22 +00:00
Cleanup CpuID function (PR #929)
This commit is contained in:
parent
18b535fb5a
commit
dd67e1eee4
42
cpu.cpp
42
cpu.cpp
@ -144,29 +144,25 @@ extern "C"
|
|||||||
|
|
||||||
extern bool CPU_ProbeSSE2();
|
extern bool CPU_ProbeSSE2();
|
||||||
|
|
||||||
#if _MSC_VER >= 1600
|
// No inline due to Borland/Embarcadero and Issue 498
|
||||||
|
|
||||||
inline bool CpuId(word32 func, word32 subfunc, word32 output[4])
|
|
||||||
{
|
|
||||||
__cpuidex((int *)output, func, subfunc);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(_MSC_VER) && _MSC_VER < 1600 && defined(_M_X64)
|
|
||||||
|
|
||||||
inline bool CpuId(word32 func, word32 subfunc, word32 output[4])
|
|
||||||
{
|
|
||||||
CPUID64(func, subfunc, output);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
// Borland/Embarcadero and Issue 498
|
|
||||||
// cpu.cpp (131): E2211 Inline assembly not allowed in inline and template functions
|
// cpu.cpp (131): E2211 Inline assembly not allowed in inline and template functions
|
||||||
bool CpuId(word32 func, word32 subfunc, word32 output[4])
|
bool CpuId(word32 func, word32 subfunc, word32 output[4])
|
||||||
{
|
{
|
||||||
#if defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY) || defined(__BORLANDC__)
|
// Visual Studio 2010 and above, all Intels
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
|
||||||
|
|
||||||
|
__cpuidex((int *)output, func, subfunc);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Visual Studio 2008 and below, 64-bit
|
||||||
|
#elif defined(_MSC_VER) && defined(_M_X64)
|
||||||
|
|
||||||
|
CPUID64(func, subfunc, output);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Visual Studio 2008 and below, 32-bit
|
||||||
|
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__BORLANDC__)
|
||||||
|
|
||||||
__try
|
__try
|
||||||
{
|
{
|
||||||
// Borland/Embarcadero and Issue 500
|
// Borland/Embarcadero and Issue 500
|
||||||
@ -187,14 +183,16 @@ bool CpuId(word32 func, word32 subfunc, word32 output[4])
|
|||||||
output[2] = c;
|
output[2] = c;
|
||||||
output[3] = d;
|
output[3] = d;
|
||||||
}
|
}
|
||||||
// GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION
|
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// Linux, Unix, OS X, Cygwin, MinGW
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// longjmp and clobber warnings. Volatile is required.
|
// longjmp and clobber warnings. Volatile is required.
|
||||||
// http://github.com/weidai11/cryptopp/issues/24 and http://stackoverflow.com/q/7721854
|
// http://github.com/weidai11/cryptopp/issues/24 and http://stackoverflow.com/q/7721854
|
||||||
volatile bool result = true;
|
volatile bool result = true;
|
||||||
@ -237,8 +235,6 @@ bool CpuId(word32 func, word32 subfunc, word32 output[4])
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool CRYPTOPP_SECTION_INIT g_x86DetectionDone = false;
|
bool CRYPTOPP_SECTION_INIT g_x86DetectionDone = false;
|
||||||
bool CRYPTOPP_SECTION_INIT g_hasSSE2 = false;
|
bool CRYPTOPP_SECTION_INIT g_hasSSE2 = false;
|
||||||
bool CRYPTOPP_SECTION_INIT g_hasSSSE3 = false;
|
bool CRYPTOPP_SECTION_INIT g_hasSSSE3 = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user