summaryrefslogtreecommitdiff
path: root/cpu.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-05-04 15:24:09 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2007-05-04 15:24:09 +0000
commitdf1ffe1e41f89222c379d982e543c2a32da78cbd (patch)
tree3ddcd92ac078642dfed5375980dc2db4006d1498 /cpu.h
parent1bb93ea95e3131c2b9a4f8f8bd3f3197e4d52a76 (diff)
downloadcryptopp-df1ffe1e41f89222c379d982e543c2a32da78cbd.tar.gz
fix compile for x64, DLL and VC 6
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@332 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'cpu.h')
-rwxr-xr-xcpu.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/cpu.h b/cpu.h
index 6a21234..6eae489 100755
--- a/cpu.h
+++ b/cpu.h
@@ -3,6 +3,10 @@
#include "config.h"
+#ifdef CRYPTOPP_MSVC6PP_OR_LATER
+ #include <emmintrin.h>
+#endif
+
NAMESPACE_BEGIN(CryptoPP)
#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || (_MSC_VER >= 1400 && CRYPTOPP_BOOL_X64)
@@ -10,12 +14,15 @@ NAMESPACE_BEGIN(CryptoPP)
#define CRYPTOPP_CPUID_AVAILABLE
// these should not be used directly
-extern bool g_x86DetectionDone;
-extern bool g_hasSSE2, g_hasMMX, g_hasSSSE3, g_isP4;
-extern int g_cacheLineSize;
-void DetectX86Features();
+extern CRYPTOPP_DLL bool g_x86DetectionDone;
+extern CRYPTOPP_DLL bool g_hasSSE2;
+extern CRYPTOPP_DLL bool g_hasMMX;
+extern CRYPTOPP_DLL bool g_hasSSSE3;
+extern CRYPTOPP_DLL bool g_isP4;
+extern CRYPTOPP_DLL word32 g_cacheLineSize;
+CRYPTOPP_DLL void DetectX86Features();
-bool CpuId(word32 input, word32 *output);
+CRYPTOPP_DLL bool CpuId(word32 input, word32 *output);
#if CRYPTOPP_BOOL_X64
inline bool HasSSE2() {return true;}
@@ -94,6 +101,7 @@ inline bool HasMMX() {return false;}
#define ASL(x) GNU_ASL(x)
#define ASJ(x, y, z) GNU_ASJ(x, y, z)
#define ASC(x, y) #x " " #y ";"
+ #define CRYPTOPP_NAKED
#else
#define AS1(x) __asm {x}
#define AS2(x, y) __asm {x, y}
@@ -102,11 +110,26 @@ inline bool HasMMX() {return false;}
#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)
#endif
// GNU assembler doesn't seem to have mod operator
#define ASM_MOD(x, y) ((x)-((x)/(y))*(y))
+#if CRYPTOPP_BOOL_X86
+ #define WORD_SZ 4
+ #define WORD_REG(x) e##x
+ #define WORD_PTR DWORD PTR
+ #define AS_PUSH(x) AS1(push e##x)
+ #define AS_POP(x) AS1(pop e##x)
+#elif CRYPTOPP_BOOL_X64
+ #define WORD_SZ 8
+ #define WORD_REG(x) r##x
+ #define WORD_PTR QWORD PTR
+ #define AS_PUSH(x) AS1(pushq r##x)
+ #define AS_POP(x) AS1(popq r##x)
+#endif
+
NAMESPACE_END
#endif