From f8717545022137560ae3fe2f2a28709bf9122d78 Mon Sep 17 00:00:00 2001 From: weidai Date: Mon, 22 Dec 2008 06:55:08 +0000 Subject: [PATCH] fix compile with GCC 4.0.1 on MacOS X 64-bit --- config.h | 11 ++++++----- integer.cpp | 2 +- iterhash.cpp | 12 ++++++++++++ iterhash.h | 14 ++++++++------ 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/config.h b/config.h index b2d6248f..ae7c5358 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 e5aa95e8..0926a0bf 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 273e0340..44360b11 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 void IteratedHashBase::TruncatedFinal(by this->Restart(); // reinit for next use } +#ifdef __GNUC__ + #ifdef WORD64_AVAILABLE + template class IteratedHashBase; + template class IteratedHashBase; + #endif + + template class IteratedHashBase; + template class IteratedHashBase; +#endif + NAMESPACE_END diff --git a/iterhash.h b/iterhash.h index d7d2f6e9..a22b57db 100644 --- a/iterhash.h +++ b/iterhash.h @@ -93,13 +93,15 @@ protected: FixedSizeSecBlock m_state; }; -#ifdef WORD64_AVAILABLE -CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase; -CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase; -#endif +#ifndef __GNUC__ + #ifdef WORD64_AVAILABLE + CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase; + CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase; + #endif -CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase; -CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase; + CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase; + CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase; +#endif NAMESPACE_END