From df1ffe1e41f89222c379d982e543c2a32da78cbd Mon Sep 17 00:00:00 2001 From: weidai Date: Fri, 4 May 2007 15:24:09 +0000 Subject: 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 --- cpu.h | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'cpu.h') 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 +#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 -- cgit v1.2.1