summaryrefslogtreecommitdiff
path: root/cpu.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2010-07-24 05:55:22 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2010-07-24 05:55:22 +0000
commit8532f317b3440154b421b1e8b8b004ead28f847e (patch)
tree9fa57aeee5c779a3c9b4f88006050d81ff68e6ef /cpu.h
parent5e47408d6c3c40f0aafaa2b32a2ae0889f9fc089 (diff)
downloadcryptopp-8532f317b3440154b421b1e8b8b004ead28f847e.tar.gz
add support for AES-NI and CLMUL instruction sets in AES and GMAC/GCM
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@508 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'cpu.h')
-rwxr-xr-xcpu.h48
1 files changed, 18 insertions, 30 deletions
diff --git a/cpu.h b/cpu.h
index 79e5ea8..9a6ee22 100755
--- a/cpu.h
+++ b/cpu.h
@@ -18,22 +18,18 @@
NAMESPACE_BEGIN(CryptoPP)
-#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || (_MSC_VER >= 1400 && CRYPTOPP_BOOL_X64)
+#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64
#define CRYPTOPP_CPUID_AVAILABLE
// these should not be used directly
extern CRYPTOPP_DLL bool g_x86DetectionDone;
-extern CRYPTOPP_DLL bool g_hasSSE2;
-extern CRYPTOPP_DLL bool g_hasISSE;
-extern CRYPTOPP_DLL bool g_hasMMX;
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 word32 g_cacheLineSize;
CRYPTOPP_DLL void CRYPTOPP_API DetectX86Features();
-
CRYPTOPP_DLL bool CRYPTOPP_API CpuId(word32 input, word32 *output);
#if CRYPTOPP_BOOL_X64
@@ -42,6 +38,10 @@ inline bool HasISSE() {return true;}
inline bool HasMMX() {return true;}
#else
+extern CRYPTOPP_DLL bool g_hasSSE2;
+extern CRYPTOPP_DLL bool g_hasISSE;
+extern CRYPTOPP_DLL bool g_hasMMX;
+
inline bool HasSSE2()
{
if (!g_x86DetectionDone)
@@ -107,22 +107,8 @@ inline int GetCacheLineSize()
return CRYPTOPP_L1_CACHE_LINE_SIZE;
}
-inline bool HasSSSE3() {return false;}
-inline bool IsP4() {return false;}
-
-// assume MMX and SSE2 if intrinsics are enabled
-#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_X64
-inline bool HasSSE2() {return true;}
-inline bool HasISSE() {return true;}
-inline bool HasMMX() {return true;}
-#else
-inline bool HasSSE2() {return false;}
-inline bool HasISSE() {return false;}
-inline bool HasMMX() {return false;}
#endif
-#endif // #ifdef CRYPTOPP_X86_ASM_AVAILABLE || _MSC_VER >= 1400
-
#endif
#ifdef CRYPTOPP_GENERATE_X64_MASM
@@ -134,7 +120,19 @@ inline bool HasMMX() {return false;}
#define ASJ(x, y, z) x label##y*newline*
#define ASC(x, y) x label##y*newline*
#define AS_HEX(y) 0##y##h
-#elif defined(__GNUC__)
+#elif defined(_MSC_VER) || defined(__BORLANDC__)
+ #define CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY
+ #define AS1(x) __asm {x}
+ #define AS2(x, y) __asm {x, y}
+ #define AS3(x, y, z) __asm {x, y, z}
+ #define ASS(x, y, a, b, c, d) __asm {x, y, (a)*64+(b)*16+(c)*4+(d)}
+ #define ASL(x) __asm {label##x:}
+ #define ASJ(x, y, z) __asm {x label##y}
+ #define ASC(x, y) __asm {x label##y}
+ #define CRYPTOPP_NAKED __declspec(naked)
+ #define AS_HEX(y) 0x##y
+#else
+ #define CRYPTOPP_GNU_STYLE_INLINE_ASSEMBLY
// define these in two steps to allow arguments to be expanded
#define GNU_AS1(x) #x ";"
#define GNU_AS2(x, y) #x ", " #y ";"
@@ -150,16 +148,6 @@ inline bool HasMMX() {return false;}
#define ASC(x, y) #x " " #y ";"
#define CRYPTOPP_NAKED
#define AS_HEX(y) 0x##y
-#else
- #define AS1(x) __asm {x}
- #define AS2(x, y) __asm {x, y}
- #define AS3(x, y, z) __asm {x, y, z}
- #define ASS(x, y, a, b, c, d) __asm {x, y, _MM_SHUFFLE(a, b, c, d)}
- #define ASL(x) __asm {label##x:}
- #define ASJ(x, y, z) __asm {x label##y}
- #define ASC(x, y) __asm {x label##y}
- #define CRYPTOPP_NAKED __declspec(naked)
- #define AS_HEX(y) 0x##y
#endif
#define IF0(y)