summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2008-12-22 06:55:08 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2008-12-22 06:55:08 +0000
commit83c4add7725ca2489ee5f10aee215e804368838b (patch)
treefb71bcd9079c3d52aa10d6a7c41a2f97412c6033
parentfca600f5f0c5759de6fe2f671aae8b183706c4b0 (diff)
downloadcryptopp-83c4add7725ca2489ee5f10aee215e804368838b.tar.gz
fix compile with GCC 4.0.1 on MacOS X 64-bit
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@430 57ff6487-cd31-0410-9ec3-f628ee90f5f0
-rw-r--r--config.h11
-rw-r--r--integer.cpp2
-rw-r--r--iterhash.cpp12
-rw-r--r--iterhash.h14
4 files changed, 27 insertions, 12 deletions
diff --git a/config.h b/config.h
index b2d6248..ae7c535 100644
--- a/config.h
+++ b/config.h
@@ -123,6 +123,10 @@ typedef unsigned int word32;
const lword LWORD_MAX = 0xffffffffUL;
#endif
+#ifdef __GNUC__
+ #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+#endif
+
// define hword, word, and dword. these are used for multiprecision integer arithmetic
// Intel compiler won't have _umul128 until version 10.0. See http://softwarecommunity.intel.com/isn/Community/en-US/forums/thread/30231625.aspx
#if (defined(_MSC_VER) && (!defined(__INTEL_COMPILER) || __INTEL_COMPILER >= 1000) && (defined(_M_X64) || defined(_M_IA64))) || (defined(__DECCXX) && defined(__alpha__)) || (defined(__INTEL_COMPILER) && defined(__x86_64__))
@@ -131,7 +135,8 @@ typedef unsigned int word32;
#else
#define CRYPTOPP_NATIVE_DWORD_AVAILABLE
#if defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || defined(__x86_64__) || defined(__mips64) || defined(__sparc64__)
- #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
+ #if defined(__GNUC__) && !defined(__INTEL_COMPILER) && !(CRYPTOPP_GCC_VERSION == 40001 && defined(__APPLE__))
+ // GCC 4.0.1 on MacOS X is missing __umodti3 and __udivti3
typedef word32 hword;
typedef word64 word;
typedef __uint128_t dword;
@@ -181,10 +186,6 @@ NAMESPACE_END
#endif
#endif
-#ifdef __GNUC__
- #define CRYPTOPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
-#endif
-
#ifndef CRYPTOPP_ALIGN_DATA
#if defined(CRYPTOPP_MSVC6PP_OR_LATER)
#define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
diff --git a/integer.cpp b/integer.cpp
index e5aa95e..0926a0b 100644
--- a/integer.cpp
+++ b/integer.cpp
@@ -101,7 +101,7 @@ static word AtomicInverseModPower2(word A)
// ********************************************************
-#if !defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE) || defined(__x86_64__)
+#if !defined(CRYPTOPP_NATIVE_DWORD_AVAILABLE) || (defined(__x86_64__) && defined(CRYPTOPP_WORD128_AVAILABLE))
#define Declare2Words(x) word x##0, x##1;
#define AssignWord(a, b) a##0 = b; a##1 = 0;
#define Add2WordsBy1(a, b, c) a##0 = b##0 + c; a##1 = b##1 + (a##0 < c);
diff --git a/iterhash.cpp b/iterhash.cpp
index 273e034..44360b1 100644
--- a/iterhash.cpp
+++ b/iterhash.cpp
@@ -1,6 +1,8 @@
// iterhash.cpp - written and placed in the public domain by Wei Dai
+#ifndef __GNUC__
#define CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES
+#endif
#include "iterhash.h"
#include "misc.h"
@@ -142,4 +144,14 @@ template <class T, class BASE> void IteratedHashBase<T, BASE>::TruncatedFinal(by
this->Restart(); // reinit for next use
}
+#ifdef __GNUC__
+ #ifdef WORD64_AVAILABLE
+ template class IteratedHashBase<word64, HashTransformation>;
+ template class IteratedHashBase<word64, MessageAuthenticationCode>;
+ #endif
+
+ template class IteratedHashBase<word32, HashTransformation>;
+ template class IteratedHashBase<word32, MessageAuthenticationCode>;
+#endif
+
NAMESPACE_END
diff --git a/iterhash.h b/iterhash.h
index d7d2f6e..a22b57d 100644
--- a/iterhash.h
+++ b/iterhash.h
@@ -93,14 +93,16 @@ protected:
FixedSizeSecBlock<T_HashWordType, T_BlockSize/sizeof(T_HashWordType)> m_state;
};
-#ifdef WORD64_AVAILABLE
-CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word64, HashTransformation>;
-CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word64, MessageAuthenticationCode>;
+#ifndef __GNUC__
+ #ifdef WORD64_AVAILABLE
+ CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word64, HashTransformation>;
+ CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word64, MessageAuthenticationCode>;
+ #endif
+
+ CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word32, HashTransformation>;
+ CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word32, MessageAuthenticationCode>;
#endif
-CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word32, HashTransformation>;
-CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word32, MessageAuthenticationCode>;
-
NAMESPACE_END
#endif