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.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'cpu.cpp') diff --git a/cpu.cpp b/cpu.cpp index a492250..c42dd8b 100755 --- a/cpu.cpp +++ b/cpu.cpp @@ -1,8 +1,10 @@ // cpu.cpp - written and placed in the public domain by Wei Dai #include "pch.h" -#include "cpu.h" +#ifndef CRYPTOPP_IMPORTS + +#include "cpu.h" #include "misc.h" #include @@ -11,10 +13,15 @@ #include #endif +#ifdef CRYPTOPP_MSVC6PP_OR_LATER +#include +#endif + NAMESPACE_BEGIN(CryptoPP) #ifdef CRYPTOPP_X86_ASM_AVAILABLE +#ifndef _MSC_VER typedef void (*SigHandler)(int); static jmp_buf s_jmpNoCPUID; @@ -22,6 +29,7 @@ static void SigIllHandlerCPUID(int) { longjmp(s_jmpNoCPUID, 1); } +#endif bool CpuId(word32 input, word32 *output) { @@ -57,7 +65,11 @@ bool CpuId(word32 input, word32 *output) __asm__ ( // save ebx in case -fPIC is being used +#if CRYPTOPP_BOOL_X86 "push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx" +#else + "pushq %%rbx; cpuid; mov %%ebx, %%edi; popq %%rbx" +#endif : "=a" (output[0]), "=D" (output[1]), "=c" (output[2]), "=d" (output[3]) : "a" (input) ); @@ -84,22 +96,19 @@ bool CpuId(word32 input, word32 *output) return true; } -inline bool TrySSE2() -{ - return true; -} - #endif #ifdef CRYPTOPP_CPUID_AVAILABLE static bool TrySSE2() { -#ifdef _MSC_VER +#if CRYPTOPP_BOOL_X64 + return true; +#elif defined(_MSC_VER) __try { #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE - __asm por xmm0, xmm0 // executing SSE2 instruction + AS2(por xmm0, xmm0) // executing SSE2 instruction #elif CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE __mm128i x = _mm_setzero_si128(); return _mm_cvtsi128_si32(x) == 0; @@ -137,7 +146,7 @@ static bool TrySSE2() bool g_x86DetectionDone = false; bool g_hasSSE2 = false, g_hasSSSE3 = false, g_hasMMX = false, g_isP4 = false; -int g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE; +word32 g_cacheLineSize = CRYPTOPP_L1_CACHE_LINE_SIZE; void DetectX86Features() { @@ -170,3 +179,5 @@ void DetectX86Features() #endif NAMESPACE_END + +#endif -- cgit v1.2.1