From dd6b53792ce52a8e10d85d4420f3946d87419d44 Mon Sep 17 00:00:00 2001 From: weidai Date: Wed, 28 Jul 2010 23:45:28 +0000 Subject: fix compile on Sun CC fix compile for non-x86 CPUs git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@511 57ff6487-cd31-0410-9ec3-f628ee90f5f0 --- bench.cpp | 8 ++++++-- cpu.cpp | 4 +++- gcm.cpp | 10 +++++++--- validat1.cpp | 2 ++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bench.cpp b/bench.cpp index 8521a5a..b39386d 100644 --- a/bench.cpp +++ b/bench.cpp @@ -243,9 +243,11 @@ void BenchmarkAll(double t, double hertz) cout << "AlgorithmMiB/Second" << cpb << "Microseconds to
Setup Key and IV" << cpk << endl; cout << "\n"; - if (CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE && HasCLMUL()) +#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE + if (HasCLMUL()) BenchMarkByName2("AES/GCM", 0, "AES/GCM"); else +#endif { BenchMarkByName2("AES/GCM", 0, "AES/GCM (2K tables)", MakeParameters(Name::TableSize(), 2048)); BenchMarkByName2("AES/GCM", 0, "AES/GCM (64K tables)", MakeParameters(Name::TableSize(), 64*1024)); @@ -254,9 +256,11 @@ void BenchmarkAll(double t, double hertz) BenchMarkByName2("AES/EAX"); cout << "\n"; - if (CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE && HasCLMUL()) +#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE + if (HasCLMUL()) BenchMarkByName2("AES/GCM", 0, "GMAC(AES)"); else +#endif { BenchMarkByName2("AES/GCM", 0, "GMAC(AES) (2K tables)", MakeParameters(Name::TableSize(), 2048)); BenchMarkByName2("AES/GCM", 0, "GMAC(AES) (64K tables)", MakeParameters(Name::TableSize(), 64*1024)); diff --git a/cpu.cpp b/cpu.cpp index 7a0079a..3610a7c 100755 --- a/cpu.cpp +++ b/cpu.cpp @@ -32,6 +32,7 @@ bool CpuId(word32 input, word32 *output) #else #ifndef CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY +extern "C" { typedef void (*SigHandler)(int); static jmp_buf s_jmpNoCPUID; @@ -45,6 +46,7 @@ static void SigIllHandlerSSE2(int) { longjmp(s_jmpNoSSE2, 1); } +} #endif bool CpuId(word32 input, word32 *output) @@ -78,7 +80,7 @@ bool CpuId(word32 input, word32 *output) result = false; else { - __asm__ + asm ( // save ebx in case -fPIC is being used #if CRYPTOPP_BOOL_X86 diff --git a/gcm.cpp b/gcm.cpp index 610db97..84f6f91 100644 --- a/gcm.cpp +++ b/gcm.cpp @@ -15,8 +15,8 @@ #endif #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE -#include -#include +#include +#include #endif NAMESPACE_BEGIN(CryptoPP) @@ -336,7 +336,11 @@ void GCM_Base::Resync(const byte *iv, size_t len) unsigned int GCM_Base::OptimalDataAlignment() const { - return HasSSE2() ? 16 : GetBlockCipher().OptimalDataAlignment(); + return +#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) + HasSSE2() ? 16 : +#endif + GetBlockCipher().OptimalDataAlignment(); } #pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code diff --git a/validat1.cpp b/validat1.cpp index 696327d..5b82539 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -236,6 +236,7 @@ bool TestSettings() #endif cout << endl; +#ifdef CRYPTOPP_CPUID_AVAILABLE bool hasMMX = HasMMX(); bool hasISSE = HasISSE(); bool hasSSE2 = HasSSE2(); @@ -253,6 +254,7 @@ bool TestSettings() cout << "hasMMX == " << hasMMX << ", hasISSE == " << hasISSE << ", hasSSE2 == " << hasSSE2 << ", hasSSSE3 == " << hasSSSE3 << ", hasAESNI == " << HasAESNI() << ", hasCLMUL == " << HasCLMUL() << ", isP4 == " << isP4 << ", cacheLineSize == " << cacheLineSize; cout << ", AESNI_INTRINSICS == " << CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE << endl; +#endif if (!pass) { -- cgit v1.2.1