add AESNI and CLMUL detection
parent
1c8437454e
commit
46832de97a
4
cpu.cpp
4
cpu.cpp
|
|
@ -145,7 +145,7 @@ static bool TrySSE2()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool g_x86DetectionDone = false;
|
bool g_x86DetectionDone = false;
|
||||||
bool g_hasISSE = false, 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_hasAESNI = false, g_hasCLMUL = false, g_isP4 = false;
|
||||||
word32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE;
|
word32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE;
|
||||||
|
|
||||||
void DetectX86Features()
|
void DetectX86Features()
|
||||||
|
|
@ -160,6 +160,8 @@ void DetectX86Features()
|
||||||
if ((cpuid1[3] & (1 << 26)) != 0)
|
if ((cpuid1[3] & (1 << 26)) != 0)
|
||||||
g_hasSSE2 = TrySSE2();
|
g_hasSSE2 = TrySSE2();
|
||||||
g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9));
|
g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9));
|
||||||
|
g_hasAESNI = (cpuid1[2] & (1<<25)) != 0;
|
||||||
|
g_hasCLMUL = (cpuid1[2] & (1<<1)) != 0;
|
||||||
|
|
||||||
if ((cpuid1[3] & (1 << 25)) != 0)
|
if ((cpuid1[3] & (1 << 25)) != 0)
|
||||||
g_hasISSE = true;
|
g_hasISSE = true;
|
||||||
|
|
|
||||||
16
cpu.h
16
cpu.h
|
|
@ -28,6 +28,8 @@ extern CRYPTOPP_DLL bool g_hasSSE2;
|
||||||
extern CRYPTOPP_DLL bool g_hasISSE;
|
extern CRYPTOPP_DLL bool g_hasISSE;
|
||||||
extern CRYPTOPP_DLL bool g_hasMMX;
|
extern CRYPTOPP_DLL bool g_hasMMX;
|
||||||
extern CRYPTOPP_DLL bool g_hasSSSE3;
|
extern CRYPTOPP_DLL bool g_hasSSSE3;
|
||||||
|
extern CRYPTOPP_DLL bool g_hasAESNI;
|
||||||
|
extern CRYPTOPP_DLL bool g_hasCLMUL;
|
||||||
extern CRYPTOPP_DLL bool g_isP4;
|
extern CRYPTOPP_DLL bool g_isP4;
|
||||||
extern CRYPTOPP_DLL word32 g_cacheLineSize;
|
extern CRYPTOPP_DLL word32 g_cacheLineSize;
|
||||||
CRYPTOPP_DLL void CRYPTOPP_API DetectX86Features();
|
CRYPTOPP_DLL void CRYPTOPP_API DetectX86Features();
|
||||||
|
|
@ -70,6 +72,20 @@ inline bool HasSSSE3()
|
||||||
return g_hasSSSE3;
|
return g_hasSSSE3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool HasAESNI()
|
||||||
|
{
|
||||||
|
if (!g_x86DetectionDone)
|
||||||
|
DetectX86Features();
|
||||||
|
return g_hasAESNI;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool HasCLMUL()
|
||||||
|
{
|
||||||
|
if (!g_x86DetectionDone)
|
||||||
|
DetectX86Features();
|
||||||
|
return g_hasCLMUL;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool IsP4()
|
inline bool IsP4()
|
||||||
{
|
{
|
||||||
if (!g_x86DetectionDone)
|
if (!g_x86DetectionDone)
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ bool TestSettings()
|
||||||
else
|
else
|
||||||
cout << "passed: ";
|
cout << "passed: ";
|
||||||
|
|
||||||
cout << "hasMMX == " << hasMMX << ", hasISSE == " << hasISSE << ", hasSSE2 == " << hasSSE2 << ", hasSSSE3 == " << hasSSSE3 << ", isP4 == " << isP4 << ", cacheLineSize == " << cacheLineSize;
|
cout << "hasMMX == " << hasMMX << ", hasISSE == " << hasISSE << ", hasSSE2 == " << hasSSE2 << ", hasSSSE3 == " << hasSSSE3 << ", hasAESNI == " << HasAESNI() << ", hasCLMUL == " << HasCLMUL() << ", isP4 == " << isP4 << ", cacheLineSize == " << cacheLineSize;
|
||||||
|
|
||||||
if (!pass)
|
if (!pass)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue