path: root/src/Crypto/cpu.h
diff options
authorMounir IDRASSI <>2017-07-04 11:19:53 +0200
committerMounir IDRASSI <>2017-07-04 12:28:17 +0200
commit88cc8a00f4a7fc34003b961c572d5a78462dd682 (patch)
treec34058cc9b899791f5b26a0c01955198cd0953d4 /src/Crypto/cpu.h
parent0358eb6c717cfe132bcec7fddeac14213ed8937c (diff)
Windows: correctly handle SEH exceptions during self-tests in order to disable CPU extended features in such case.
Diffstat (limited to 'src/Crypto/cpu.h')
1 files changed, 19 insertions, 26 deletions
diff --git a/src/Crypto/cpu.h b/src/Crypto/cpu.h
index 68041190..cddec05c 100644
--- a/src/Crypto/cpu.h
+++ b/src/Crypto/cpu.h
@@ -186,38 +186,31 @@ extern "C" {
// these should not be used directly
-extern int g_x86DetectionDone;
-extern int g_hasAVX;
-extern int g_hasAVX2;
-extern int g_hasBMI2;
-extern int g_hasSSE42;
-extern int g_hasSSE41;
-extern int g_hasSSSE3;
-extern int g_hasAESNI;
-extern int g_hasCLMUL;
-extern int g_isP4;
-extern int g_isIntel;
-extern int g_isAMD;
-extern uint32 g_cacheLineSize;
+extern volatile int g_x86DetectionDone;
+extern volatile int g_hasSSE2;
+extern volatile int g_hasISSE;
+extern volatile int g_hasMMX;
+extern volatile int g_hasAVX;
+extern volatile int g_hasAVX2;
+extern volatile int g_hasBMI2;
+extern volatile int g_hasSSE42;
+extern volatile int g_hasSSE41;
+extern volatile int g_hasSSSE3;
+extern volatile int g_hasAESNI;
+extern volatile int g_hasCLMUL;
+extern volatile int g_isP4;
+extern volatile int g_isIntel;
+extern volatile int g_isAMD;
+extern volatile uint32 g_cacheLineSize;
void DetectX86Features(); // must be called at the start of the program/driver
int CpuId(uint32 input, uint32 *output);
-#define HasSSE2() 1
-#define HasISSE() 1
-#define HasMMX() 1
-extern int g_hasSSE2;
-extern int g_hasISSE;
-extern int g_hasMMX;
+// disable all CPU extended features (e.g. SSE, AVX, AES) that may have
+// been enabled by DetectX86Features.
+void DisableCPUExtendedFeatures ();
#define HasSSE2() g_hasSSE2
#define HasISSE() g_hasISSE
#define HasMMX() g_hasMMX
#define HasSSE42() g_hasSSE42
#define HasSSE41() g_hasSSE41
#define HasSAVX() g_hasAVX