fix compile on MacOS X and MinGW

pull/2/head
weidai 2009-04-05 19:58:48 +00:00
parent 26666baa38
commit 5b809d7931
3 changed files with 11 additions and 5 deletions

View File

@ -12,7 +12,6 @@ MKDIR = mkdir
EGREP = egrep EGREP = egrep
UNAME = $(shell uname) UNAME = $(shell uname)
ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64") ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")
ISMINGW = $(shell uname | $(EGREP) -c "MINGW32")
# Default prefix for make install # Default prefix for make install
ifeq ($(PREFIX),) ifeq ($(PREFIX),)
@ -29,6 +28,7 @@ GCC42_OR_LATER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(GCC\) (4.[2-9]|[
INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)") INTEL_COMPILER = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "\(ICC\)")
GAS210_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])") GAS210_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.[1-9][0-9]|[3-9])")
GAS217_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])") GAS217_OR_LATER = $(shell echo "" | $(AS) -v 2>&1 | $(EGREP) -c "GNU assembler version (2\.1[7-9]|2\.[2-9]|[3-9])")
ISMINGW = $(shell $(CXX) --version 2>&1 | $(EGREP) -c "mingw")
ifneq ($(GCC42_OR_LATER),0) ifneq ($(GCC42_OR_LATER),0)
ifneq ($(UNAME),Darwin) ifneq ($(UNAME),Darwin)
@ -53,12 +53,12 @@ CXXFLAGS += -Wa,--divide # allow use of "/" operator
endif endif
endif endif
endif # ISX86
ifeq ($(ISMINGW),1) ifeq ($(ISMINGW),1)
LDLIBS += -lws2_32 LDLIBS += -lws2_32
endif endif
endif # ISX86
ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist ifeq ($(UNAME),) # for DJGPP, where uname doesn't exist
CXXFLAGS += -mbnu210 CXXFLAGS += -mbnu210
else else

View File

@ -73,6 +73,10 @@ being unloaded from L1 cache, until that round is finished.
#include <alloca.h> #include <alloca.h>
#endif #endif
#ifdef __MINGW32__
#include <malloc.h>
#endif
NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(CryptoPP)
#ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS #ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
@ -909,7 +913,7 @@ void Rijndael_Enc_AdvancedProcessBlocks(void *locals, const word32 *k);
} }
#endif #endif
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86
static inline bool AliasedWithTable(const byte *begin, const byte *end) static inline bool AliasedWithTable(const byte *begin, const byte *end)
{ {
@ -923,6 +927,7 @@ static inline bool AliasedWithTable(const byte *begin, const byte *end)
size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const
{ {
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
if (length < BLOCKSIZE) if (length < BLOCKSIZE)
return length; return length;
@ -976,6 +981,7 @@ size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xo
return length%16; return length%16;
} }
else else
#endif
return BlockTransformation::AdvancedProcessBlocks(inBlocks, xorBlocks, outBlocks, length, flags); return BlockTransformation::AdvancedProcessBlocks(inBlocks, xorBlocks, outBlocks, length, flags);
} }

View File

@ -41,7 +41,7 @@ class CRYPTOPP_DLL Rijndael : public Rijndael_Info, public BlockCipherDocumentat
{ {
public: public:
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const; void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE) #if CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86
size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const; size_t AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const;
#endif #endif
}; };