large-hashable 0.1.0.0 → 0.1.0.1
raw patch · 4 files changed
+352/−97 lines, 4 filesdep ~HTFdep ~QuickCheckdep ~aesonnew-uploader
Dependency ranges changed: HTF, QuickCheck, aeson, base16-bytestring, byteable, bytes, bytestring, cereal, containers, cryptohash, deepseq, hashable, large-hashable, safecopy, scientific, strict, template-haskell, text, time, transformers, unordered-containers, utf8-light, vector, void
Files
- ChangeLog +5/−0
- README.md +8/−1
- cbits/bitfn.h +238/−0
- large-hashable.cabal +101/−96
+ ChangeLog view
@@ -0,0 +1,5 @@+0.1.0.1: 2016-08-10+ * fixed build issue: added bitfn.h to cabal file++0.1.0.0: 2016-08-09+ * initial release
README.md view
@@ -1,12 +1,19 @@ # LargeHashable [](https://travis-ci.org/factisresearch/large-hashable)+[](http://hackage.haskell.org/package/large-hashable) Efficiently hash Haskell values with MD5, SHA256, SHA512 and other hashing algorithms. -## Build instructions+## Install +* Using cabal: `cabal install large-hashable`+* Using Stack: `stack install large-hashable`++### Building from git repository++- clone the repository - Install the stack tool (http://haskellstack.org) - `stack build` builds the code - `stack test` builds the code and runs the tests
+ cbits/bitfn.h view
@@ -0,0 +1,238 @@+/*+ * Copyright (C) 2006-2009 Vincent Hanquez <vincent@snarc.org>+ *+ * Redistribution and use in source and binary forms, with or without+ * modification, are permitted provided that the following conditions+ * are met:+ * 1. Redistributions of source code must retain the above copyright+ * notice, this list of conditions and the following disclaimer.+ * 2. Redistributions in binary form must reproduce the above copyright+ * notice, this list of conditions and the following disclaimer in the+ * documentation and/or other materials provided with the distribution.+ *+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+ */++#ifndef BITFN_H+#define BITFN_H+#include <stdint.h>++#ifndef NO_INLINE_ASM+/**********************************************************/+# if (defined(__i386__))+# define ARCH_HAS_SWAP32+static inline uint32_t bitfn_swap32(uint32_t a)+{+ asm ("bswap %0" : "=r" (a) : "0" (a));+ return a;+}+/**********************************************************/+# elif (defined(__arm__))+# define ARCH_HAS_SWAP32+static inline uint32_t bitfn_swap32(uint32_t a)+{+ uint32_t tmp = a;+ asm volatile ("eor %1, %0, %0, ror #16\n"+ "bic %1, %1, #0xff0000\n"+ "mov %0, %0, ror #8\n"+ "eor %0, %0, %1, lsr #8\n"+ : "=r" (a), "=r" (tmp) : "0" (a), "1" (tmp));+ return a;+}+/**********************************************************/+# elif defined(__x86_64__)+# define ARCH_HAS_SWAP32+# define ARCH_HAS_SWAP64+static inline uint32_t bitfn_swap32(uint32_t a)+{+ asm ("bswap %0" : "=r" (a) : "0" (a));+ return a;+}++static inline uint64_t bitfn_swap64(uint64_t a)+{+ asm ("bswap %0" : "=r" (a) : "0" (a));+ return a;+}++# endif+#endif /* NO_INLINE_ASM */+/**********************************************************/++#ifndef ARCH_HAS_ROL32+static inline uint32_t rol32(uint32_t word, uint32_t shift)+{+ return (word << shift) | (word >> (32 - shift));+}+#endif++#ifndef ARCH_HAS_ROR32+static inline uint32_t ror32(uint32_t word, uint32_t shift)+{+ return (word >> shift) | (word << (32 - shift));+}+#endif++#ifndef ARCH_HAS_ROL64+static inline uint64_t rol64(uint64_t word, uint32_t shift)+{+ return (word << shift) | (word >> (64 - shift));+}+#endif++#ifndef ARCH_HAS_ROR64+static inline uint64_t ror64(uint64_t word, uint32_t shift)+{+ return (word >> shift) | (word << (64 - shift));+}+#endif++#ifndef ARCH_HAS_SWAP32+static inline uint32_t bitfn_swap32(uint32_t a)+{+ return (a << 24) | ((a & 0xff00) << 8) | ((a >> 8) & 0xff00) | (a >> 24);+}+#endif++#ifndef ARCH_HAS_ARRAY_SWAP32+static inline void array_swap32(uint32_t *d, uint32_t *s, uint32_t nb)+{+ while (nb--)+ *d++ = bitfn_swap32(*s++);+}+#endif++#ifndef ARCH_HAS_SWAP64+static inline uint64_t bitfn_swap64(uint64_t a)+{+ return ((uint64_t) bitfn_swap32((uint32_t) (a >> 32))) |+ (((uint64_t) bitfn_swap32((uint32_t) a)) << 32);+}+#endif++#ifndef ARCH_HAS_ARRAY_SWAP64+static inline void array_swap64(uint64_t *d, uint64_t *s, uint32_t nb)+{+ while (nb--)+ *d++ = bitfn_swap64(*s++);+}+#endif++#ifndef ARCH_HAS_MEMORY_ZERO+static inline void memory_zero(void *ptr, uint32_t len)+{+ uint32_t *ptr32 = ptr;+ uint8_t *ptr8;+ int i;++ for (i = 0; i < len / 4; i++)+ *ptr32++ = 0;+ if (len % 4) {+ ptr8 = (uint8_t *) ptr32;+ for (i = len % 4; i >= 0; i--)+ ptr8[i] = 0;+ }+}+#endif++#ifndef ARCH_HAS_ARRAY_COPY32+static inline void array_copy32(uint32_t *d, uint32_t *s, uint32_t nb)+{+ while (nb--) *d++ = *s++;+}+#endif++#ifndef ARCH_HAS_ARRAY_COPY64+static inline void array_copy64(uint64_t *d, uint64_t *s, uint32_t nb)+{+ while (nb--) *d++ = *s++;+}+#endif++#ifdef __MINGW32__+ # define LITTLE_ENDIAN 1234+ # define BYTE_ORDER LITTLE_ENDIAN+#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__)+ # include <sys/endian.h>+#elif defined(__OpenBSD__) || defined(__SVR4)+ # include <sys/types.h>+#elif defined(__APPLE__)+ # include <machine/endian.h>+#elif defined( BSD ) && ( BSD >= 199103 )+ # include <machine/endian.h>+#elif defined( __QNXNTO__ ) && defined( __LITTLEENDIAN__ )+ # define LITTLE_ENDIAN 1234+ # define BYTE_ORDER LITTLE_ENDIAN+#elif defined( __QNXNTO__ ) && defined( __BIGENDIAN__ )+ # define BIG_ENDIAN 1234+ # define BYTE_ORDER BIG_ENDIAN+#else+ # include <endian.h>+#endif+/* big endian to cpu */+#if LITTLE_ENDIAN == BYTE_ORDER++# define be32_to_cpu(a) bitfn_swap32(a)+# define cpu_to_be32(a) bitfn_swap32(a)+# define le32_to_cpu(a) (a)+# define cpu_to_le32(a) (a)+# define be64_to_cpu(a) bitfn_swap64(a)+# define cpu_to_be64(a) bitfn_swap64(a)+# define le64_to_cpu(a) (a)+# define cpu_to_le64(a) (a)++# define cpu_to_le32_array(d, s, l) array_copy32(d, s, l)+# define le32_to_cpu_array(d, s, l) array_copy32(d, s, l)+# define cpu_to_be32_array(d, s, l) array_swap32(d, s, l)+# define be32_to_cpu_array(d, s, l) array_swap32(d, s, l)++# define cpu_to_le64_array(d, s, l) array_copy64(d, s, l)+# define le64_to_cpu_array(d, s, l) array_copy64(d, s, l)+# define cpu_to_be64_array(d, s, l) array_swap64(d, s, l)+# define be64_to_cpu_array(d, s, l) array_swap64(d, s, l)++# define ror32_be(a, s) rol32(a, s)+# define rol32_be(a, s) ror32(a, s)++# define ARCH_IS_LITTLE_ENDIAN++#elif BIG_ENDIAN == BYTE_ORDER++# define be32_to_cpu(a) (a)+# define cpu_to_be32(a) (a)+# define be64_to_cpu(a) (a)+# define cpu_to_be64(a) (a)+# define le64_to_cpu(a) bitfn_swap64(a)+# define cpu_to_le64(a) bitfn_swap64(a)+# define le32_to_cpu(a) bitfn_swap32(a)+# define cpu_to_le32(a) bitfn_swap32(a)++# define cpu_to_le32_array(d, s, l) array_swap32(d, s, l)+# define le32_to_cpu_array(d, s, l) array_swap32(d, s, l)+# define cpu_to_be32_array(d, s, l) array_copy32(d, s, l)+# define be32_to_cpu_array(d, s, l) array_copy32(d, s, l)++# define cpu_to_le64_array(d, s, l) array_swap64(d, s, l)+# define le64_to_cpu_array(d, s, l) array_swap64(d, s, l)+# define cpu_to_be64_array(d, s, l) array_copy64(d, s, l)+# define be64_to_cpu_array(d, s, l) array_copy64(d, s, l)++# define ror32_be(a, s) ror32(a, s)+# define rol32_be(a, s) rol32(a, s)++# define ARCH_IS_BIG_ENDIAN++#else+# error "endian not supported"+#endif++#endif /* !BITFN_H */
large-hashable.cabal view
@@ -1,106 +1,111 @@-name: large-hashable-version: 0.1.0.0-cabal-version: >=1.10-build-type: Simple-license: BSD3-license-file: LICENSE-copyright: 2015 - 2016 factis research GmbH-maintainer: Stefan Wehr <wehr@cp-med.com>-homepage: https://github.com/factisresearch/large-hashable-synopsis: Efficiently hash (large) Haskell values-description:- Please see README.md-category: Web-author: Stefan Wehr, Lukas Epple+name: large-hashable+version: 0.1.0.1+synopsis: Efficiently hash (large) Haskell values+description: Please see README.md+homepage: https://github.com/factisresearch/large-hashable+license: BSD3+license-file: LICENSE+author: Stefan Wehr, Lukas Epple+maintainer: Stefan Wehr <wehr@cp-med.com>+copyright: 2015 - 2016 factis research GmbH+category: Web+build-type: Simple+cabal-version: >=1.10 extra-source-files: cbits/md5.h+ cbits/bitfn.h README.md+ ChangeLog shell.nix stack.yaml -source-repository head- type: git- location: https://github.com/factisresearch/large-hashable- library- exposed-modules:- Data.LargeHashable- Data.LargeHashable.Class- Data.LargeHashable.MD5- Data.LargeHashable.Intern- Data.LargeHashable.LargeWord- Data.LargeHashable.TH- build-depends:- aeson >=0.11.2.0,- base >=4.8 && <5,- text >=1.2.2.1,- bytestring >=0.10.6.0,- transformers >=0.4.2.0,- base16-bytestring >=0.1.1.6,- bytes >=0.15.2,- containers >=0.5.6.2,- unordered-containers >=0.2.7.0,- scientific >=0.3.4.6,- strict >=0.3.2,- time >=1.5.0.1,- template-haskell >=2.10.0.0,- utf8-light >=0.4.2,- vector >=0.11.0.0,- void >=0.7.1- c-sources:- cbits/md5.c- default-language: Haskell2010- hs-source-dirs: src- ghc-options: -optc -O3 -fno-cse -W -fwarn-unused-imports -fwarn-unused-binds -fwarn-unused-matches -fwarn-unused-do-bind -fwarn-wrong-do-bind -pgmPcpphs -optP--cpp -fno-warn-name-shadowing -fwarn-missing-signatures -O2+ hs-source-dirs: src+ c-sources: cbits/md5.c+ exposed-modules: Data.LargeHashable+ , Data.LargeHashable.Class+ , Data.LargeHashable.MD5+ , Data.LargeHashable.Intern+ , Data.LargeHashable.LargeWord+ , Data.LargeHashable.TH+ build-depends: aeson+ , base >= 4.8 && < 5+ , text+ , bytestring+ , transformers+ , base16-bytestring+ , bytes+ , containers+ , unordered-containers+ , scientific+ , strict+ , time+ , template-haskell+ , utf8-light+ , vector+ , void+ default-language: Haskell2010+ ghc-options: -optc -O3 -fno-cse -W -fwarn-unused-imports -fwarn-unused-binds+ -fwarn-unused-matches -fwarn-unused-do-bind -fwarn-wrong-do-bind+ -pgmPcpphs -optP--cpp -fno-warn-name-shadowing+ -fwarn-missing-signatures -O2 +benchmark large-hashable-benchmark+ type: exitcode-stdio-1.0+ hs-source-dirs: benchmark+ main-is: Main.hs+ other-modules: Data.LargeHashable.Benchmarks.CryptoHash+ , Data.LargeHashable.Benchmarks.Main+ , Data.LargeHashable.Benchmarks.Serial+ ghc-options: -optc -O3 -fno-cse -threaded -rtsopts -with-rtsopts=-N+ -W -fwarn-unused-imports -fwarn-unused-binds+ -fwarn-unused-matches -fwarn-unused-do-bind -fwarn-wrong-do-bind+ -pgmPcpphs -optP--cpp -rtsopts -threaded -funbox-strict-fields+ -fwarn-missing-signatures -fno-warn-name-shadowing -O2+ build-depends: base >= 4.8 && < 5+ , base16-bytestring+ , large-hashable+ , safecopy+ , text+ , deepseq+ , cryptohash+ , bytestring+ , cereal+ , byteable+ , transformers+ , bytes+ default-language: Haskell2010+ test-suite large-hashable-test- type: exitcode-stdio-1.0- main-is: Main.hs- build-depends:- aeson >=0.11.2.0,- HTF >=0.13.1.0,- QuickCheck >=2.8.2,- base >=4.8 && <5,- bytes >=0.15.2,- bytestring >=0.10.6.0,- containers >=0.5.6.2,- hashable >=1.2.4.0,- large-hashable >=0.1.0.0,- scientific >=0.3.4.6,- strict >=0.3.2,- text >=1.2.2.1,- time >=1.5.0.1,- unordered-containers >=0.2.7.0,- vector >=0.11.0.0- default-language: Haskell2010- hs-source-dirs: test- other-modules:- Data.LargeHashable.Tests.Class- Data.LargeHashable.Tests.Helper- Data.LargeHashable.Tests.TH- Data.LargeHashable.Tests.LargeWord- ghc-options: -optc -O3 -fno-cse -threaded -rtsopts -with-rtsopts=-N -W -fwarn-unused-imports -fwarn-unused-binds -fwarn-unused-matches -fwarn-unused-do-bind -fwarn-wrong-do-bind -pgmPcpphs -optP--cpp -rtsopts -threaded -funbox-strict-fields -fwarn-missing-signatures -fno-warn-name-shadowing+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ main-is: Main.hs+ build-depends: aeson+ , HTF+ , QuickCheck+ , base >= 4.8 && < 5+ , bytes+ , bytestring+ , containers+ , hashable+ , large-hashable+ , scientific+ , strict+ , text+ , time+ , unordered-containers+ , vector+ ghc-options: -optc -O3 -fno-cse -threaded -rtsopts -with-rtsopts=-N+ -W -fwarn-unused-imports -fwarn-unused-binds+ -fwarn-unused-matches -fwarn-unused-do-bind -fwarn-wrong-do-bind+ -pgmPcpphs -optP--cpp -rtsopts -threaded -funbox-strict-fields+ -fwarn-missing-signatures -fno-warn-name-shadowing+ default-language: Haskell2010+ other-modules: Data.LargeHashable.Tests.Class+ , Data.LargeHashable.Tests.Helper+ , Data.LargeHashable.Tests.TH+ , Data.LargeHashable.Tests.LargeWord -benchmark large-hashable-benchmark- type: exitcode-stdio-1.0- main-is: Main.hs- build-depends:- base >=4.8 && <5,- base16-bytestring >=0.1.1.6,- large-hashable >=0.1.0.0,- safecopy >=0.9.0.1,- text >=1.2.2.1,- deepseq >=1.4.1.1,- cryptohash >=0.11.9,- bytestring >=0.10.6.0,- cereal >=0.5.1.0,- byteable >=0.1.1,- transformers >=0.4.2.0,- bytes >=0.15.2- default-language: Haskell2010- hs-source-dirs: benchmark- other-modules:- Data.LargeHashable.Benchmarks.CryptoHash- Data.LargeHashable.Benchmarks.Main- Data.LargeHashable.Benchmarks.Serial- ghc-options: -optc -O3 -fno-cse -threaded -rtsopts -with-rtsopts=-N -W -fwarn-unused-imports -fwarn-unused-binds -fwarn-unused-matches -fwarn-unused-do-bind -fwarn-wrong-do-bind -pgmPcpphs -optP--cpp -rtsopts -threaded -funbox-strict-fields -fwarn-missing-signatures -fno-warn-name-shadowing -O2+source-repository head+ type: git+ location: https://github.com/factisresearch/large-hashable