From 3d68714e229aefd3a91ad16e169f600abca1653d Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 20 Nov 2009 10:35:43 +0000 Subject: [PATCH] compatibility-c++0x.cc (_Fnv_hash<4>, [...]): Add. 2009-11-21 Paolo Carlini * src/compatibility-c++0x.cc (_Fnv_hash<4>, _Fnv_hash<8>): Add. From-SVN: r154361 --- libstdc++-v3/ChangeLog | 4 +++ libstdc++-v3/src/compatibility-c++0x.cc | 33 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 83e740d18cb..3ae63049b92 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,7 @@ +2009-11-21 Paolo Carlini + + * src/compatibility-c++0x.cc (_Fnv_hash<4>, _Fnv_hash<8>): Add. + 2009-11-19 Benjamin Kosnik * src/pool_allocator.cc: Adjust catch blocks. diff --git a/libstdc++-v3/src/compatibility-c++0x.cc b/libstdc++-v3/src/compatibility-c++0x.cc index 0e92135d403..df28ecae358 100644 --- a/libstdc++-v3/src/compatibility-c++0x.cc +++ b/libstdc++-v3/src/compatibility-c++0x.cc @@ -57,6 +57,39 @@ namespace std } }; + template<> + struct _Fnv_hash<4> + { + static size_t + hash(const char* __first, size_t __length) + { + size_t __result = static_cast(2166136261UL); + for (; __length > 0; --__length) + { + __result ^= static_cast(*__first++); + __result *= static_cast(16777619UL); + } + return __result; + } + }; + + template<> + struct _Fnv_hash<8> + { + static size_t + hash(const char* __first, size_t __length) + { + size_t __result = + static_cast(14695981039346656037ULL); + for (; __length > 0; --__length) + { + __result ^= static_cast(*__first++); + __result *= static_cast(1099511628211ULL); + } + return __result; + } + }; + #include "hash.cc" template<>