fix compile on Sun CC

fix compile for non-x86 CPUs
pull/2/head
weidai 2010-07-28 23:45:28 +00:00
parent 0e44445b68
commit 0403d122e1
4 changed files with 18 additions and 6 deletions

View File

@ -243,9 +243,11 @@ void BenchmarkAll(double t, double hertz)
cout << "<THEAD><TR><TH>Algorithm<TH>MiB/Second" << cpb << "<TH>Microseconds to<br>Setup Key and IV" << cpk << endl; cout << "<THEAD><TR><TH>Algorithm<TH>MiB/Second" << cpb << "<TH>Microseconds to<br>Setup Key and IV" << cpk << endl;
cout << "\n<TBODY style=\"background: yellow\">"; cout << "\n<TBODY style=\"background: yellow\">";
if (CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE && HasCLMUL()) #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
if (HasCLMUL())
BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/GCM", 0, "AES/GCM"); BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/GCM", 0, "AES/GCM");
else else
#endif
{ {
BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/GCM", 0, "AES/GCM (2K tables)", MakeParameters(Name::TableSize(), 2048)); BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/GCM", 0, "AES/GCM (2K tables)", MakeParameters(Name::TableSize(), 2048));
BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/GCM", 0, "AES/GCM (64K tables)", MakeParameters(Name::TableSize(), 64*1024)); BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/GCM", 0, "AES/GCM (64K tables)", MakeParameters(Name::TableSize(), 64*1024));
@ -254,9 +256,11 @@ void BenchmarkAll(double t, double hertz)
BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/EAX"); BenchMarkByName2<AuthenticatedSymmetricCipher, AuthenticatedSymmetricCipher>("AES/EAX");
cout << "\n<TBODY style=\"background: white\">"; cout << "\n<TBODY style=\"background: white\">";
if (CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE && HasCLMUL()) #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
if (HasCLMUL())
BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES)"); BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES)");
else else
#endif
{ {
BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES) (2K tables)", MakeParameters(Name::TableSize(), 2048)); BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES) (2K tables)", MakeParameters(Name::TableSize(), 2048));
BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES) (64K tables)", MakeParameters(Name::TableSize(), 64*1024)); BenchMarkByName2<AuthenticatedSymmetricCipher, MessageAuthenticationCode>("AES/GCM", 0, "GMAC(AES) (64K tables)", MakeParameters(Name::TableSize(), 64*1024));

View File

@ -32,6 +32,7 @@ bool CpuId(word32 input, word32 *output)
#else #else
#ifndef CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY #ifndef CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY
extern "C" {
typedef void (*SigHandler)(int); typedef void (*SigHandler)(int);
static jmp_buf s_jmpNoCPUID; static jmp_buf s_jmpNoCPUID;
@ -45,6 +46,7 @@ static void SigIllHandlerSSE2(int)
{ {
longjmp(s_jmpNoSSE2, 1); longjmp(s_jmpNoSSE2, 1);
} }
}
#endif #endif
bool CpuId(word32 input, word32 *output) bool CpuId(word32 input, word32 *output)
@ -78,7 +80,7 @@ bool CpuId(word32 input, word32 *output)
result = false; result = false;
else else
{ {
__asm__ asm
( (
// save ebx in case -fPIC is being used // save ebx in case -fPIC is being used
#if CRYPTOPP_BOOL_X86 #if CRYPTOPP_BOOL_X86

10
gcm.cpp
View File

@ -15,8 +15,8 @@
#endif #endif
#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE #if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
#include <tmmintrin.h> #include <tmmintrin.h>
#include <wmmintrin.h> #include <wmmintrin.h>
#endif #endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
@ -336,7 +336,11 @@ void GCM_Base::Resync(const byte *iv, size_t len)
unsigned int GCM_Base::OptimalDataAlignment() const 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 #pragma warning(disable: 4731) // frame pointer register 'ebp' modified by inline assembly code

View File

@ -236,6 +236,7 @@ bool TestSettings()
#endif #endif
cout << endl; cout << endl;
#ifdef CRYPTOPP_CPUID_AVAILABLE
bool hasMMX = HasMMX(); bool hasMMX = HasMMX();
bool hasISSE = HasISSE(); bool hasISSE = HasISSE();
bool hasSSE2 = HasSSE2(); 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 << "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; cout << ", AESNI_INTRINSICS == " << CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE << endl;
#endif
if (!pass) if (!pass)
{ {