From ebb56f57edd46175798c2a70b6dd88bd6ce7f877 Mon Sep 17 00:00:00 2001 From: weidai Date: Mon, 13 Aug 2007 23:53:09 +0000 Subject: fixed Whirlpool crash on Pentium 2 machines git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@385 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- cpu.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'cpu.cpp') diff --git a/cpu.cpp b/cpu.cpp index 4d8577e..3e46804 100755 --- a/cpu.cpp +++ b/cpu.cpp @@ -145,7 +145,7 @@ static bool TrySSE2() } bool g_x86DetectionDone = false; -bool g_hasSSE2 = false, g_hasSSSE3 = false, g_hasMMX = false, g_isP4 = false; +bool g_hasISSE = false, g_hasSSE2 = false, g_hasSSSE3 = false, g_hasMMX = false, g_isP4 = false; word32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE; void DetectX86Features() @@ -161,6 +161,19 @@ void DetectX86Features() g_hasSSE2 = TrySSE2(); g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9)); + if ((cpuid1[3] & (1 << 25)) != 0) + g_hasISSE = true; + else + { + word32 cpuid2[4]; + CpuId(0x080000000, cpuid2); + if (cpuid2[0] >= 0x080000001) + { + CpuId(0x080000001, cpuid2); + g_hasISSE = (cpuid2[3] & (1 << 22)) != 0; + } + } + std::swap(cpuid[2], cpuid[3]); if (memcmp(cpuid+1, "GenuineIntel", 12) == 0) { -- cgit v1.2.1