From 3a3fef7436c4093908dee7a03bfcae6366f5ba95 Mon Sep 17 00:00:00 2001 From: weidai Date: Mon, 16 Apr 2007 05:40:37 +0000 Subject: fix compile on Sun CC --- GNUmakefile | 10 ++++++++-- config.h | 7 +++++-- cpu.cpp | 2 +- cpu.h | 31 ++++++++++++++++--------------- integer.cpp | 2 ++ misc.h | 14 +++++++------- salsa.cpp | 2 ++ strciphr.h | 2 +- 8 files changed, 42 insertions(+), 28 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index f8390024..23d13436 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -48,10 +48,8 @@ endif ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist CXXFLAGS += -mbnu210 else -ifneq ($(CXX),CC) # don't use -pipe with CC (Solaris native C++ compiler) CXXFLAGS += -pipe endif -endif ifeq ($(UNAME),Linux) LDFLAGS += -pthread @@ -72,6 +70,14 @@ endif ifeq ($(UNAME),SunOS) LDLIBS += -lnsl -lsocket +ifeq ($(CXX),CC) # override flags for CC (Solaris native C++ compiler) +CXXFLAGS = -DNDEBUG -O -g -native +LDFLAGS = +ifeq ($(ISX86),1) +# SSE2 intrinsics should work in Sun Studio 12 +# CXXFLAGS += -xarch=sse2 -D__SSE2__ +endif +endif endif SRCS = $(wildcard *.cpp) diff --git a/config.h b/config.h index 82fd4951..05d77fff 100644 --- a/config.h +++ b/config.h @@ -186,8 +186,10 @@ NAMESPACE_END #ifndef CRYPTOPP_ALIGN_DATA #if defined(CRYPTOPP_MSVC6PP_OR_LATER) #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x)) - #elif defined(__GNUC__) + #elif defined(__GNUC__) || __SUNPRO_CC > 0x580 #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x))) + #else + #define CRYPTOPP_ALIGN_DATA(x) #endif #endif @@ -323,7 +325,8 @@ NAMESPACE_END #define CRYPTOPP_BOOL_X64 0 #endif -#if defined(_M_IX86) || defined(__i386__) +// see http://predef.sourceforge.net/prearch.html +#if defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__) #define CRYPTOPP_BOOL_X86 1 #else #define CRYPTOPP_BOOL_X86 0 diff --git a/cpu.cpp b/cpu.cpp index 643a0ffc..a4922504 100755 --- a/cpu.cpp +++ b/cpu.cpp @@ -76,7 +76,7 @@ static void SigIllHandlerSSE2(int) } #endif -#elif _MSC_VER >= 1400 +#elif _MSC_VER >= 1400 && CRYPTOPP_BOOL_X64 bool CpuId(word32 input, word32 *output) { diff --git a/cpu.h b/cpu.h index d8a5a1f7..6a212345 100755 --- a/cpu.h +++ b/cpu.h @@ -5,7 +5,7 @@ NAMESPACE_BEGIN(CryptoPP) -#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || _MSC_VER >= 1400 +#if defined(CRYPTOPP_X86_ASM_AVAILABLE) || (_MSC_VER >= 1400 && CRYPTOPP_BOOL_X64) #define CRYPTOPP_CPUID_AVAILABLE @@ -17,7 +17,10 @@ void DetectX86Features(); bool CpuId(word32 input, word32 *output); -#if !CRYPTOPP_BOOL_X64 +#if CRYPTOPP_BOOL_X64 +inline bool HasSSE2() {return true;} +inline bool HasMMX() {return true;} +#else inline bool HasSSE2() { @@ -63,22 +66,20 @@ inline int GetCacheLineSize() return CRYPTOPP_L1_CACHE_LINE_SIZE; } -#endif // #ifdef CRYPTOPP_X86_ASM_AVAILABLE || _MSC_VER >= 1400 - -#if CRYPTOPP_BOOL_X64 - -inline bool HasSSE2() -{ - return true; -} - -inline bool HasMMX() -{ - return true; -} +inline bool HasSSSE3() {return false;} +inline bool IsP4() {return false;} +// assume MMX and SSE2 if intrinsics are enabled +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE || CRYPTOPP_BOOL_X64 +inline bool HasSSE2() {return true;} +inline bool HasMMX() {return true;} +#else +inline bool HasSSE2() {return false;} +inline bool HasMMX() {return false;} #endif +#endif // #ifdef CRYPTOPP_X86_ASM_AVAILABLE || _MSC_VER >= 1400 + #if defined(__GNUC__) // define these in two steps to allow arguments to be expanded #define GNU_AS1(x) #x ";" diff --git a/integer.cpp b/integer.cpp index 8909ec94..64f3cea0 100644 --- a/integer.cpp +++ b/integer.cpp @@ -692,6 +692,7 @@ int CRYPTOPP_FASTCALL Baseline_Add(size_t N, word *C, const word *A, const word assert (N%2 == 0); Declare2Words(u); + AssignWord(u, 0); for (size_t i=0; i(block)); #endif return ConditionalByteReverse(order, *reinterpret_cast(block)); @@ -953,7 +953,7 @@ inline void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, c { #ifndef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS if (!assumeAligned) - return UnalignedGetWordNonTemplate(order, block, value, xorBlock); + return UnalignedPutWordNonTemplate(order, block, value, xorBlock); assert(IsAligned(block)); assert(IsAligned(xorBlock)); #endif diff --git a/salsa.cpp b/salsa.cpp index 40fffc43..4781218a 100755 --- a/salsa.cpp +++ b/salsa.cpp @@ -6,7 +6,9 @@ #include "argnames.h" #include "cpu.h" +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE #include +#endif NAMESPACE_BEGIN(CryptoPP) diff --git a/strciphr.h b/strciphr.h index e9bcf2e6..724bbbfd 100644 --- a/strciphr.h +++ b/strciphr.h @@ -83,7 +83,7 @@ template ();} -- cgit v1.2.1