cityhash 0.2.0.0 → 0.3.0.0
raw patch · 4 files changed
+74/−7 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- cbits/city.h +5/−0
- cbits/citycrc.h +43/−0
- cbits/hs_city.cc +12/−2
- cityhash.cabal +14/−5
cbits/city.h view
@@ -74,6 +74,11 @@ // hashed into the result. uint128 CityHash128WithSeed(const char *s, size_t len, uint128 seed); +uint128 CityHashCrc128(const char *s, size_t len);++uint128 CityHashCrc128WithSeed(const char *s, size_t len, uint128 seed);++ // Hash 128 input bits down to 64 bits of output. // This is intended to be a reasonably good hash function. inline uint64 Hash128to64(const uint128& x) {
+ cbits/citycrc.h view
@@ -0,0 +1,43 @@+// Copyright (c) 2011 Google, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.+//+// CityHash, by Geoff Pike and Jyrki Alakuijala+//+// This file declares the subset of the CityHash functions that require+// _mm_crc32_u64(). See the CityHash README for details.+//+// Functions in the CityHash family are not suitable for cryptography.++#ifndef CITY_HASH_CRC_H_+#define CITY_HASH_CRC_H_++#include <city.h>++// Hash function for a byte array.+uint128 CityHashCrc128(const char *s, size_t len);++// Hash function for a byte array. For convenience, a 128-bit seed is also+// hashed into the result.+uint128 CityHashCrc128WithSeed(const char *s, size_t len, uint128 seed);++// Hash function for a byte array. Sets result[0] ... result[3].+void CityHashCrc256(const char *s, size_t len, uint64 *result);++#endif // CITY_HASH_CRC_H_
cbits/hs_city.cc view
@@ -5,17 +5,22 @@ return CityHash64(buf,len); } -uint64_t hs_CityHash64WithSeed(const char *buf, size_t len, uint64_t seed) {+uint64_t hs_CityHash64WithSeed(const char* buf, size_t len, uint64_t seed) { return CityHash64WithSeed(buf,len,seed); } -uint64_t hs_CityHash64WithSeeds(const char *buf, size_t len,+uint64_t hs_CityHash64WithSeeds(const char* buf, size_t len, uint64 seed0, uint64 seed1) { return CityHash64WithSeeds(buf,len,seed0,seed1); } void hs_CityHash128(const char* buf, size_t len, uint64_t* lo, uint64_t* hi) {+#if defined(__SSE4_2__)+ uint128 res = CityHashCrc128(buf,len);+#else uint128 res = CityHash128(buf,len);+#endif /* defined(__SSE4_2__) */+ *lo = Uint128Low64(res); *hi = Uint128High64(res); }@@ -25,7 +30,12 @@ uint128 seed; seed.first = in1; seed.second = in2; +#if defined(__SSE4_2__)+ uint128 r = CityHashCrc128WithSeed(buf, len, seed);+#else uint128 r = CityHash128WithSeed(buf, len, seed);+#endif /* defined(__SSE4_2__) */+ *lo = Uint128Low64(r); *hi = Uint128High64(r); }
cityhash.cabal view
@@ -1,10 +1,14 @@ name: cityhash-version: 0.2.0.0+version: 0.3.0.0 synopsis: Bindings to CityHash description: This package implements a binding to the CityHash family of hashing functions (implemented in C++.) . See <http://code.google.com/p/cityhash/> for more information.+ .+ This package has optional SSE4.2 support. If you build it with the @-fsse42@ flag, the 128-bit+ hashing functions will use an SSE-optimized implementation (which takes advantage of the @crc32@+ instruction present on recent Intel/AMD machines.) The 64-bit hashing functions are unaffected. homepage: http://github.com/thoughtpolice/hs-cityhash bug-reports: https://github.com/thoughtpolice/hs-cityhash/issues license: MIT@@ -17,7 +21,7 @@ tested-with: GHC==7.0.4, GHC==7.2.1 extra-source-files:- cbits/city.cc, cbits/city.h, cbits/config.h+ cbits/city.cc, cbits/city.h, cbits/config.h, cbits/citycrc.h, cbits/hs_city.cc, cbits/hs_city.h, README.md, tests/Properties.hs @@ -25,16 +29,21 @@ type: git location: https://github.com/thoughtpolice/hs-cityhash.git +flag sse42+ default: False+ library exposed-modules: Data.Digest.CityHash build-depends:- base >= 3 && < 5,- bytestring >= 0.9,- largeword >= 1.0+ base >= 3 && < 5,+ bytestring >= 0.9,+ largeword >= 1.0 c-sources: cbits/city.cc, cbits/hs_city.cc include-dirs: cbits extra-libraries: stdc++ + if flag(sse42)+ cc-options: -D__SSE4_2__ -msse4.2 cc-options: -O3 ghc-options: -Wall -O2 -fwarn-tabs default-language: Haskell98