From 25ff77c2fde3715d25f882aae036323551b63e05 Mon Sep 17 00:00:00 2001 From: NATTSiM Date: Tue, 14 Jan 2014 08:38:59 -0800 Subject: [PATCH] Fix Clang compile and link errors --- src/beast/beast/http/URL.h | 3 -- src/beast/beast/net/IPAddress.h | 13 --------- src/beast/beast/threads/impl/ServiceQueue.cpp | 3 +- src/ripple/beast/ripple_beast.cpp | 6 +--- src/ripple/types/api/CryptoIdentifier.h | 3 ++ src/ripple/types/api/IdentifierType.h | 6 ---- src/ripple/types/api/RippleAssets.h | 1 + src/ripple/types/api/UInt160.h | 6 ---- src/ripple/types/api/base_uint.h | 3 -- src/ripple/types/impl/RandomNumbers.cpp | 2 +- src/ripple/types/impl/RippleAssets.cpp | 27 +++++++++++++++--- src/ripple/types/ripple_types.cpp | 2 ++ src/ripple/types/ripple_types.h | 2 +- src/ripple_app/consensus/LedgerConsensus.cpp | 4 +++ src/ripple_app/consensus/LedgerConsensus.h | 4 ++- src/ripple_app/ripple_app.h | 5 ++-- src/ripple_app/shamap/SHAMap.h | 26 +++++++++++++++++ src/ripple_app/shamap/SHAMapAddNode.h | 4 +++ src/ripple_app/shamap/SHAMapMissingNode.h | 4 +++ src/ripple_app/shamap/SHAMapNode.h | 4 +++ src/ripple_app/shamap/SHAMapSyncFilter.h | 4 +++ src/ripple_app/shamap/SHAMapTreeNode.h | 4 +++ src/ripple_basics/log/LogPartition.h | 28 +++++++++++++------ src/websocket/src/roles/server.hpp | 2 +- 24 files changed, 110 insertions(+), 56 deletions(-) diff --git a/src/beast/beast/http/URL.h b/src/beast/beast/http/URL.h index d9359df59c..d2b01f6e55 100644 --- a/src/beast/beast/http/URL.h +++ b/src/beast/beast/http/URL.h @@ -130,9 +130,6 @@ extern std::size_t hash_value (beast::URL const& url); namespace std { -template -struct hash; - template <> struct hash { diff --git a/src/beast/beast/net/IPAddress.h b/src/beast/beast/net/IPAddress.h index ef2616fae2..c67a31179c 100644 --- a/src/beast/beast/net/IPAddress.h +++ b/src/beast/beast/net/IPAddress.h @@ -26,16 +26,6 @@ #include "../CStdInt.h" -namespace std { - -template -struct hash; - -//template <> -//struct hash ; - -} - //------------------------------------------------------------------------------ namespace beast { @@ -400,9 +390,6 @@ inline bool IPAddress::EqualWithoutPort::operator() ( namespace std { -template -struct hash; - template <> struct hash { diff --git a/src/beast/beast/threads/impl/ServiceQueue.cpp b/src/beast/beast/threads/impl/ServiceQueue.cpp index 7f62cc3cb3..9fe3bf452c 100644 --- a/src/beast/beast/threads/impl/ServiceQueue.cpp +++ b/src/beast/beast/threads/impl/ServiceQueue.cpp @@ -437,10 +437,11 @@ public: } }; - static int const callsPerThread = 10000; + static std::size_t const totalCalls = 10000; void testThreads (std::size_t n) { + std::size_t const callsPerThread (totalCalls / n); beginTestCase (String::fromNumber (n) + " threads"); ServiceQueue service (n); std::vector > threads; diff --git a/src/ripple/beast/ripple_beast.cpp b/src/ripple/beast/ripple_beast.cpp index 17443c0a85..0d4bba81ce 100644 --- a/src/ripple/beast/ripple_beast.cpp +++ b/src/ripple/beast/ripple_beast.cpp @@ -27,11 +27,7 @@ // Include this to get all the basic includes included, to prevent errors #include "../beast/modules/beast_core/beast_core.h" - -// Mac builds use ripple_beastobjc.mm -#ifndef BEAST_MAC -# include "../beast/modules/beast_core/beast_core.cpp" -#endif +#include "../beast/modules/beast_core/beast_core.cpp" #include "../beast/modules/beast_asio/beast_asio.cpp" #include "../beast/modules/beast_sqdb/beast_sqdb.cpp" diff --git a/src/ripple/types/api/CryptoIdentifier.h b/src/ripple/types/api/CryptoIdentifier.h index 92481066fc..50c844918e 100644 --- a/src/ripple/types/api/CryptoIdentifier.h +++ b/src/ripple/types/api/CryptoIdentifier.h @@ -127,6 +127,9 @@ public: } }; +template + typename CryptoIdentifier ::size_type + const CryptoIdentifier ::size; } #endif diff --git a/src/ripple/types/api/IdentifierType.h b/src/ripple/types/api/IdentifierType.h index 4556ab223e..d7d91c1055 100644 --- a/src/ripple/types/api/IdentifierType.h +++ b/src/ripple/types/api/IdentifierType.h @@ -220,9 +220,6 @@ std::istream& operator>> (std::istream& is, namespace std { -template -struct hash; - /** Specialization for hash. */ template struct hash > @@ -254,9 +251,6 @@ private: //------------------------------------------------------------------------------ -template -struct equal_to; - /** Specialization for equal_to. */ template struct equal_to > diff --git a/src/ripple/types/api/RippleAssets.h b/src/ripple/types/api/RippleAssets.h index f62448d0b8..a4b5f0bb3f 100644 --- a/src/ripple/types/api/RippleAssets.h +++ b/src/ripple/types/api/RippleAssets.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_TYPES_RIPPLEASSETS_H_INCLUDED #define RIPPLE_TYPES_RIPPLEASSETS_H_INCLUDED +#include #include namespace ripple { diff --git a/src/ripple/types/api/UInt160.h b/src/ripple/types/api/UInt160.h index 776085e516..407810a262 100644 --- a/src/ripple/types/api/UInt160.h +++ b/src/ripple/types/api/UInt160.h @@ -194,9 +194,6 @@ extern std::size_t hash_value (const uint160&); namespace std { -template -struct hash; - template <> struct hash : ripple::uint160::hasher { @@ -210,9 +207,6 @@ struct hash : ripple::uint160::hasher namespace boost { -template -struct hash; - template <> struct hash : ripple::uint160::hasher { diff --git a/src/ripple/types/api/base_uint.h b/src/ripple/types/api/base_uint.h index c0a2fe9d4a..8dc33e80f3 100644 --- a/src/ripple/types/api/base_uint.h +++ b/src/ripple/types/api/base_uint.h @@ -531,9 +531,6 @@ private: //------------------------------------------------------------------------------ -template -struct equal_to; - /** Specialization for equal_to. */ template struct equal_to > diff --git a/src/ripple/types/impl/RandomNumbers.cpp b/src/ripple/types/impl/RandomNumbers.cpp index 11c15c9366..807bdde615 100644 --- a/src/ripple/types/impl/RandomNumbers.cpp +++ b/src/ripple/types/impl/RandomNumbers.cpp @@ -29,7 +29,7 @@ # include # include #endif -#if BEAST_LINUX || BEAST_BSD +#if BEAST_LINUX || BEAST_BSD || BEAST_MAC || BEAST_IOS # include #else # include diff --git a/src/ripple/types/impl/RippleAssets.cpp b/src/ripple/types/impl/RippleAssets.cpp index 1f048df65a..83336881ef 100644 --- a/src/ripple/types/impl/RippleAssets.cpp +++ b/src/ripple/types/impl/RippleAssets.cpp @@ -28,6 +28,16 @@ # define STL_SET_HAS_EMPLACE 0 #endif +#ifndef RIPPLE_ASSETS_ENABLE_STD_HASH +# if BEAST_MAC || BEAST_IOS +# define RIPPLE_ASSETS_ENABLE_STD_HASH 0 +# else +# define RIPPLE_ASSETS_ENABLE_STD_HASH 1 +# endif +#endif + + + namespace ripple { class RippleAssetTests : public UnitTest @@ -50,7 +60,7 @@ public: expect (u3 >= u2); expect (u3 > u2); - std::hash const hash; + std::hash hash; expect (hash (u1) == hash (u1)); expect (hash (u2) == hash (u2)); @@ -87,7 +97,7 @@ public: expect (Asset (c1, i3) >= Asset (c1, i2)); expect (Asset (c1, i3) > Asset (c1, i2)); - std::hash const hash; + std::hash hash; expect (hash (Asset (c1, i1)) == hash (Asset (c1, i1))); expect (hash (Asset (c1, i2)) == hash (Asset (c1, i2))); @@ -201,11 +211,13 @@ public: beginTestCase ("std::set "); testAssetSet > (); +#if RIPPLE_ASSETS_ENABLE_STD_HASH beginTestCase ("std::unordered_set "); testAssetSet > (); beginTestCase ("std::unordered_set "); testAssetSet > (); +#endif beginTestCase ("boost::unordered_set "); testAssetSet > (); @@ -216,12 +228,13 @@ public: void testAssetMaps () { - beginTestCase ("std::map "); + beginTestCase ("std::map "); testAssetMap > (); beginTestCase ("std::map "); testAssetMap > (); +#if RIPPLE_ASSETS_ENABLE_STD_HASH beginTestCase ("std::unordered_map "); testAssetMap > (); @@ -233,6 +246,8 @@ public: beginTestCase ("boost::unordered_map "); testAssetMap > (); + +#endif } //-------------------------------------------------------------------------- @@ -259,7 +274,7 @@ public: expect (Book (a3, a4) >= Book (a2, a3)); expect (Book (a3, a4) > Book (a2, a3)); - std::hash const hash; + std::hash hash; expect (hash (Book (a1, a2)) == hash (Book (a1, a2))); expect (hash (Book (a1, a3)) == hash (Book (a1, a3))); @@ -381,11 +396,13 @@ public: beginTestCase ("std::set "); testBookSet > (); +#if RIPPLE_ASSETS_ENABLE_STD_HASH beginTestCase ("std::unordered_set "); testBookSet > (); beginTestCase ("std::unordered_set "); testBookSet > (); +#endif beginTestCase ("boost::unordered_set "); testBookSet > (); @@ -402,6 +419,7 @@ public: beginTestCase ("std::map "); testBookMap > (); +#if RIPPLE_ASSETS_ENABLE_STD_HASH beginTestCase ("std::unordered_map "); testBookMap > (); @@ -413,6 +431,7 @@ public: beginTestCase ("boost::unordered_map "); testBookMap > (); +#endif } //-------------------------------------------------------------------------- diff --git a/src/ripple/types/ripple_types.cpp b/src/ripple/types/ripple_types.cpp index a747c181f0..8b33328c5b 100644 --- a/src/ripple/types/ripple_types.cpp +++ b/src/ripple/types/ripple_types.cpp @@ -47,3 +47,5 @@ #include "impl/RippleIdentifierTests.cpp" #include "impl/RippleAssets.cpp" #include "impl/JsonPropertyStream.cpp" + + diff --git a/src/ripple/types/ripple_types.h b/src/ripple/types/ripple_types.h index b53d2b068d..2b7523431d 100644 --- a/src/ripple/types/ripple_types.h +++ b/src/ripple/types/ripple_types.h @@ -51,8 +51,8 @@ using namespace beast; # include "api/ByteOrder.h" # include "api/strHex.h" # include "api/UInt128.h" -# include "api/UInt160.h" # include "api/UInt256.h" +# include "api/UInt160.h" # include "api/RandomNumbers.h" #include "api/HashMaps.h" diff --git a/src/ripple_app/consensus/LedgerConsensus.cpp b/src/ripple_app/consensus/LedgerConsensus.cpp index 7659aa3f8d..1d45d2245f 100644 --- a/src/ripple_app/consensus/LedgerConsensus.cpp +++ b/src/ripple_app/consensus/LedgerConsensus.cpp @@ -1906,6 +1906,10 @@ private: //------------------------------------------------------------------------------ +LedgerConsensus::~LedgerConsensus () +{ +} + boost::shared_ptr LedgerConsensus::New(LedgerHash const & prevLCLHash, Ledger::ref previousLedger, uint32 closeTime) { diff --git a/src/ripple_app/consensus/LedgerConsensus.h b/src/ripple_app/consensus/LedgerConsensus.h index dbdbcbbe06..f03ecb5c87 100644 --- a/src/ripple_app/consensus/LedgerConsensus.h +++ b/src/ripple_app/consensus/LedgerConsensus.h @@ -27,11 +27,13 @@ */ class LedgerConsensus { -public: +public: static shared_ptr New( LedgerHash const & prevLCLHash, Ledger::ref previousLedger, uint32 closeTime); + virtual ~LedgerConsensus () = 0; + virtual int startup () = 0; virtual Json::Value getJson (bool full) = 0; diff --git a/src/ripple_app/ripple_app.h b/src/ripple_app/ripple_app.h index 126b5340df..257ba0e081 100644 --- a/src/ripple_app/ripple_app.h +++ b/src/ripple_app/ripple_app.h @@ -24,6 +24,7 @@ #include #endif + //------------------------------------------------------------------------------ // VFALCO TODO Reduce these boost dependencies. Make more interfaces @@ -76,13 +77,13 @@ namespace ripple { // VFALCO NOTE Have to step outside the ripple namespace to // get the specialization for std::hash, et. al. #include "shamap/SHAMapNode.h" - -namespace ripple { #include "shamap/SHAMapTreeNode.h" #include "shamap/SHAMapMissingNode.h" #include "shamap/SHAMapSyncFilter.h" #include "shamap/SHAMapAddNode.h" #include "shamap/SHAMap.h" + +namespace ripple { #include "misc/SerializedTransaction.h" #include "misc/SerializedLedger.h" #include "tx/TransactionMeta.h" diff --git a/src/ripple_app/shamap/SHAMap.h b/src/ripple_app/shamap/SHAMap.h index 214d321e43..05435eacdf 100644 --- a/src/ripple_app/shamap/SHAMap.h +++ b/src/ripple_app/shamap/SHAMap.h @@ -29,6 +29,30 @@ enum SHAMapState smsInvalid = 4, // Map is known not to be valid (usually synching a corrupt ledger) }; +namespace std { + +template <> +struct hash +{ + std::size_t operator() (ripple::SHAMapNode const& value) const + { + return value.getMHash (); + } +}; + +} + +namespace boost { + +template <> +struct hash : std::hash +{ +}; + +} + +namespace ripple { + class SHAMap : public CountedObject { @@ -290,4 +314,6 @@ private: MissingNodeHandler m_missing_node_handler; }; +} + #endif diff --git a/src/ripple_app/shamap/SHAMapAddNode.h b/src/ripple_app/shamap/SHAMapAddNode.h index 6e0c7098df..eee0cb90ce 100644 --- a/src/ripple_app/shamap/SHAMapAddNode.h +++ b/src/ripple_app/shamap/SHAMapAddNode.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_SHAMAPADDNODE_H #define RIPPLE_SHAMAPADDNODE_H +namespace ripple { + // results of adding nodes class SHAMapAddNode { @@ -131,4 +133,6 @@ private: int mDuplicate; }; +} + #endif diff --git a/src/ripple_app/shamap/SHAMapMissingNode.h b/src/ripple_app/shamap/SHAMapMissingNode.h index ac04e0c0ee..cf0612aba0 100644 --- a/src/ripple_app/shamap/SHAMapMissingNode.h +++ b/src/ripple_app/shamap/SHAMapMissingNode.h @@ -27,6 +27,8 @@ enum SHAMapType smtFREE = 3, // A tree not part of a ledger }; +namespace ripple { + class SHAMapMissingNode : public std::runtime_error { public: @@ -95,4 +97,6 @@ private: extern std::ostream& operator<< (std::ostream&, SHAMapMissingNode const&); +} + #endif diff --git a/src/ripple_app/shamap/SHAMapNode.h b/src/ripple_app/shamap/SHAMapNode.h index 45dd3edbac..39cd8e2734 100644 --- a/src/ripple_app/shamap/SHAMapNode.h +++ b/src/ripple_app/shamap/SHAMapNode.h @@ -135,6 +135,7 @@ inline std::ostream& operator<< (std::ostream& out, const SHAMapNode& node) //------------------------------------------------------------------------------ +/* namespace std { template <> @@ -147,9 +148,11 @@ struct hash }; } +*/ //------------------------------------------------------------------------------ +/* namespace boost { template <> @@ -158,5 +161,6 @@ struct hash : std::hash }; } +*/ #endif diff --git a/src/ripple_app/shamap/SHAMapSyncFilter.h b/src/ripple_app/shamap/SHAMapSyncFilter.h index 672edb02f7..87fdc0ff3b 100644 --- a/src/ripple_app/shamap/SHAMapSyncFilter.h +++ b/src/ripple_app/shamap/SHAMapSyncFilter.h @@ -22,6 +22,8 @@ /** Callback for filtering SHAMap during sync. */ +namespace ripple { + class SHAMapSyncFilter { public: @@ -39,4 +41,6 @@ public: Blob& nodeData) = 0; }; +} + #endif diff --git a/src/ripple_app/shamap/SHAMapTreeNode.h b/src/ripple_app/shamap/SHAMapTreeNode.h index abaee7ceb8..54e97f6e6c 100644 --- a/src/ripple_app/shamap/SHAMapTreeNode.h +++ b/src/ripple_app/shamap/SHAMapTreeNode.h @@ -29,6 +29,8 @@ enum SHANodeFormat snfHASH = 3, // just the hash }; +namespace ripple { + class SHAMapTreeNode : public SHAMapNode , public CountedObject @@ -183,4 +185,6 @@ private: bool updateHash (); }; +} + #endif diff --git a/src/ripple_basics/log/LogPartition.h b/src/ripple_basics/log/LogPartition.h index 7c9cf18d9b..c471c12354 100644 --- a/src/ripple_basics/log/LogPartition.h +++ b/src/ripple_basics/log/LogPartition.h @@ -86,7 +86,6 @@ public: static Journal::Severity convertLogSeverity (LogSeverity level); /** @} */ -private: /** Retrieve the name for a log partition. */ template static char const* getPartitionName (); @@ -100,19 +99,30 @@ private: std::string mName; }; +//------------------------------------------------------------------------------ + +namespace detail { + +template +struct LogPartitionType : LogPartition +{ + LogPartitionType () : LogPartition (getPartitionName ()) + { } +}; + +} + template LogPartition& LogPartition::get () { - struct LogPartitionType : LogPartition - { - LogPartitionType () : LogPartition (getPartitionName ()) - { } - }; - - // Each LogPartition is a singleton. - return *SharedSingleton ::getInstance(); + return *SharedSingleton < + detail::LogPartitionType >::getInstance(); } +//------------------------------------------------------------------------------ + +// VFALCO These macros are deprecated. Use the Journal class instead. + #define SETUP_LOG(Class) \ template <> char const* LogPartition::getPartitionName () { return #Class; } \ struct Class##Instantiator { Class##Instantiator () { LogPartition::get (); } }; \ diff --git a/src/websocket/src/roles/server.hpp b/src/websocket/src/roles/server.hpp index cc701e2b29..2ce45d9249 100644 --- a/src/websocket/src/roles/server.hpp +++ b/src/websocket/src/roles/server.hpp @@ -55,7 +55,7 @@ namespace websocketpp { typedef boost::asio::buffers_iterator bufIterator; -static std::pair match_header(boost::shared_ptr string, +static inline std::pair match_header(boost::shared_ptr string, bufIterator nBegin, bufIterator nEnd) { if (nBegin == nEnd)