diff options
author | Tobias Markmann <tm@ayena.de> | 2014-10-19 20:22:58 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2014-10-20 13:49:33 (GMT) |
commit | 6b22dfcf59474dd016a0355a3102a1dd3692d92c (patch) | |
tree | 2b1fd33be433a91e81fee84fdc2bf1b52575d934 /3rdParty/Boost/src/boost/functional/hash/hash.hpp | |
parent | 38b0cb785fea8eae5e48fae56440695fdfd10ee1 (diff) | |
download | swift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.zip swift-6b22dfcf59474dd016a0355a3102a1dd3692d92c.tar.bz2 |
Update Boost in 3rdParty to version 1.56.0.
This updates Boost in our 3rdParty directory to version 1.56.0.
Updated our update.sh script to stop on error.
Changed error reporting in SwiftTools/CrashReporter.cpp to SWIFT_LOG due to
missing include of <iostream> with newer Boost.
Change-Id: I4b35c77de951333979a524097f35f5f83d325edc
Diffstat (limited to '3rdParty/Boost/src/boost/functional/hash/hash.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/functional/hash/hash.hpp | 154 |
1 files changed, 102 insertions, 52 deletions
diff --git a/3rdParty/Boost/src/boost/functional/hash/hash.hpp b/3rdParty/Boost/src/boost/functional/hash/hash.hpp index 647fd68..3e5ab5b 100644 --- a/3rdParty/Boost/src/boost/functional/hash/hash.hpp +++ b/3rdParty/Boost/src/boost/functional/hash/hash.hpp @@ -1,11 +1,17 @@ -// Copyright 2005-2009 Daniel James. +// Copyright 2005-2014 Daniel James. // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // Based on Peter Dimov's proposal // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf // issue 6.18. +// +// This also contains public domain code from MurmurHash. From the +// MurmurHash header: + +// MurmurHash3 was written by Austin Appleby, and is placed in the public +// domain. The author hereby disclaims copyright to this source code. #if !defined(BOOST_FUNCTIONAL_HASH_HASH_HPP) #define BOOST_FUNCTIONAL_HASH_HASH_HPP @@ -16,7 +22,9 @@ #include <string> #include <boost/limits.hpp> #include <boost/type_traits/is_enum.hpp> +#include <boost/type_traits/is_integral.hpp> #include <boost/utility/enable_if.hpp> +#include <boost/cstdint.hpp> #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) #include <boost/type_traits/is_pointer.hpp> @@ -26,6 +34,17 @@ #include <typeindex> #endif +#if defined(BOOST_MSVC) +#pragma warning(push) + +#if BOOST_MSVC >= 1400 +#pragma warning(disable:6295) // Ill-defined for-loop : 'unsigned int' values + // are always of range '0' to '4294967295'. + // Loop executes infinitely. +#endif + +#endif + #if BOOST_WORKAROUND(__GNUC__, < 3) \ && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) #define BOOST_HASH_CHAR_TRAITS string_char_traits @@ -33,6 +52,12 @@ #define BOOST_HASH_CHAR_TRAITS char_traits #endif +#if defined(_MSC_VER) +# define BOOST_FUNCTIONAL_HASH_ROTL32(x, r) _rotl(x,r) +#else +# define BOOST_FUNCTIONAL_HASH_ROTL32(x, r) (x << r) | (x >> (32 - r)) +#endif + namespace boost { namespace hash_detail @@ -40,8 +65,8 @@ namespace boost struct enable_hash_value { typedef std::size_t type; }; template <typename T> struct basic_numbers {}; - template <typename T> struct long_numbers {}; - template <typename T> struct ulong_numbers {}; + template <typename T> struct long_numbers; + template <typename T> struct ulong_numbers; template <typename T> struct float_numbers {}; template <> struct basic_numbers<bool> : @@ -70,6 +95,14 @@ namespace boost boost::hash_detail::enable_hash_value {}; #endif + // long_numbers is defined like this to allow for separate + // specialization for long_long and int128_type, in case + // they conflict. + template <typename T> struct long_numbers2 {}; + template <typename T> struct ulong_numbers2 {}; + template <typename T> struct long_numbers : long_numbers2<T> {}; + template <typename T> struct ulong_numbers : ulong_numbers2<T> {}; + #if !defined(BOOST_NO_LONG_LONG) template <> struct long_numbers<boost::long_long_type> : boost::hash_detail::enable_hash_value {}; @@ -77,6 +110,13 @@ namespace boost boost::hash_detail::enable_hash_value {}; #endif +#if defined(BOOST_HAS_INT128) + template <> struct long_numbers2<boost::int128_type> : + boost::hash_detail::enable_hash_value {}; + template <> struct ulong_numbers2<boost::uint128_type> : + boost::hash_detail::enable_hash_value {}; +#endif + template <> struct float_numbers<float> : boost::hash_detail::enable_hash_value {}; template <> struct float_numbers<double> : @@ -94,7 +134,7 @@ namespace boost template <typename T> typename boost::enable_if<boost::is_enum<T>, std::size_t>::type - hash_value(T); + hash_value(T); #if !BOOST_WORKAROUND(__DMC__, <= 0x848) template <class T> std::size_t hash_value(T* const&); @@ -165,6 +205,51 @@ namespace boost return seed; } + + template <typename SizeT> + inline void hash_combine_impl(SizeT& seed, SizeT value) + { + seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + + template <typename SizeT> + inline void hash_combine_impl(boost::uint32_t& h1, + boost::uint32_t k1) + { + const uint32_t c1 = 0xcc9e2d51; + const uint32_t c2 = 0x1b873593; + + k1 *= c1; + k1 = BOOST_FUNCTIONAL_HASH_ROTL32(k1,15); + k1 *= c2; + + h1 ^= k1; + h1 = BOOST_FUNCTIONAL_HASH_ROTL32(h1,13); + h1 = h1*5+0xe6546b64; + } + + +// Don't define 64-bit hash combine on platforms with 64 bit integers, +// and also not for 32-bit gcc as it warns about the 64-bit constant. +#if !defined(BOOST_NO_INT64_T) && \ + !(defined(__GNUC__) && ULONG_MAX == 0xffffffff) + + template <typename SizeT> + inline void hash_combine_impl(boost::uint64_t& h, + boost::uint64_t k) + { + const uint64_t m = UINT64_C(0xc6a4a7935bd1e995); + const int r = 47; + + k *= m; + k ^= k >> r; + k *= m; + + h ^= k; + h *= m; + } + +#endif // BOOST_NO_INT64_T } template <typename T> @@ -187,9 +272,9 @@ namespace boost template <typename T> typename boost::enable_if<boost::is_enum<T>, std::size_t>::type - hash_value(T v) + hash_value(T v) { - return static_cast<std::size_t>(v); + return static_cast<std::size_t>(v); } // Implementation by Alberto Barbati and Dave Harris. @@ -221,16 +306,11 @@ namespace boost #endif #endif -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - template <class T> - inline void hash_combine(std::size_t& seed, T& v) -#else template <class T> inline void hash_combine(std::size_t& seed, T const& v) -#endif { boost::hash<T> hasher; - seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); + return boost::hash_detail::hash_combine_impl(seed, hasher(v)); } #if defined(BOOST_MSVC) @@ -335,7 +415,6 @@ namespace boost // // These are undefined later. -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) #define BOOST_HASH_SPECIALIZE(type) \ template <> struct hash<type> \ : public std::unary_function<type, std::size_t> \ @@ -355,45 +434,6 @@ namespace boost return boost::hash_value(v); \ } \ }; -#else -#define BOOST_HASH_SPECIALIZE(type) \ - template <> struct hash<type> \ - : public std::unary_function<type, std::size_t> \ - { \ - std::size_t operator()(type v) const \ - { \ - return boost::hash_value(v); \ - } \ - }; \ - \ - template <> struct hash<const type> \ - : public std::unary_function<const type, std::size_t> \ - { \ - std::size_t operator()(const type v) const \ - { \ - return boost::hash_value(v); \ - } \ - }; - -#define BOOST_HASH_SPECIALIZE_REF(type) \ - template <> struct hash<type> \ - : public std::unary_function<type, std::size_t> \ - { \ - std::size_t operator()(type const& v) const \ - { \ - return boost::hash_value(v); \ - } \ - }; \ - \ - template <> struct hash<const type> \ - : public std::unary_function<const type, std::size_t> \ - { \ - std::size_t operator()(type const& v) const \ - { \ - return boost::hash_value(v); \ - } \ - }; -#endif BOOST_HASH_SPECIALIZE(bool) BOOST_HASH_SPECIALIZE(char) @@ -423,6 +463,11 @@ namespace boost BOOST_HASH_SPECIALIZE(boost::ulong_long_type) #endif +#if defined(BOOST_HAS_INT128) + BOOST_HASH_SPECIALIZE(boost::int128_type) + BOOST_HASH_SPECIALIZE(boost::uint128_type) +#endif + #if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) BOOST_HASH_SPECIALIZE(std::type_index) #endif @@ -496,6 +541,11 @@ namespace boost } #undef BOOST_HASH_CHAR_TRAITS +#undef BOOST_FUNCTIONAL_HASH_ROTL32 + +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif #endif // BOOST_FUNCTIONAL_HASH_HASH_HPP |