X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FSpookyHashV1.h;h=bb457d5f80f3ac24fa41cabf59c3039a81a4e0d6;hb=d9acfc9e4d3f94c3470df9b45c7f0b6c172e8c23;hp=6d32c70995cf7a42b0c01f5d5bf9003734d761aa;hpb=22afce906d7e98d95f8c45c3301072d9fd891d41;p=folly.git diff --git a/folly/SpookyHashV1.h b/folly/SpookyHashV1.h index 6d32c709..bb457d5f 100644 --- a/folly/SpookyHashV1.h +++ b/folly/SpookyHashV1.h @@ -1,5 +1,5 @@ /* - * Copyright 2014 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,8 +42,7 @@ // slower than MD5. // -#ifndef FOLLY_SPOOKYHASHV1_H_ -#define FOLLY_SPOOKYHASHV1_H_ +#pragma once #include #include @@ -143,18 +142,18 @@ public: uint64_t &s4, uint64_t &s5, uint64_t &s6, uint64_t &s7, uint64_t &s8, uint64_t &s9, uint64_t &s10,uint64_t &s11) { - s0 += data[0]; s2 ^= s10; s11 ^= s0; s0 = Rot64(s0,11); s11 += s1; - s1 += data[1]; s3 ^= s11; s0 ^= s1; s1 = Rot64(s1,32); s0 += s2; - s2 += data[2]; s4 ^= s0; s1 ^= s2; s2 = Rot64(s2,43); s1 += s3; - s3 += data[3]; s5 ^= s1; s2 ^= s3; s3 = Rot64(s3,31); s2 += s4; - s4 += data[4]; s6 ^= s2; s3 ^= s4; s4 = Rot64(s4,17); s3 += s5; - s5 += data[5]; s7 ^= s3; s4 ^= s5; s5 = Rot64(s5,28); s4 += s6; - s6 += data[6]; s8 ^= s4; s5 ^= s6; s6 = Rot64(s6,39); s5 += s7; - s7 += data[7]; s9 ^= s5; s6 ^= s7; s7 = Rot64(s7,57); s6 += s8; - s8 += data[8]; s10 ^= s6; s7 ^= s8; s8 = Rot64(s8,55); s7 += s9; - s9 += data[9]; s11 ^= s7; s8 ^= s9; s9 = Rot64(s9,54); s8 += s10; - s10 += data[10]; s0 ^= s8; s9 ^= s10; s10 = Rot64(s10,22); s9 += s11; - s11 += data[11]; s1 ^= s9; s10 ^= s11; s11 = Rot64(s11,46); s10 += s0; + s0 += data[0]; s2 ^= s10; s11 ^= s0; s0 = Rot64(s0,11); s11 += s1; + s1 += data[1]; s3 ^= s11; s0 ^= s1; s1 = Rot64(s1,32); s0 += s2; + s2 += data[2]; s4 ^= s0; s1 ^= s2; s2 = Rot64(s2,43); s1 += s3; + s3 += data[3]; s5 ^= s1; s2 ^= s3; s3 = Rot64(s3,31); s2 += s4; + s4 += data[4]; s6 ^= s2; s3 ^= s4; s4 = Rot64(s4,17); s3 += s5; + s5 += data[5]; s7 ^= s3; s4 ^= s5; s5 = Rot64(s5,28); s4 += s6; + s6 += data[6]; s8 ^= s4; s5 ^= s6; s6 = Rot64(s6,39); s5 += s7; + s7 += data[7]; s9 ^= s5; s6 ^= s7; s7 = Rot64(s7,57); s6 += s8; + s8 += data[8]; s10 ^= s6; s7 ^= s8; s8 = Rot64(s8,55); s7 += s9; + s9 += data[9]; s11 ^= s7; s8 ^= s9; s9 = Rot64(s9,54); s8 += s10; + s10 += data[10]; s0 ^= s8; s9 ^= s10; s10 = Rot64(s10,22); s9 += s11; + s11 += data[11]; s1 ^= s9; s10 ^= s11; s11 = Rot64(s11,46); s10 += s0; } // @@ -217,7 +216,8 @@ public: // with diffs defined by either xor or subtraction // with a base of all zeros plus a counter, or plus another bit, or random // - static inline void ShortMix(uint64_t &h0, uint64_t &h1, uint64_t &h2, uint64_t &h3) + static inline void ShortMix(uint64_t &h0, uint64_t &h1, + uint64_t &h2, uint64_t &h3) { h2 = Rot64(h2,50); h2 += h3; h0 ^= h2; h3 = Rot64(h3,52); h3 += h0; h1 ^= h3; @@ -245,7 +245,8 @@ public: // For every pair of input bits, // with probability 50 +- .75% (the worst case is approximately that) // - static inline void ShortEnd(uint64_t &h0, uint64_t &h1, uint64_t &h2, uint64_t &h3) + static inline void ShortEnd(uint64_t &h0, uint64_t &h1, + uint64_t &h2, uint64_t &h3) { h3 ^= h2; h2 = Rot64(h2,15); h3 += h2; h0 ^= h3; h3 = Rot64(h3,52); h0 += h3; @@ -269,7 +270,7 @@ private: // held to the same quality bar. // static void Short( - const void *message, // message (array of bytes, not necessarily aligned) + const void *message, // message (byte array, not necessarily aligned) size_t length, // length of message (in bytes) uint64_t *hash1, // in/out: in the seed, out the hash value uint64_t *hash2); // in/out: in the seed, out the hash value @@ -290,7 +291,7 @@ private: // * is a not-very-regular mix of 1's and 0's // * does not need any other special mathematical properties // - static const uint64_t sc_const = 0xdeadbeefdeadbeefLL; + static const uint64_t sc_const = 0xdeadbeefdeadbeefULL; uint64_t m_data[2*sc_numVars]; // unhashed data, for partial messages uint64_t m_state[sc_numVars]; // internal state of the hash @@ -300,5 +301,3 @@ private: } // namespace hash } // namespace folly - -#endif