diff options
author | weidai <weidai11@users.noreply.github.com> | 2007-04-16 05:40:37 +0000 |
---|---|---|
committer | weidai <weidai11@users.noreply.github.com> | 2007-04-16 05:40:37 +0000 |
commit | 3a3fef7436c4093908dee7a03bfcae6366f5ba95 (patch) | |
tree | 60a4e53f174eb18d85511f007d44f312368a52f9 | |
parent | 68a38c0b9aa572407ff9e9c0a1de79a79f6363f3 (diff) | |
download | cryptopp-git-3a3fef7436c4093908dee7a03bfcae6366f5ba95.tar.gz |
fix compile on Sun CC
-rw-r--r-- | GNUmakefile | 10 | ||||
-rw-r--r-- | config.h | 7 | ||||
-rwxr-xr-x | cpu.cpp | 2 | ||||
-rwxr-xr-x | cpu.h | 31 | ||||
-rw-r--r-- | integer.cpp | 2 | ||||
-rw-r--r-- | misc.h | 14 | ||||
-rwxr-xr-x | salsa.cpp | 2 | ||||
-rw-r--r-- | 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) @@ -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 @@ -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) { @@ -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<N; i+=2) { AddWithCarry(u, A[i], B[i]); @@ -707,6 +708,7 @@ int CRYPTOPP_FASTCALL Baseline_Sub(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<N; i+=2) { SubtractWithBorrow(u, A[i], B[i]); @@ -24,7 +24,7 @@ #define CRYPTOPP_FAST_ROTATE(x) ((x) == 32) #elif defined(__GNUC__) && (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86) // depend on GCC's peephole optimization to generate rotate instructions #define CRYPTOPP_FAST_ROTATE(x) 1 -#elif +#else #define CRYPTOPP_FAST_ROTATE(x) 0 #endif @@ -795,19 +795,19 @@ inline void GetUserKey(ByteOrder order, T *out, size_t outlen, const byte *in, s } #ifndef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS -inline byte UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, byte*) +inline byte UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const byte *) { return block[0]; } -inline word16 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, word16*) +inline word16 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const word16 *) { return (order == BIG_ENDIAN_ORDER) ? block[1] | (block[0] << 8) : block[0] | (block[1] << 8); } -inline word32 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, word32*) +inline word32 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const word32 *) { return (order == BIG_ENDIAN_ORDER) ? word32(block[3]) | (word32(block[2]) << 8) | (word32(block[1]) << 16) | (word32(block[0]) << 24) @@ -815,7 +815,7 @@ inline word32 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, wo } #ifdef WORD64_AVAILABLE -inline word64 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, word64*) +inline word64 UnalignedGetWordNonTemplate(ByteOrder order, const byte *block, const word64 *) { return (order == BIG_ENDIAN_ORDER) ? @@ -936,7 +936,7 @@ inline T GetWord(bool assumeAligned, ByteOrder order, const byte *block) { #ifndef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS if (!assumeAligned) - return UnalignedGetWordNonTemplate(order, block); + return UnalignedGetWordNonTemplate(order, block, (T*)NULL); assert(IsAligned<T>(block)); #endif return ConditionalByteReverse(order, *reinterpret_cast<const T *>(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<T>(block)); assert(IsAligned<T>(xorBlock)); #endif @@ -6,7 +6,9 @@ #include "argnames.h" #include "cpu.h" +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE #include <emmintrin.h> +#endif NAMESPACE_BEGIN(CryptoPP) @@ -83,7 +83,7 @@ template <typename WT, unsigned int W, unsigned int X = 1, class BASE = Additive struct CRYPTOPP_NO_VTABLE AdditiveCipherConcretePolicy : public BASE { typedef WT WordType; - CRYPTOPP_CONSTANT(BYTES_PER_ITERATION = sizeof(WordType) * W); + CRYPTOPP_CONSTANT(BYTES_PER_ITERATION = sizeof(WordType) * W) #if !(CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X64) unsigned int GetAlignment() const {return GetAlignmentOf<WordType>();} |