-#define ROTL_UV(x,r) ROTL32(x,r)
-#endif
-
-/* This is SipHash by Jean-Philippe Aumasson and Daniel J. Bernstein.
- * The authors claim it is relatively secure compared to the alternatives
- * and that performance wise it is a suitable hash for languages like Perl.
- * See:
- *
- * https://www.131002.net/siphash/
- *
- * This implementation seems to perform slightly slower than one-at-a-time for
- * short keys, but degrades slower for longer keys. Murmur Hash outperforms it
- * regardless of keys size.
- *
- * It is 64 bit only.
- */
-
-#ifdef HAS_QUAD
-
-#define U8TO64_LE(p) \
- (((U64TYPE)((p)[0]) ) | \
- ((U64TYPE)((p)[1]) << 8) | \
- ((U64TYPE)((p)[2]) << 16) | \
- ((U64TYPE)((p)[3]) << 24) | \
- ((U64TYPE)((p)[4]) << 32) | \
- ((U64TYPE)((p)[5]) << 40) | \
- ((U64TYPE)((p)[6]) << 48) | \
- ((U64TYPE)((p)[7]) << 56))
-
-#define SIPROUND \
- do { \
- v0 += v1; v1=ROTL64(v1,13); v1 ^= v0; v0=ROTL64(v0,32); \
- v2 += v3; v3=ROTL64(v3,16); v3 ^= v2; \
- v0 += v3; v3=ROTL64(v3,21); v3 ^= v0; \
- v2 += v1; v1=ROTL64(v1,17); v1 ^= v2; v2=ROTL64(v2,32); \
- } while(0)
-
-/* SipHash-2-4 */
-
-PERL_STATIC_INLINE U32
-S_perl_hash_siphash_2_4(const unsigned char * const seed, const unsigned char *in, const STRLEN inlen) {
- /* "somepseudorandomlygeneratedbytes" */
- U64TYPE v0 = UINT64_C(0x736f6d6570736575);
- U64TYPE v1 = UINT64_C(0x646f72616e646f6d);
- U64TYPE v2 = UINT64_C(0x6c7967656e657261);
- U64TYPE v3 = UINT64_C(0x7465646279746573);
-
- U64TYPE b;
- U64TYPE k0 = ((U64TYPE*)seed)[0];
- U64TYPE k1 = ((U64TYPE*)seed)[1];
- U64TYPE m;
- const int left = inlen & 7;
- const U8 *end = in + inlen - left;
-
- b = ( ( U64TYPE )(inlen) ) << 56;
- v3 ^= k1;
- v2 ^= k0;
- v1 ^= k1;
- v0 ^= k0;
-
- for ( ; in != end; in += 8 )
- {
- m = U8TO64_LE( in );
- v3 ^= m;
- SIPROUND;
- SIPROUND;
- v0 ^= m;
- }
-
- switch( left )
- {
- case 7: b |= ( ( U64TYPE )in[ 6] ) << 48;
- case 6: b |= ( ( U64TYPE )in[ 5] ) << 40;
- case 5: b |= ( ( U64TYPE )in[ 4] ) << 32;
- case 4: b |= ( ( U64TYPE )in[ 3] ) << 24;
- case 3: b |= ( ( U64TYPE )in[ 2] ) << 16;
- case 2: b |= ( ( U64TYPE )in[ 1] ) << 8;
- case 1: b |= ( ( U64TYPE )in[ 0] ); break;
- case 0: break;
- }
-
- v3 ^= b;
- SIPROUND;
- SIPROUND;
- v0 ^= b;
-
- v2 ^= 0xff;
- SIPROUND;
- SIPROUND;
- SIPROUND;
- SIPROUND;
- b = v0 ^ v1 ^ v2 ^ v3;
- return (U32)(b & U32_MAX);
-}
-#endif /* defined(HAS_QUAD) */
-
-/* FYI: This is the "Super-Fast" algorithm mentioned by Bob Jenkins in
- * (http://burtleburtle.net/bob/hash/doobs.html)
- * It is by Paul Hsieh (c) 2004 and is analysed here
- * http://www.azillionmonkeys.com/qed/hash.html
- * license terms are here:
- * http://www.azillionmonkeys.com/qed/weblicense.html
- */
-
-
-PERL_STATIC_INLINE U32
-S_perl_hash_superfast(const unsigned char * const seed, const unsigned char *str, STRLEN len) {
- U32 hash = *((U32*)seed) + (U32)len;
- U32 tmp;
- int rem= len & 3;
- len >>= 2;
-
- for (;len > 0; len--) {
- hash += U8TO16_LE (str);
- tmp = (U8TO16_LE (str+2) << 11) ^ hash;
- hash = (hash << 16) ^ tmp;
- str += 2 * sizeof (U16);
- hash += hash >> 11;
- }
-
- /* Handle end cases */
- switch (rem) { \
- case 3: hash += U8TO16_LE (str);
- hash ^= hash << 16;
- hash ^= str[sizeof (U16)] << 18;
- hash += hash >> 11;
- break;
- case 2: hash += U8TO16_LE (str);
- hash ^= hash << 11;
- hash += hash >> 17;
- break;
- case 1: hash += *str;
- hash ^= hash << 10;
- hash += hash >> 1;
- }
- /* Force "avalanching" of final 127 bits */
- hash ^= hash << 3;
- hash += hash >> 5;
- hash ^= hash << 4;
- hash += hash >> 17;
- hash ^= hash << 25;
- return (hash + (hash >> 6));
-}
-
-
-/*-----------------------------------------------------------------------------
- * MurmurHash3 was written by Austin Appleby, and is placed in the public
- * domain.
- *
- * This implementation was originally written by Shane Day, and is also public domain,
- * and was modified to function as a macro similar to other perl hash functions by
- * Yves Orton.
- *
- * This is a portable ANSI C implementation of MurmurHash3_x86_32 (Murmur3A)
- * with support for progressive processing.
- *
- * If you want to understand the MurmurHash algorithm you would be much better
- * off reading the original source. Just point your browser at:
- * http://code.google.com/p/smhasher/source/browse/trunk/MurmurHash3.cpp
- *
- * How does it work?
- *
- * We can only process entire 32 bit chunks of input, except for the very end
- * that may be shorter.
- *
- * To handle endianess I simply use a macro that reads a U32 and define
- * that macro to be a direct read on little endian machines, a read and swap
- * on big endian machines, or a byte-by-byte read if the endianess is unknown.
- */