diff --git a/hashes/beamsplitter.cpp b/hashes/beamsplitter.cpp index 3368b55a..7cea0418 100644 --- a/hashes/beamsplitter.cpp +++ b/hashes/beamsplitter.cpp @@ -311,8 +311,8 @@ static FORCE_INLINE uint64_t beam_ROTR64( uint64_t v, int n ) { static FORCE_INLINE void mix( uint64_t * state, const uint32_t A ) { const uint32_t B = A + 1; - const uint32_t iv = state[A ] & 1023; - const uint64_t M = T [iv]; + const uint32_t iv = state[A] & 1023; + const uint64_t M = T[iv]; state[B] += state[A] + M; @@ -416,7 +416,7 @@ static void beamsplitter_64( const void * in, const size_t len, const seed_t see h[0] = state[2]; h[1] = state[3]; - h[0] += h [1]; + h[0] += h[1]; PUT_U64(h[0], (uint8_t *)out, 0); } diff --git a/hashes/blake2.cpp b/hashes/blake2.cpp index 54fa96f2..04a7c844 100644 --- a/hashes/blake2.cpp +++ b/hashes/blake2.cpp @@ -52,7 +52,7 @@ static const uint8_t blake2_sigma[12][16] = { { 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 }, { 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 }, { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 }, - { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 }, + { 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 }, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, { 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 } }; diff --git a/hashes/blake3.cpp b/hashes/blake3.cpp index 29484843..397c4621 100644 --- a/hashes/blake3.cpp +++ b/hashes/blake3.cpp @@ -173,7 +173,7 @@ static FORCE_INLINE size_t chunk_state_fill_buf( blake3_chunk_state * self, cons if (take > input_len) { take = input_len; } - uint8_t * dest = self->buf + ((size_t)self->buf_len); + uint8_t * dest = self->buf + ((size_t)self->buf_len); memcpy(dest, input, take); self->buf_len += (uint8_t)take; return take; @@ -451,8 +451,7 @@ static FORCE_INLINE void compress_subtree_to_parent_node( const uint8_t * input, // warnings here. GCC 8.5 is particularly sensitive, so if you're changing // this code, test it against that version. while (num_cvs > 2 && num_cvs <= SIMD_DEGREE_OR_2) { - num_cvs = - compress_parents_parallel(cv_array, num_cvs, key, flags, out_array); + num_cvs = compress_parents_parallel(cv_array, num_cvs, key, flags, out_array); memcpy(cv_array, out_array, num_cvs * BLAKE3_OUT_LEN); } memcpy(out, cv_array, 2 * BLAKE3_OUT_LEN); diff --git a/hashes/blake3/compress-portable.h b/hashes/blake3/compress-portable.h index 2f620f22..ad698da0 100644 --- a/hashes/blake3/compress-portable.h +++ b/hashes/blake3/compress-portable.h @@ -17,13 +17,13 @@ static FORCE_INLINE void round_fn( uint32_t state[16], const uint32_t * msg, siz const uint8_t * schedule = MSG_SCHEDULE[round]; // Mix the columns. - g(state, 0, 4, 8, 12, msg[schedule[0]] , msg[schedule[1]] ); - g(state, 1, 5, 9, 13, msg[schedule[2]] , msg[schedule[3]] ); - g(state, 2, 6, 10, 14, msg[schedule[4]] , msg[schedule[5]] ); - g(state, 3, 7, 11, 15, msg[schedule[6]] , msg[schedule[7]] ); + g(state, 0, 4, 8, 12, msg[schedule[ 0]], msg[schedule[ 1]]); + g(state, 1, 5, 9, 13, msg[schedule[ 2]], msg[schedule[ 3]]); + g(state, 2, 6, 10, 14, msg[schedule[ 4]], msg[schedule[ 5]]); + g(state, 3, 7, 11, 15, msg[schedule[ 6]], msg[schedule[ 7]]); // Mix the rows. - g(state, 0, 5, 10, 15, msg[schedule[8]] , msg[schedule[9]] ); + g(state, 0, 5, 10, 15, msg[schedule[ 8]], msg[schedule[ 9]]); g(state, 1, 6, 11, 12, msg[schedule[10]], msg[schedule[11]]); g(state, 2, 7, 8, 13, msg[schedule[12]], msg[schedule[13]]); g(state, 3, 4, 9, 14, msg[schedule[14]], msg[schedule[15]]); @@ -57,22 +57,22 @@ static FORCE_INLINE void compress_pre( uint32_t state[16], const uint32_t cv[8], block_words[14] = load32(block + 4 * 14); block_words[15] = load32(block + 4 * 15); - state[ 0] = cv[0 ]; - state[ 1] = cv[1 ]; - state[ 2] = cv[2 ]; - state[ 3] = cv[3 ]; - state[ 4] = cv[4 ]; - state[ 5] = cv[5 ]; - state[ 6] = cv[6 ]; - state[ 7] = cv[7 ]; - state[ 8] = IV[0 ]; - state[ 9] = IV[1 ]; - state[10] = IV[2 ]; - state[11] = IV[3 ]; + state[ 0] = cv[0]; + state[ 1] = cv[1]; + state[ 2] = cv[2]; + state[ 3] = cv[3]; + state[ 4] = cv[4]; + state[ 5] = cv[5]; + state[ 6] = cv[6]; + state[ 7] = cv[7]; + state[ 8] = IV[0]; + state[ 9] = IV[1]; + state[10] = IV[2]; + state[11] = IV[3]; state[12] = counter_low(counter); state[13] = counter_high(counter); - state[14] = (uint32_t)block_len; - state[15] = (uint32_t)flags; + state[14] = (uint32_t)block_len; + state[15] = (uint32_t)flags; round_fn(state, &block_words[0], 0); round_fn(state, &block_words[0], 1); @@ -104,22 +104,22 @@ static void blake3_compress_xof( const uint32_t cv[8], const uint8_t block[BLAKE compress_pre(state, cv, block, block_len, counter, flags); - store32(&out[0 * 4] , state[0] ^ state[8] ); - store32(&out[1 * 4] , state[1] ^ state[9] ); - store32(&out[2 * 4] , state[2] ^ state[10]); - store32(&out[3 * 4] , state[3] ^ state[11]); - store32(&out[4 * 4] , state[4] ^ state[12]); - store32(&out[5 * 4] , state[5] ^ state[13]); - store32(&out[6 * 4] , state[6] ^ state[14]); - store32(&out[7 * 4] , state[7] ^ state[15]); - store32(&out[8 * 4] , state[8] ^ cv[0] ); - store32(&out[9 * 4] , state[9] ^ cv[1] ); - store32(&out[10 * 4], state[10] ^ cv[2] ); - store32(&out[11 * 4], state[11] ^ cv[3] ); - store32(&out[12 * 4], state[12] ^ cv[4] ); - store32(&out[13 * 4], state[13] ^ cv[5] ); - store32(&out[14 * 4], state[14] ^ cv[6] ); - store32(&out[15 * 4], state[15] ^ cv[7] ); + store32(&out[ 0 * 4], state[ 0] ^ state[ 8]); + store32(&out[ 1 * 4], state[ 1] ^ state[ 9]); + store32(&out[ 2 * 4], state[ 2] ^ state[10]); + store32(&out[ 3 * 4], state[ 3] ^ state[11]); + store32(&out[ 4 * 4], state[ 4] ^ state[12]); + store32(&out[ 5 * 4], state[ 5] ^ state[13]); + store32(&out[ 6 * 4], state[ 6] ^ state[14]); + store32(&out[ 7 * 4], state[ 7] ^ state[15]); + store32(&out[ 8 * 4], state[ 8] ^ cv[0] ); + store32(&out[ 9 * 4], state[ 9] ^ cv[1] ); + store32(&out[10 * 4], state[10] ^ cv[2] ); + store32(&out[11 * 4], state[11] ^ cv[3] ); + store32(&out[12 * 4], state[12] ^ cv[4] ); + store32(&out[13 * 4], state[13] ^ cv[5] ); + store32(&out[14 * 4], state[14] ^ cv[6] ); + store32(&out[15 * 4], state[15] ^ cv[7] ); } static FORCE_INLINE void hash_one( const uint8_t * input, size_t blocks, const uint32_t key[8], uint64_t counter, diff --git a/hashes/blake3/compress-sse2.h b/hashes/blake3/compress-sse2.h index f2525c49..f1685c23 100644 --- a/hashes/blake3/compress-sse2.h +++ b/hashes/blake3/compress-sse2.h @@ -430,9 +430,9 @@ static FORCE_INLINE void transpose_msg_vecs( const uint8_t * const * inputs, siz for (size_t i = 0; i < 4; ++i) { _mm_prefetch((const void *)&inputs[i][block_offset + 256], _MM_HINT_T0); } - transpose_vecs(&out[0] ); - transpose_vecs(&out[4] ); - transpose_vecs(&out[8] ); + transpose_vecs(&out[ 0]); + transpose_vecs(&out[ 4]); + transpose_vecs(&out[ 8]); transpose_vecs(&out[12]); } @@ -443,7 +443,7 @@ static FORCE_INLINE void load_counters( uint64_t counter, bool increment_counter __m128i l = _mm_add_epi32(_mm_set1_epi32((int32_t)counter), add1); __m128i carry = _mm_cmpgt_epi32(_mm_xor_si128(add1, _mm_set1_epi32( 0x80000000)), _mm_xor_si128(l, _mm_set1_epi32(0x80000000))); - __m128i h = _mm_sub_epi32(_mm_set1_epi32( (int32_t)(counter >> 32)), carry); + __m128i h = _mm_sub_epi32(_mm_set1_epi32((int32_t)(counter >> 32)), carry); *out_lo = l; *out_hi = h; diff --git a/hashes/blake3/compress-sse41.h b/hashes/blake3/compress-sse41.h index a379e5ae..6b0378a7 100644 --- a/hashes/blake3/compress-sse41.h +++ b/hashes/blake3/compress-sse41.h @@ -258,7 +258,7 @@ static void blake3_compress_xof( const uint32_t cv[8], const uint8_t block[BLAKE __m128i rows[4]; compress_pre(rows, cv, block, block_len, counter, flags); - storeu(xorv(rows[0], rows[2]), &out[0] ); + storeu(xorv(rows[0], rows[2]), &out[ 0]); storeu(xorv(rows[1], rows[3]), &out[16]); storeu(xorv(rows[2], loadu((uint8_t *)&cv[0])), &out[32]); storeu(xorv(rows[3], loadu((uint8_t *)&cv[4])), &out[48]); @@ -421,9 +421,9 @@ static FORCE_INLINE void transpose_msg_vecs( const uint8_t * const * inputs, siz for (size_t i = 0; i < 4; ++i) { _mm_prefetch((const void *)&inputs[i][block_offset + 256], _MM_HINT_T0); } - transpose_vecs(&out[0] ); - transpose_vecs(&out[4] ); - transpose_vecs(&out[8] ); + transpose_vecs(&out[ 0]); + transpose_vecs(&out[ 4]); + transpose_vecs(&out[ 8]); transpose_vecs(&out[12]); } @@ -434,7 +434,7 @@ static FORCE_INLINE void load_counters( uint64_t counter, bool increment_counter __m128i l = _mm_add_epi32(_mm_set1_epi32((int32_t)counter), add1); __m128i carry = _mm_cmpgt_epi32(_mm_xor_si128(add1, _mm_set1_epi32( 0x80000000)), _mm_xor_si128(l, _mm_set1_epi32(0x80000000))); - __m128i h = _mm_sub_epi32(_mm_set1_epi32( (int32_t)(counter >> 32)), carry); + __m128i h = _mm_sub_epi32(_mm_set1_epi32((int32_t)(counter >> 32)), carry); *out_lo = l; *out_hi = h; diff --git a/hashes/blockpearson.cpp b/hashes/blockpearson.cpp index 41eb3b95..4835570e 100644 --- a/hashes/blockpearson.cpp +++ b/hashes/blockpearson.cpp @@ -64,8 +64,8 @@ template static void blockpearson_hash_256( const void * in, const size_t org_len, const seed_t seed, void * out ) { const uint8_t * current = (const uint8_t *)in; - uint64_t len = (uint64_t )org_len; - uint64_t hash1 = (uint64_t )seed; + uint64_t len = (uint64_t)org_len; + uint64_t hash1 = (uint64_t)seed; permute64(hash1); @@ -121,8 +121,8 @@ template static void blockpearson_hash_128( const void * in, const size_t org_len, const seed_t seed, void * out ) { const uint8_t * current = (const uint8_t *)in; - uint64_t len = (uint64_t )org_len; - uint64_t hash1 = (uint64_t )seed; + uint64_t len = (uint64_t)org_len; + uint64_t hash1 = (uint64_t)seed; permute64(hash1); @@ -164,8 +164,8 @@ template static void blockpearson_hash_64( const void * in, const size_t org_len, const seed_t seed, void * out ) { const uint8_t * current = (const uint8_t *)in; - uint64_t len = (uint64_t )org_len; - uint64_t hash1 = (uint64_t )seed; + uint64_t len = (uint64_t)org_len; + uint64_t hash1 = (uint64_t)seed; permute64(hash1); diff --git a/hashes/cityhash.cpp b/hashes/cityhash.cpp index ef5ea564..5605b3d3 100644 --- a/hashes/cityhash.cpp +++ b/hashes/cityhash.cpp @@ -178,11 +178,11 @@ static uint32_t Hash32Len5to12( const uint8_t * s, size_t len, uint32_t seed ) { template static uint32_t Hash32Len13to24( const uint8_t * s, size_t len, uint32_t seed ) { uint32_t a = Fetch32(s - 4 + (len >> 1)); - uint32_t b = Fetch32(s + 4); - uint32_t c = Fetch32(s + len - 8); + uint32_t b = Fetch32(s + 4 ); + uint32_t c = Fetch32(s + len - 8 ); uint32_t d = Fetch32(s + (len >> 1)); - uint32_t e = Fetch32(s); - uint32_t f = Fetch32(s + len - 4); + uint32_t e = Fetch32(s ); + uint32_t f = Fetch32(s + len - 4 ); uint32_t h = seed + len; return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h))))))); @@ -287,8 +287,8 @@ static uint64_t HashLen0to16( const uint8_t * s, size_t len ) { // in that case. template static uint64_t HashLen17to32( const uint8_t * s, size_t len ) { - uint64_t a = Fetch64(s ) * k1; - uint64_t b = Fetch64(s + 8); + uint64_t a = Fetch64(s ) * k1; + uint64_t b = Fetch64(s + 8 ); uint64_t c = Fetch64(s + len - 8) * k2; uint64_t d = Fetch64(s + len - 16) * k0; @@ -303,7 +303,7 @@ static uint64_t HashLen33to64( const uint8_t * s, size_t len ) { uint64_t b = ROTR64(a + z, 52); uint64_t c = ROTR64(a , 37); - a += Fetch64(s + 8); + a += Fetch64(s + 8 ); c += ROTR64(a, 7); a += Fetch64(s + 16 ); uint64_t vf = a + z; @@ -346,7 +346,7 @@ static uint64_t CityHash64( const uint8_t * s, size_t len ) { len = (len - 1) & ~static_cast(63); do { x = ROTR64(x + y + v.first + Fetch64(s + 8), 37) * k1; - y = ROTR64(y + v.second + Fetch64 (s + 48), 42) * k1; + y = ROTR64(y + v.second + Fetch64(s + 48), 42) * k1; x ^= w.second; y += v.first + Fetch64(s + 40); z = ROTR64(z + w.first, 33) * k1; @@ -422,7 +422,7 @@ static uint128_t CityHash128WithSeed( const uint8_t * s, size_t len, uint128_t s // This is the same inner loop as CityHash64(), manually unrolled. do { x = ROTR64(x + y + v.first + Fetch64(s + 8), 37) * k1; - y = ROTR64(y + v.second + Fetch64 (s + 48), 42) * k1; + y = ROTR64(y + v.second + Fetch64(s + 48), 42) * k1; x ^= w.second; y += v.first + Fetch64(s + 40); z = ROTR64(z + w.first, 33) * k1; @@ -447,9 +447,9 @@ static uint128_t CityHash128WithSeed( const uint8_t * s, size_t len, uint128_t s for (size_t tail_done = 0; tail_done < len;) { tail_done += 32; y = ROTR64(x + y, 42) * k0 + v.second; - w.first += Fetch64 (s + len - tail_done + 16); + w.first += Fetch64(s + len - tail_done + 16); x = x * k0 + w.first; - z += w.second + Fetch64 (s + len - tail_done); + z += w.second + Fetch64(s + len - tail_done); w.second += v.first; v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second); } @@ -543,11 +543,11 @@ static void CityHashCrc256Long( const uint8_t * s, size_t len, uint64_t seed, ui // result[0] = e + f + g + h; a = ShiftMix((a + g) * k0) * k0 + b; - result[1] += a + result[0 ]; + result[1] += a + result[0]; a = ShiftMix(a * k0) * k0 + c; - result[2] = a + result[1 ]; + result[2] = a + result[1]; a = ShiftMix((a + e) * k0) * k0; - result[3] = a + result[2 ]; + result[3] = a + result[2]; } // Requires len < 240. diff --git a/hashes/crc.cpp b/hashes/crc.cpp index 8d29688f..79a2821b 100644 --- a/hashes/crc.cpp +++ b/hashes/crc.cpp @@ -283,40 +283,40 @@ static uint32_t crc32_sw( uint32_t crci, const crc_sw_table crc32_table, const v crc ^= wd1; if (bswap) { crc = - crc32_table[15][crc & 0xff] ^ + crc32_table[15][ crc & 0xff] ^ crc32_table[14][(crc >> 8) & 0xff] ^ crc32_table[13][(crc >> 16) & 0xff] ^ crc32_table[12][(crc >> 24) & 0xff] ^ crc32_table[11][(crc >> 32) & 0xff] ^ crc32_table[10][(crc >> 40) & 0xff] ^ crc32_table[ 9][(crc >> 48) & 0xff] ^ - crc32_table[ 8][crc >> 56] ^ - crc32_table[ 0][wd2 & 0xff] ^ + crc32_table[ 8][ crc >> 56 ] ^ + crc32_table[ 0][ wd2 & 0xff] ^ crc32_table[ 1][(wd2 >> 8) & 0xff] ^ crc32_table[ 2][(wd2 >> 16) & 0xff] ^ crc32_table[ 3][(wd2 >> 24) & 0xff] ^ crc32_table[ 4][(wd2 >> 32) & 0xff] ^ crc32_table[ 5][(wd2 >> 40) & 0xff] ^ crc32_table[ 6][(wd2 >> 48) & 0xff] ^ - crc32_table[ 7][wd2 >> 56]; + crc32_table[ 7][ wd2 >> 56 ]; } else { crc = - crc32_table[15][crc & 0xff] ^ + crc32_table[15][ crc & 0xff] ^ crc32_table[14][(crc >> 8) & 0xff] ^ crc32_table[13][(crc >> 16) & 0xff] ^ crc32_table[12][(crc >> 24) & 0xff] ^ crc32_table[11][(crc >> 32) & 0xff] ^ crc32_table[10][(crc >> 40) & 0xff] ^ crc32_table[ 9][(crc >> 48) & 0xff] ^ - crc32_table[ 8][crc >> 56] ^ - crc32_table[ 7][wd2 & 0xff] ^ + crc32_table[ 8][ crc >> 56 ] ^ + crc32_table[ 7][ wd2 & 0xff] ^ crc32_table[ 6][(wd2 >> 8) & 0xff] ^ crc32_table[ 5][(wd2 >> 16) & 0xff] ^ crc32_table[ 4][(wd2 >> 24) & 0xff] ^ crc32_table[ 3][(wd2 >> 32) & 0xff] ^ crc32_table[ 2][(wd2 >> 40) & 0xff] ^ crc32_table[ 1][(wd2 >> 48) & 0xff] ^ - crc32_table[ 0][wd2 >> 56]; + crc32_table[ 0][ wd2 >> 56 ]; } next += 16; len -= 16; @@ -397,7 +397,7 @@ REGISTER_HASH(CRC_32C, $.bits = 32, $.verification_LE = 0x6E6071BD, $.verification_BE = 0x6E6071BD, - $.initfn = CRC32_init, + $.initfn = CRC32_init, $.hashfn_native = CRC32, $.hashfn_bswap = CRC32 ); diff --git a/hashes/discohash.cpp b/hashes/discohash.cpp index 5bbae08e..54e99944 100644 --- a/hashes/discohash.cpp +++ b/hashes/discohash.cpp @@ -172,9 +172,9 @@ static void BEBB4185( const void * in, const size_t len, const seed_t seed, void // variable. The mixing of the state with itself also doesn't need // bswap set, because the endianness of the data will naturally // always match the endianness of the ds[] values. - round(ds, key8Arr , (uint32_t)len); - round(ds, (uint8_t *)seedbuf, 16 ); - round( ds, (uint8_t *)ds, STATE ); + round(ds, key8Arr , (uint32_t)len); + round(ds, (uint8_t *)seedbuf, 16); + round(ds, (uint8_t *)ds , STATE ); /* * diff --git a/hashes/farmhash.cpp b/hashes/farmhash.cpp index 6ed0b455..89396637 100644 --- a/hashes/farmhash.cpp +++ b/hashes/farmhash.cpp @@ -265,8 +265,8 @@ static inline uint64_t farmhashna::HashLen0to16( const uint8_t * s, size_t len ) template static inline uint64_t farmhashna::HashLen17to32( const uint8_t * s, size_t len ) { uint64_t mul = k2 + len * 2; - uint64_t a = Fetch64(s ) * k1; - uint64_t b = Fetch64(s + 8); + uint64_t a = Fetch64(s ) * k1; + uint64_t b = Fetch64(s + 8 ); uint64_t c = Fetch64(s + len - 8) * mul; uint64_t d = Fetch64(s + len - 16) * k2; @@ -277,14 +277,14 @@ static inline uint64_t farmhashna::HashLen17to32( const uint8_t * s, size_t len template static inline uint64_t farmhashna::HashLen33to64( const uint8_t * s, size_t len ) { uint64_t mul = k2 + len * 2; - uint64_t a = Fetch64(s ) * k2; - uint64_t b = Fetch64(s + 8); + uint64_t a = Fetch64(s ) * k2; + uint64_t b = Fetch64(s + 8 ); uint64_t c = Fetch64(s + len - 8) * mul; uint64_t d = Fetch64(s + len - 16) * k2; uint64_t y = ROTR64(a + b, 43) + ROTR64(c, 30) + d; uint64_t z = HashLen16(y, a + ROTR64(b + k2, 18) + c, mul); - uint64_t e = Fetch64(s + 16) * mul; - uint64_t f = Fetch64(s + 24); + uint64_t e = Fetch64(s + 16 ) * mul; + uint64_t f = Fetch64(s + 24 ); uint64_t g = (y + Fetch64(s + len - 32)) * mul; uint64_t h = (z + Fetch64(s + len - 24)) * mul; @@ -320,7 +320,7 @@ static uint64_t farmhashna::Hash64( const uint8_t * s, size_t len ) { assert(s + len - 64 == last64); do { x = ROTR64(x + y + v.first + Fetch64(s + 8), 37) * k1; - y = ROTR64(y + v.second + Fetch64 (s + 48), 42) * k1; + y = ROTR64(y + v.second + Fetch64(s + 48), 42) * k1; x ^= w.second; y += v.first + Fetch64(s + 40); z = ROTR64(z + w.first, 33) * k1; @@ -336,7 +336,7 @@ static uint64_t farmhashna::Hash64( const uint8_t * s, size_t len ) { v.first += w.first; w.first += v.first; x = ROTR64(x + y + v.first + Fetch64(s + 8), 37) * mul; - y = ROTR64(y + v.second + Fetch64 (s + 48), 42) * mul; + y = ROTR64(y + v.second + Fetch64(s + 48), 42) * mul; x ^= w.second * 9; y += v.first * 9 + Fetch64(s + 40); z = ROTR64(z + w.first, 33) * mul; @@ -503,8 +503,8 @@ namespace farmhashxo { template static inline uint64_t farmhashxo::H32( const uint8_t * s, size_t len, uint64_t mul, uint64_t seed0, uint64_t seed1 ) { - uint64_t a = Fetch64(s ) * k1; - uint64_t b = Fetch64(s + 8); + uint64_t a = Fetch64(s ) * k1; + uint64_t b = Fetch64(s + 8 ); uint64_t c = Fetch64(s + len - 8) * mul; uint64_t d = Fetch64(s + len - 16) * k2; uint64_t u = ROTR64(a + b, 43) + ROTR64(c, 30) + d + seed0; @@ -531,8 +531,8 @@ template static inline uint64_t farmhashxo::HashLen65to96( const uint8_t * s, size_t len ) { uint64_t mul0 = k2 - 114; uint64_t mul1 = k2 - 114 + 2 * len; - uint64_t h0 = H32(s , 32, mul0); - uint64_t h1 = H32(s + 32, 32, mul1); + uint64_t h0 = H32(s , 32, mul0); + uint64_t h1 = H32(s + 32 , 32, mul1); uint64_t h2 = H32(s + len - 32, 32, mul1, h0, h1); return (h2 * 9 + (h0 >> 17) + (h1 >> 21)) * mul1; @@ -588,7 +588,7 @@ namespace farmhashte { template static inline uint64_t farmhashte::Hash64Long( const uint8_t * s, size_t n, uint64_t seed0, uint64_t seed1 ) { const __m128i kShuf = - _mm_set_epi8( 4, 11, 10, 5, 8, 15, 6, 9, 12, 2, 14, 13, 0, 7, 3, 1); + _mm_set_epi8( 4, 11, 10, 5, 8, 15, 6, 9, 12, 2, 14, 13, 0, 7, 3, 1); const __m128i kMult = _mm_set_epi8(0xbd, 0xd6, 0x33, 0x39, 0x45, 0x54, 0xfa, 0x03, 0x34, 0x3e, 0x33, 0xed, 0xcc, 0x9e, 0x2d, 0x51); @@ -826,11 +826,11 @@ namespace farmhashmk { template static inline uint32_t farmhashmk::Hash32Len13to24( const uint8_t * s, size_t len, uint32_t seed ) { uint32_t a = Fetch32(s - 4 + (len >> 1)); - uint32_t b = Fetch32(s + 4); - uint32_t c = Fetch32(s + len - 8); + uint32_t b = Fetch32(s + 4 ); + uint32_t c = Fetch32(s + len - 8 ); uint32_t d = Fetch32(s + (len >> 1)); - uint32_t e = Fetch32(s); - uint32_t f = Fetch32(s + len - 4); + uint32_t e = Fetch32(s ); + uint32_t f = Fetch32(s + len - 4 ); uint32_t h = d * c1 + len + seed; a = ROTR32(a, 12) + f; @@ -1002,7 +1002,7 @@ static uint32_t farmhashsu::Hash32( const uint8_t * s, size_t len ) { if (len < 80) { __m128i a = Fetch128(s ); __m128i b = Fetch128(s + 16); - __m128i c = Fetch128(s + (len - 15) / 2); + __m128i c = Fetch128(s + (len - 15) / 2); __m128i d = Fetch128(s + len - 32); __m128i e = Fetch128(s + len - 16); h = Add32(h, a); @@ -1345,11 +1345,11 @@ namespace farmhashcc { template static inline uint32_t farmhashcc::Hash32Len13to24( const uint8_t * s, size_t len ) { uint32_t a = Fetch32(s - 4 + (len >> 1)); - uint32_t b = Fetch32(s + 4); - uint32_t c = Fetch32(s + len - 8); + uint32_t b = Fetch32(s + 4 ); + uint32_t c = Fetch32(s + len - 8 ); uint32_t d = Fetch32(s + (len >> 1)); - uint32_t e = Fetch32(s); - uint32_t f = Fetch32(s + len - 4); + uint32_t e = Fetch32(s ); + uint32_t f = Fetch32(s + len - 4 ); uint32_t h = len; return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h))))))); @@ -1538,7 +1538,7 @@ static uint128_t farmhashcc::Hash128WithSeed( const uint8_t * s, size_t len, uin // This is the same inner loop as CityHash64(), manually unrolled. do { x = ROTR64(x + y + v.first + Fetch64(s + 8), 37) * k1; - y = ROTR64(y + v.second + Fetch64 (s + 48), 42) * k1; + y = ROTR64(y + v.second + Fetch64(s + 48), 42) * k1; x ^= w.second; y += v.first + Fetch64(s + 40); z = ROTR64(z + w.first, 33) * k1; @@ -1547,7 +1547,7 @@ static uint128_t farmhashcc::Hash128WithSeed( const uint8_t * s, size_t len, uin std::swap(z, x); s += 64; x = ROTR64(x + y + v.first + Fetch64(s + 8), 37) * k1; - y = ROTR64(y + v.second + Fetch64 (s + 48), 42) * k1; + y = ROTR64(y + v.second + Fetch64(s + 48), 42) * k1; x ^= w.second; y += v.first + Fetch64(s + 40); z = ROTR64(z + w.first, 33) * k1; @@ -1566,9 +1566,9 @@ static uint128_t farmhashcc::Hash128WithSeed( const uint8_t * s, size_t len, uin for (size_t tail_done = 0; tail_done < len;) { tail_done += 32; y = ROTR64(x + y, 42) * k0 + v.second; - w.first += Fetch64 (s + len - tail_done + 16); + w.first += Fetch64(s + len - tail_done + 16); x = x * k0 + w.first; - z += w.second + Fetch64 (s + len - tail_done); + z += w.second + Fetch64 (s + len - tail_done); w.second += v.first; v = WeakHashLen32WithSeeds(s + len - tail_done, v.first + z, v.second); v.first *= k0; diff --git a/hashes/farsh.cpp b/hashes/farsh.cpp index 522b5c81..70473364 100644 --- a/hashes/farsh.cpp +++ b/hashes/farsh.cpp @@ -215,7 +215,7 @@ static uint32_t farsh_keyed( const void * data, size_t bytes, const void * key, return farsh_final(sum) ^ key_ptr[bytes % STRIPE_ELEMENTS]; /* * ensure that zeroes at the end of data will affect the * hash value - */ + */ } template diff --git a/hashes/fnv.cpp b/hashes/fnv.cpp index 6cf28509..f706fd29 100644 --- a/hashes/fnv.cpp +++ b/hashes/fnv.cpp @@ -29,8 +29,8 @@ template static void fibonacci( const void * in, const size_t len, const seed_t seed, void * out ) { - hashT h = (hashT)seed; - const hashT * dw = (const hashT *)in; + hashT h = (hashT)seed; + const hashT * dw = (const hashT *)in; const hashT * const endw = &dw[len / sizeof(hashT)]; const uint64_t C = UINT64_C(11400714819323198485); hashT w; diff --git a/hashes/halftimehash.cpp b/hashes/halftimehash.cpp index 08534b8a..20f74136 100644 --- a/hashes/halftimehash.cpp +++ b/hashes/halftimehash.cpp @@ -812,19 +812,19 @@ namespace halftime_hash { output[3] = input[0]; output[1] = input[1]; - output[3] = Plus(output [3], input[1 ] ); + output[3] = Plus(output[3], input[1]); - output[1] = Plus(output [1], LeftShift(input[2], 1)); - output[2] = Plus(output [2], input[2 ] ); + output[1] = Plus(output[1], LeftShift(input[2], 1)); + output[2] = Plus(output[2], input[2]); output[0] = input[3]; - output[3] = Plus(output [3], input[3 ] ); + output[3] = Plus(output[3], input[3]); - output[0] = Plus(output [0], input[4 ] ); - output[2] = Plus(output [2], LeftShift(input[4], 2)); + output[0] = Plus(output[0], input[4]); + output[2] = Plus(output[2], LeftShift(input[4], 2)); - output[0] = Plus(output [0], LeftShift(input[5], 2)); - output[1] = Plus(output [1], input[5 ] ); + output[0] = Plus(output[0], LeftShift(input[5], 2)); + output[1] = Plus(output[1], input[5]); Badger::template Dot4<2, 1, 1, 4>(output, input[6]); Badger::template Dot4<4, 2, 1, 1>(output, input[7]); diff --git a/hashes/hasshe2.cpp b/hashes/hasshe2.cpp index d10e1740..2322a4c2 100644 --- a/hashes/hasshe2.cpp +++ b/hashes/hasshe2.cpp @@ -82,24 +82,24 @@ static void combine_and_mix( uint64_t state[4], const uint64_t input[2] ) { * Phase 3: Propagate the changes among the four 64-bit words by * performing 64-bit subtractions and 32-bit word shuffling. */ - state[0] -= state [2]; - state[1] -= state [3]; + state[0] -= state[2]; + state[1] -= state[3]; uint64_t tmp; - tmp = state [2]; + tmp = state[2]; state[2] = ((state[2] >> 32) + (state[3] << 32)) - state[0]; state[3] = ((state[3] >> 32) + (tmp << 32)) - state[1]; - tmp = state [1]; + tmp = state[1]; state[1] = ((state[0] >> 32) + (state[0] << 32)) - state[3]; state[0] = tmp - state[2]; - tmp = state [2]; + tmp = state[2]; state[2] = ((state[3] >> 32) + (state[2] << 32)) - state[0]; state[3] = ((tmp >> 32) + (state[3] << 32)) - state[1]; - tmp = state [0]; + tmp = state[0]; state[0] = ((state[1] >> 32) + (state[0] << 32)) - state[2]; state[1] = ((tmp >> 32) + (state[1] << 32)) - state[3]; diff --git a/hashes/md5.cpp b/hashes/md5.cpp index 974d3c25..830d600d 100644 --- a/hashes/md5.cpp +++ b/hashes/md5.cpp @@ -259,7 +259,7 @@ static void md5_finish( md5_context * ctx, uint8_t output[16] ) { PUT_U32(low , msglen, 0); PUT_U32(high, msglen, 4); - last = ctx->total [0] & 0x3F; + last = ctx->total[0] & 0x3F; padn = (last < 56) ? (56 - last) : (120 - last); md5_update(ctx, (uint8_t *)md5_padding, padn); diff --git a/hashes/multiply_shift.cpp b/hashes/multiply_shift.cpp index 3ac990ba..89fe6f8b 100644 --- a/hashes/multiply_shift.cpp +++ b/hashes/multiply_shift.cpp @@ -145,8 +145,7 @@ static void pair_multiply_shift32( const void * in, const size_t len_bytes, cons uint64_t last = 0; if (remaining_bytes & 2) { last = (last << 16) | GET_U16(buf, 0); buf += 2; } if (remaining_bytes & 1) { last = (last << 8) | (*buf); } - t = last * - multiply_shift_random[len % MULTIPLY_SHIFT_RANDOM_WORDS]; + t = last * multiply_shift_random[len % MULTIPLY_SHIFT_RANDOM_WORDS]; h += t; } diff --git a/hashes/mum_mir.cpp b/hashes/mum_mir.cpp index 07a2a1ce..22ba5a35 100644 --- a/hashes/mum_mir.cpp +++ b/hashes/mum_mir.cpp @@ -75,7 +75,7 @@ static const uint64_t _mum_tail_prime = UINT64_C(0xaf47d47c99b1461b); static const uint64_t _mum_finish_prime1 = UINT64_C(0xa9a7ae7ceff79f3f); static const uint64_t _mum_finish_prime2 = UINT64_C(0xaf47d47c99b1461b); -static const uint64_t _mum_primes [] = { +static const uint64_t _mum_primes[] = { UINT64_C(0x9ebdcae10d981691), UINT64_C(0x32b9b9b97a27ac7d), UINT64_C(0x29b5584d83d35bbd), UINT64_C(0x4b04e0e61401255f), UINT64_C(0x25e8f7b1f1c9d027), UINT64_C(0x80d4c8c000f3e881), diff --git a/hashes/pearson.cpp b/hashes/pearson.cpp index de9b796e..560f54c5 100644 --- a/hashes/pearson.cpp +++ b/hashes/pearson.cpp @@ -107,31 +107,31 @@ static void pearson_hash_256_portable( uint8_t * out, const uint8_t * in, size_t // table lookup uint64_t h = 0; uint16_t x; - x = upper_hash; x = t16[x]; upper_hash >>= 16; h = x; h = ROTR64(h, 16); - x = upper_hash; x = t16[x]; upper_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = upper_hash; x = t16[x]; upper_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = upper_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); + x = upper_hash; x = t16[x]; upper_hash >>= 16; h = x; h = ROTR64(h, 16); + x = upper_hash; x = t16[x]; upper_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = upper_hash; x = t16[x]; upper_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = upper_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); upper_hash = h; h = 0; - x = lower_hash; x = t16[x]; lower_hash >>= 16; h = x; h = ROTR64(h, 16); - x = lower_hash; x = t16[x]; lower_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = lower_hash; x = t16[x]; lower_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = lower_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); + x = lower_hash; x = t16[x]; lower_hash >>= 16; h = x; h = ROTR64(h, 16); + x = lower_hash; x = t16[x]; lower_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = lower_hash; x = t16[x]; lower_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = lower_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); lower_hash = h; h = 0; - x = high_upper_hash; x = t16[x]; high_upper_hash >>= 16; h = x; h = ROTR64(h, 16); - x = high_upper_hash; x = t16[x]; high_upper_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = high_upper_hash; x = t16[x]; high_upper_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = high_upper_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); + x = high_upper_hash; x = t16[x]; high_upper_hash >>= 16; h = x; h = ROTR64(h, 16); + x = high_upper_hash; x = t16[x]; high_upper_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = high_upper_hash; x = t16[x]; high_upper_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = high_upper_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); high_upper_hash = h; h = 0; - x = high_lower_hash; x = t16[x]; high_lower_hash >>= 16; h = x; h = ROTR64(h, 16); - x = high_lower_hash; x = t16[x]; high_lower_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = high_lower_hash; x = t16[x]; high_lower_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = high_lower_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); + x = high_lower_hash; x = t16[x]; high_lower_hash >>= 16; h = x; h = ROTR64(h, 16); + x = high_lower_hash; x = t16[x]; high_lower_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = high_lower_hash; x = t16[x]; high_lower_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = high_lower_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); high_lower_hash = h; } // store output @@ -174,17 +174,17 @@ static void pearson_hash_128_portable( uint8_t * out, const uint8_t * in, size_t // table lookup uint64_t h = 0; uint16_t x; - x = upper_hash; x = t16[x]; upper_hash >>= 16; h = x; h = ROTR64(h, 16); - x = upper_hash; x = t16[x]; upper_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = upper_hash; x = t16[x]; upper_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = upper_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); + x = upper_hash; x = t16[x]; upper_hash >>= 16; h = x; h = ROTR64(h, 16); + x = upper_hash; x = t16[x]; upper_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = upper_hash; x = t16[x]; upper_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = upper_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); upper_hash = h; h = 0; - x = lower_hash; x = t16[x]; lower_hash >>= 16; h = x; h = ROTR64(h, 16); - x = lower_hash; x = t16[x]; lower_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = lower_hash; x = t16[x]; lower_hash >>= 16; h |= x; h = ROTR64(h, 16); - x = lower_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); + x = lower_hash; x = t16[x]; lower_hash >>= 16; h = x; h = ROTR64(h, 16); + x = lower_hash; x = t16[x]; lower_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = lower_hash; x = t16[x]; lower_hash >>= 16; h |= x; h = ROTR64(h, 16); + x = lower_hash; x = t16[x]; h |= x; h = ROTR64(h, 16); lower_hash = h; } // store output @@ -367,7 +367,7 @@ static void pearson_hash_256_ssse3( uint8_t * out, const uint8_t * in, size_t le high_selected_entries = _mm_or_si128(high_selected_entries, high_lut_index); high_selected_entries = _mm_shuffle_epi8(table_line, high_selected_entries); lut_result = _mm_or_si128(lut_result, selected_entries); - lut_index = _mm_sub_epi8(lut_index, p16); + lut_index = _mm_sub_epi8(lut_index, p16); high_lut_result = _mm_or_si128(high_lut_result, high_selected_entries); high_lut_index = _mm_sub_epi8(high_lut_index, p16); } diff --git a/hashes/pmp_multilinear.cpp b/hashes/pmp_multilinear.cpp index 04b76b91..5e036085 100644 --- a/hashes/pmp_multilinear.cpp +++ b/hashes/pmp_multilinear.cpp @@ -695,7 +695,7 @@ void mul32x32to64addto96( uint32_t & loWord, uint32_t & hiWord, uint32_t & hhWor #define PMPML_CHUNK_LOOP_BODY_ULI_T1_LAST \ /*multiply32x32to64(mul.HighPart, mul.LowPart, xLast, coeff[ size ]); \ - add64(constTerm.LowPart, constTerm.HighPart, ctr, mul.LowPart, mul.HighPart);*/ \ + add64(constTerm.LowPart, constTerm.HighPart, ctr, mul.LowPart, mul.HighPart);*/ \ mul32x32to64addto96(constTerm.LowPart, constTerm.HighPart, ctr, xLast, coeff[ size ]); \ #define PMPML_CHUNK_LOOP_PRE_REDUCE_L0 @@ -710,81 +710,81 @@ void mul32x32to64addto96( uint32_t & loWord, uint32_t & hiWord, uint32_t & hhWor #define PMPML_CHUNK_REDUCE_96_TO_64 -#define PMPML_CHUNK_REDUCE_64_TO_32 \ -{ \ - uint32_t lo, hi; \ - multiply32x32to64(hi, lo, constTerm.HighPart, 15);\ - uint32_t part = ctr * 225 + (hi << 4) - hi + 15;\ - constTerm.LowPart += part; \ - constTerm.HighPart = 1 + (constTerm.LowPart < part);\ - constTerm.HighPart -= (constTerm.LowPart < lo);\ - constTerm.LowPart -= lo; \ - if ( likely( constTerm.LowPart >= 30) ) { \ - constTerm.LowPart -= constTerm.HighPart * 15; \ - constTerm.HighPart = 0; \ - } else { \ - if ( constTerm.HighPart ) { \ - constTerm.LowPart -= constTerm.HighPart * 15;\ - constTerm.HighPart = 1; \ - if ( likely( constTerm.LowPart >= 15)) {\ - constTerm.LowPart -= 15; \ - constTerm.HighPart = 0; \ - } else { \ - constTerm.LowPart -= 15;\ - constTerm.HighPart = 0;\ - } \ - } \ - } \ +#define PMPML_CHUNK_REDUCE_64_TO_32 \ +{ \ + uint32_t lo, hi; \ + multiply32x32to64(hi, lo, constTerm.HighPart, 15); \ + uint32_t part = ctr * 225 + (hi << 4) - hi + 15; \ + constTerm.LowPart += part; \ + constTerm.HighPart = 1 + (constTerm.LowPart < part); \ + constTerm.HighPart -= (constTerm.LowPart < lo); \ + constTerm.LowPart -= lo; \ + if ( likely( constTerm.LowPart >= 30) ) { \ + constTerm.LowPart -= constTerm.HighPart * 15; \ + constTerm.HighPart = 0; \ + } else { \ + if ( constTerm.HighPart ) { \ + constTerm.LowPart -= constTerm.HighPart * 15; \ + constTerm.HighPart = 1; \ + if ( likely( constTerm.LowPart >= 15)) { \ + constTerm.LowPart -= 15; \ + constTerm.HighPart = 0; \ + } else { \ + constTerm.LowPart -= 15; \ + constTerm.HighPart = 0; \ + } \ + } \ + } \ } #define PMPML_FULL_REDUCE_MOD_2_32_PLUS_15_AND_RETURN \ - PMPML_CHUNK_REDUCE_96_TO_64 \ - PMPML_CHUNK_REDUCE_64_TO_32 \ + PMPML_CHUNK_REDUCE_96_TO_64 \ + PMPML_CHUNK_REDUCE_64_TO_32 \ return constTerm.QuadPart; -#define PMPML_FULL_REDUCE_MOD_2_32_PLUS_15_AND_RETURN_RETURN_32x32_ONLY \ -{ \ - constTerm.QuadPart = constTerm.LowPart + PMPML_MAIN_PRIME - constTerm.HighPart * UINT64_C( 15 );\ - if ( likely( constTerm.LowPart >= 30) ) { \ - constTerm.LowPart -= (constTerm.HighPart << 4) - constTerm.HighPart; \ - return fmix32_short( constTerm.LowPart ); \ - } else { \ - constTerm.LowPart -= constTerm.HighPart * 15; \ - if ( constTerm.LowPart < 30 ) { \ - return fmix32_short( constTerm.LowPart ); \ - } else { \ - constTerm.LowPart += 15; \ - return fmix32_short( constTerm.LowPart ); \ - } \ - } \ +#define PMPML_FULL_REDUCE_MOD_2_32_PLUS_15_AND_RETURN_RETURN_32x32_ONLY \ + { \ + constTerm.QuadPart = constTerm.LowPart + PMPML_MAIN_PRIME - constTerm.HighPart * UINT64_C( 15 ); \ + if ( likely( constTerm.LowPart >= 30) ) { \ + constTerm.LowPart -= (constTerm.HighPart << 4) - constTerm.HighPart; \ + return fmix32_short( constTerm.LowPart ); \ + } else { \ + constTerm.LowPart -= constTerm.HighPart * 15; \ + if ( constTerm.LowPart < 30 ) { \ + return fmix32_short( constTerm.LowPart ); \ + } else { \ + constTerm.LowPart += 15; \ + return fmix32_short( constTerm.LowPart ); \ + } \ + } \ } #define PMPML_FULL_REDUCE_MOD_2_32_PLUS_15_AND_RETURN_RETURN \ { \ - uint32_t lo, hi; \ - multiply32x32to64(hi, lo, constTerm.HighPart, 15); \ - uint32_t part = ctr * 225 + (hi << 4) - hi + 15; \ - constTerm.LowPart += part; \ - constTerm.HighPart = 1 + (constTerm.LowPart < part); \ - constTerm.HighPart -= (constTerm.LowPart < lo); \ - constTerm.LowPart -= lo; \ - if ( likely( constTerm.LowPart >= 30) ) { \ + uint32_t lo, hi; \ + multiply32x32to64(hi, lo, constTerm.HighPart, 15); \ + uint32_t part = ctr * 225 + (hi << 4) - hi + 15; \ + constTerm.LowPart += part; \ + constTerm.HighPart = 1 + (constTerm.LowPart < part); \ + constTerm.HighPart -= (constTerm.LowPart < lo); \ + constTerm.LowPart -= lo; \ + if ( likely( constTerm.LowPart >= 30) ) { \ constTerm.LowPart -= (constTerm.HighPart << 4) - constTerm.HighPart/*constTerm.HighPart * 15*/; \ return fmix32_short( constTerm.LowPart ); \ - } else { \ - if ( constTerm.HighPart ) { \ - constTerm.LowPart -= constTerm.HighPart * 15 - 15; \ - constTerm.HighPart = 1; \ - if ( likely( constTerm.LowPart >= 15)) { \ + } else { \ + if ( constTerm.HighPart ) { \ + constTerm.LowPart -= constTerm.HighPart * 15 - 15; \ + constTerm.HighPart = 1; \ + if ( likely( constTerm.LowPart >= 15)) { \ constTerm.LowPart -= 15; \ return fmix32_short( constTerm.LowPart ); \ } else { \ - return constTerm.LowPart; \ - } \ + return constTerm.LowPart; \ + } \ } else { \ - return fmix32_short( constTerm.LowPart ); \ + return fmix32_short( constTerm.LowPart ); \ } \ - } \ + } \ } class PMP_Multilinear_Hasher_32 { @@ -1444,23 +1444,25 @@ class PMP_Multilinear_Hasher_32 { break; case 2: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) } break; - case 3: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1( - 2 + offset) } + case 3: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) + PMPML_CHUNK_LOOP_BODY_ULI_T1(2 + offset) } break; - case 4: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1( - 2 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(3 + offset) } + case 4: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) + PMPML_CHUNK_LOOP_BODY_ULI_T1(2 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(3 + offset) } break; - case 5: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1( - 2 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(3 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(4 + offset) } + case 5: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) + PMPML_CHUNK_LOOP_BODY_ULI_T1(2 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(3 + offset) + PMPML_CHUNK_LOOP_BODY_ULI_T1(4 + offset) } + break; + case 6: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) + PMPML_CHUNK_LOOP_BODY_ULI_T1(2 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(3 + offset) + PMPML_CHUNK_LOOP_BODY_ULI_T1(4 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(5 + offset) } + break; + case 7: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) + PMPML_CHUNK_LOOP_BODY_ULI_T1(2 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(3 + offset) + PMPML_CHUNK_LOOP_BODY_ULI_T1(4 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(5 + offset) + PMPML_CHUNK_LOOP_BODY_ULI_T1(6 + offset) } break; - case 6: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1( - 2 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(3 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(4 + - offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(5 + offset) } - break; - case 7: { PMPML_CHUNK_LOOP_BODY_ULI_T1(0 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(1 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1( - 2 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(3 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(4 + - offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(5 + offset) PMPML_CHUNK_LOOP_BODY_ULI_T1(6 + offset) } - break; } uint32_t xLast; @@ -1530,8 +1532,8 @@ class PMP_Multilinear_Hasher_32 { ULARGE_INTEGER__XX lowProduct; lowProduct.QuadPart = UInt32x32To64(c_ctr.LowPart, prevConstTerm.LowPart ); ULARGE_INTEGER__XX midProduct; - midProduct.QuadPart = UInt32x32To64(c_ctr.LowPart, prevConstTerm.HighPart) + UInt32x32To64( - c_ctr.HighPart, prevConstTerm.LowPart); + midProduct.QuadPart = UInt32x32To64(c_ctr.LowPart, prevConstTerm.HighPart) + + UInt32x32To64(c_ctr.HighPart, prevConstTerm.LowPart); midProduct.QuadPart += lowProduct.HighPart; lowProduct.HighPart = midProduct.LowPart; uint32_t hiProduct = c_ctr.HighPart * prevConstTerm.HighPart + midProduct.HighPart; @@ -1557,7 +1559,7 @@ class PMP_Multilinear_Hasher_32 { PMPML_CHUNK_LOOP_PRE_REDUCE_L0 - PMPML_FULL_REDUCE_MOD_2_32_PLUS_15_AND_RETURN + PMPML_FULL_REDUCE_MOD_2_32_PLUS_15_AND_RETURN } template @@ -1600,7 +1602,7 @@ class PMP_Multilinear_Hasher_32 { procesNextValue(i + 1, /* * hash_of_num_chunk( curr_rd[ i ].random_coeff, - *(ULARGE_INTEGER__XX*)(&(curr_rd[i].const_term)), + * (ULARGE_INTEGER__XX*)(&(curr_rd[i].const_term)), * allValues + ( i << PMPML_CHUNK_SIZE_LOG2 ) ), */ hash_of_num_chunk_incomplete(curr_rd[i].random_coeff, *(ULARGE_INTEGER__XX *)(&(curr_rd[i].const_term)), @@ -1652,26 +1654,31 @@ class PMP_Multilinear_Hasher_32 { HASH_SIZE_XXX_BEGIN(28) PMPML_CHUNK_LOOP_BODY_ULI_T1(0) PMPML_CHUNK_LOOP_BODY_ULI_T1(1) PMPML_CHUNK_LOOP_BODY_ULI_T1(2) PMPML_CHUNK_LOOP_BODY_ULI_T1(3) - PMPML_CHUNK_LOOP_BODY_ULI_T1(4) PMPML_CHUNK_LOOP_BODY_ULI_T1(5) PMPML_CHUNK_LOOP_BODY_ULI_T1(6) xLast = - 0x1; PMPML_CHUNK_LOOP_BODY_ULI_T1_LAST_FOR_JUST_1; + PMPML_CHUNK_LOOP_BODY_ULI_T1(4) PMPML_CHUNK_LOOP_BODY_ULI_T1(5) PMPML_CHUNK_LOOP_BODY_ULI_T1(6) + xLast = 0x1; + PMPML_CHUNK_LOOP_BODY_ULI_T1_LAST_FOR_JUST_1; HASH_SIZE_XXX_END - HASH_SIZE_XXX_BEGIN( 29 ) + HASH_SIZE_XXX_BEGIN( 29 ) PMPML_CHUNK_LOOP_BODY_ULI_T1(0) PMPML_CHUNK_LOOP_BODY_ULI_T1(1) PMPML_CHUNK_LOOP_BODY_ULI_T1(2) PMPML_CHUNK_LOOP_BODY_ULI_T1(3) - PMPML_CHUNK_LOOP_BODY_ULI_T1(4) PMPML_CHUNK_LOOP_BODY_ULI_T1(5) PMPML_CHUNK_LOOP_BODY_ULI_T1(6) xLast = - 0x100 + chars[28]; PMPML_CHUNK_LOOP_BODY_ULI_T1_LAST; + PMPML_CHUNK_LOOP_BODY_ULI_T1(4) PMPML_CHUNK_LOOP_BODY_ULI_T1(5) PMPML_CHUNK_LOOP_BODY_ULI_T1(6) + xLast = 0x100 + chars[28]; + PMPML_CHUNK_LOOP_BODY_ULI_T1_LAST; HASH_SIZE_XXX_END - HASH_SIZE_XXX_BEGIN( 30 ) + HASH_SIZE_XXX_BEGIN( 30 ) PMPML_CHUNK_LOOP_BODY_ULI_T1(0) PMPML_CHUNK_LOOP_BODY_ULI_T1(1) PMPML_CHUNK_LOOP_BODY_ULI_T1(2) PMPML_CHUNK_LOOP_BODY_ULI_T1(3) - PMPML_CHUNK_LOOP_BODY_ULI_T1(4) PMPML_CHUNK_LOOP_BODY_ULI_T1(5) PMPML_CHUNK_LOOP_BODY_ULI_T1(6) xLast = - *((const unsigned short *)(chars + 28)) + 0x10000; PMPML_CHUNK_LOOP_BODY_ULI_T1_LAST + PMPML_CHUNK_LOOP_BODY_ULI_T1(4) PMPML_CHUNK_LOOP_BODY_ULI_T1(5) PMPML_CHUNK_LOOP_BODY_ULI_T1(6) + xLast =((const unsigned short *)(chars + 28)) + 0x10000; + PMPML_CHUNK_LOOP_BODY_ULI_T1_LAST HASH_SIZE_XXX_END - HASH_SIZE_XXX_BEGIN( 31 ) + HASH_SIZE_XXX_BEGIN( 31 ) PMPML_CHUNK_LOOP_BODY_ULI_T1(0) PMPML_CHUNK_LOOP_BODY_ULI_T1(1) PMPML_CHUNK_LOOP_BODY_ULI_T1(2) PMPML_CHUNK_LOOP_BODY_ULI_T1(3) - PMPML_CHUNK_LOOP_BODY_ULI_T1(4) PMPML_CHUNK_LOOP_BODY_ULI_T1(5) PMPML_CHUNK_LOOP_BODY_ULI_T1(6) xLast = chars[30]; - xLast = (xLast << 16) + *((const unsigned short *)(chars + 28)) + 0x1000000; PMPML_CHUNK_LOOP_BODY_ULI_T1_LAST; + PMPML_CHUNK_LOOP_BODY_ULI_T1(4) PMPML_CHUNK_LOOP_BODY_ULI_T1(5) PMPML_CHUNK_LOOP_BODY_ULI_T1(6) + xLast = chars[30]; + xLast = (xLast << 16) + *((const unsigned short *)(chars + 28)) + 0x1000000; + PMPML_CHUNK_LOOP_BODY_ULI_T1_LAST; HASH_SIZE_XXX_END #endif // PMPML_MSC_32_WORKAROUND @@ -2025,82 +2032,82 @@ static FORCE_INLINE void MultiplyAccumulateWordLoHi( uint64_t & rlo, uint64_t & #define PMPML_CHUNK_LOOP_PRE_REDUCE_L0_64 -#define PMPML_CHUNK_REDUCE_128_TO_64 \ -{ \ - uint64_t hi, lo; \ - MultiplyWordLoHi(lo, hi, ctr1.QuadPart, 13); \ - uint64_t part = ctr2.QuadPart * 169 + hi * 13 + 13;\ - ctr0.QuadPart += part; \ - ctr1.QuadPart = 1 + (ctr0.QuadPart < part); \ - ctr1.QuadPart -= (ctr0.QuadPart < lo); \ - ctr0.QuadPart -= lo; \ - if ( likely( ctr0.QuadPart >= 26) ) { \ - ctr0.QuadPart -= ctr1.QuadPart * 13; \ - ctr1.QuadPart = 0; \ - } else { \ - ctr0.QuadPart -= ctr1.QuadPart * 13; \ - if ( ctr0.QuadPart < 26 ) { \ - ctr1.QuadPart = 0; \ - } else { \ - ctr0.QuadPart += 13; \ - if ( ctr0.QuadPart < 13 ) { \ - ctr1.QuadPart = 1; \ - } else { \ - ctr1.QuadPart = 0; \ - } \ - } \ - } \ +#define PMPML_CHUNK_REDUCE_128_TO_64 \ + { \ + uint64_t hi, lo; \ + MultiplyWordLoHi(lo, hi, ctr1.QuadPart, 13); \ + uint64_t part = ctr2.QuadPart * 169 + hi * 13 + 13; \ + ctr0.QuadPart += part; \ + ctr1.QuadPart = 1 + (ctr0.QuadPart < part); \ + ctr1.QuadPart -= (ctr0.QuadPart < lo); \ + ctr0.QuadPart -= lo; \ + if ( likely( ctr0.QuadPart >= 26) ) { \ + ctr0.QuadPart -= ctr1.QuadPart * 13; \ + ctr1.QuadPart = 0; \ + } else { \ + ctr0.QuadPart -= ctr1.QuadPart * 13; \ + if ( ctr0.QuadPart < 26 ) { \ + ctr1.QuadPart = 0; \ + } else { \ + ctr0.QuadPart += 13; \ + if ( ctr0.QuadPart < 13 ) { \ + ctr1.QuadPart = 1; \ + } else { \ + ctr1.QuadPart = 0; \ + } \ + } \ + } \ } -#define PMPML_CHUNK_REDUCE_128_TO_64____ \ -{ \ - _compensate_ \ - uint64_t hi, lo; \ - MultiplyWordLoHi(lo, hi, ctr1.QuadPart, 13); \ - uint64_t part = ctr2.QuadPart * 169 + hi * 13 + 13;\ - ctr0.QuadPart += part; \ - ctr1.QuadPart = 1 + (ctr0.QuadPart < part); \ - ctr1.QuadPart -= (ctr0.QuadPart < lo); \ - ctr0.QuadPart -= lo; \ - if ( likely( ctr0.QuadPart >= 26) ) { \ - ctr0.QuadPart -= ctr1.QuadPart * 13; \ - ctr1.QuadPart = 0; \ - } else { \ - ctr0.QuadPart -= ctr1.QuadPart * 13; \ - if ( ctr0.QuadPart < 26 ) { \ - ctr1.QuadPart = 0; \ - } else { \ - ctr0.QuadPart += 13; \ - if ( ctr0.QuadPart < 13 ) { \ - ctr1.QuadPart = 1; \ - } else { \ - ctr1.QuadPart = 0; \ - } \ - } \ - } \ +#define PMPML_CHUNK_REDUCE_128_TO_64____ \ +{ \ + _compensate_ \ + uint64_t hi, lo; \ + MultiplyWordLoHi(lo, hi, ctr1.QuadPart, 13); \ + uint64_t part = ctr2.QuadPart * 169 + hi * 13 + 13; \ + ctr0.QuadPart += part; \ + ctr1.QuadPart = 1 + (ctr0.QuadPart < part); \ + ctr1.QuadPart -= (ctr0.QuadPart < lo); \ + ctr0.QuadPart -= lo; \ + if ( likely( ctr0.QuadPart >= 26) ) { \ + ctr0.QuadPart -= ctr1.QuadPart * 13; \ + ctr1.QuadPart = 0; \ + } else { \ + ctr0.QuadPart -= ctr1.QuadPart * 13; \ + if ( ctr0.QuadPart < 26 ) { \ + ctr1.QuadPart = 0; \ + } else { \ + ctr0.QuadPart += 13; \ + if ( ctr0.QuadPart < 13 ) { \ + ctr1.QuadPart = 1; \ + } else { \ + ctr1.QuadPart = 0; \ + } \ + } \ + } \ } -#define PMPML_CHUNK_REDUCE_128_TO_64_AND_RETURN \ -{ \ - uint64_t hi, lo; \ - MultiplyWordLoHi(lo, hi, ctr1.QuadPart, 13); \ - uint64_t part = ctr2.QuadPart * 169 + hi * 13 + 13;\ - ctr0.QuadPart += part; \ - ctr1.QuadPart = 1 + (ctr0.QuadPart < part); \ - ctr1.QuadPart -= (ctr0.QuadPart < lo); \ - ctr0.QuadPart -= lo; \ - if ( likely( ctr0.QuadPart >= 26) ) { \ - ctr0.QuadPart -= ctr1.QuadPart * 13; \ - return fmix64_short( ctr0.QuadPart ); \ - } else { \ - ctr0.QuadPart -= ctr1.QuadPart * 13; \ - if ( ctr0.QuadPart < 26 ) { \ - return fmix64_short( ctr0.QuadPart ); \ - } else { \ - ctr0.QuadPart += 13; \ - return fmix64_short( ctr0.QuadPart );\ - } \ - } \ +#define PMPML_CHUNK_REDUCE_128_TO_64_AND_RETURN \ +{ \ + uint64_t hi, lo; \ + MultiplyWordLoHi(lo, hi, ctr1.QuadPart, 13); \ + uint64_t part = ctr2.QuadPart * 169 + hi * 13 + 13; \ + ctr0.QuadPart += part; \ + ctr1.QuadPart = 1 + (ctr0.QuadPart < part); \ + ctr1.QuadPart -= (ctr0.QuadPart < lo); \ + ctr0.QuadPart -= lo; \ + if ( likely( ctr0.QuadPart >= 26) ) { \ + ctr0.QuadPart -= ctr1.QuadPart * 13; \ + return fmix64_short( ctr0.QuadPart ); \ + } else { \ + ctr0.QuadPart -= ctr1.QuadPart * 13; \ + if ( ctr0.QuadPart < 26 ) { \ + return fmix64_short( ctr0.QuadPart ); \ + } else { \ + ctr0.QuadPart += 13; \ + return fmix64_short( ctr0.QuadPart ); \ + } \ + } \ } template diff --git a/hashes/rmd.cpp b/hashes/rmd.cpp index 20eb959c..8794ce5a 100644 --- a/hashes/rmd.cpp +++ b/hashes/rmd.cpp @@ -579,7 +579,7 @@ static void rmd256( const void * in, const size_t len, const seed_t seed, void * } static bool rmd_test( void ) { - static conststruct { + static const struct { const char * msg; unsigned char hash128[16]; unsigned char hash160[20]; diff --git a/hashes/siphash.cpp b/hashes/siphash.cpp index 2a2da0c8..14cfc5a5 100644 --- a/hashes/siphash.cpp +++ b/hashes/siphash.cpp @@ -141,7 +141,7 @@ static uint64_t siphash_sse( const uint64_t key[2], const uint8_t * m, size_t le v13 = _mm_xor_si128(v13, _mm_unpackhi_epi64(k, k)); #if defined(HAVE_SSSE_3) -#define sipcompress() \ +#define sipcompress() \ v11 = v13; \ v33 = v13; \ v11 = _mm_or_si128(_mm_slli_epi64(v11, 13), _mm_srli_epi64(v11, 64-13));\ @@ -160,7 +160,7 @@ static uint64_t siphash_sse( const uint64_t key[2], const uint8_t * m, size_t le v02 = _mm_shuffle_epi32(v20, _MM_SHUFFLE(0,1,3,2)); \ v13 = _mm_xor_si128(v13, v20); #else -#define sipcompress() \ +#define sipcompress() \ v11 = v13; \ v33 = _mm_shuffle_epi32(v13, _MM_SHUFFLE(1,0,3,2)); \ v11 = _mm_or_si128(_mm_slli_epi64(v11, 13), _mm_srli_epi64(v11, 64-13));\ diff --git a/hashes/spookyhash.cpp b/hashes/spookyhash.cpp index 14d64be4..fcdc0a0c 100644 --- a/hashes/spookyhash.cpp +++ b/hashes/spookyhash.cpp @@ -98,8 +98,8 @@ class SpookyHash { s7 += GET_U64(data, 8 * 7); s9 ^= s5; s6 ^= s7; s7 = ROTL64(s7, 57); s6 += s8; s8 += GET_U64(data, 8 * 8); s10 ^= s6; s7 ^= s8; s8 = ROTL64(s8, 55); s7 += s9; s9 += GET_U64(data, 8 * 9); s11 ^= s7; s8 ^= s9; s9 = ROTL64(s9, 54); s8 += s10; - s10 += GET_U64(data, 8 * 10); s0 ^= s8; s9 ^= s10; s10 = ROTL64(s10, 22); s9 += s11; - s11 += GET_U64(data, 8 * 11); s1 ^= s9; s10 ^= s11; s11 = ROTL64(s11, 46); s10 += s0; + s10 += GET_U64(data, 8 * 10); s0 ^= s8; s9 ^= s10; s10 = ROTL64(s10, 22); s9 += s11; + s11 += GET_U64(data, 8 * 11); s1 ^= s9; s10 ^= s11; s11 = ROTL64(s11, 46); s10 += s0; } // @@ -121,18 +121,18 @@ class SpookyHash { static FORCE_INLINE void EndPartial( uint64_t & h0, uint64_t & h1, uint64_t & h2, uint64_t & h3, uint64_t & h4, uint64_t & h5, uint64_t & h6, uint64_t & h7, uint64_t & h8, uint64_t & h9, uint64_t & h10, uint64_t & h11 ) { - h11 += h1; h2 ^= h11; h1 = ROTL64(h1 , 44); - h0 += h2; h3 ^= h0; h2 = ROTL64(h2 , 15); - h1 += h3; h4 ^= h1; h3 = ROTL64(h3 , 34); - h2 += h4; h5 ^= h2; h4 = ROTL64(h4 , 21); - h3 += h5; h6 ^= h3; h5 = ROTL64(h5 , 38); - h4 += h6; h7 ^= h4; h6 = ROTL64(h6 , 33); - h5 += h7; h8 ^= h5; h7 = ROTL64(h7 , 10); - h6 += h8; h9 ^= h6; h8 = ROTL64(h8 , 13); - h7 += h9; h10 ^= h7; h9 = ROTL64(h9 , 38); - h8 += h10; h11 ^= h8; h10 = ROTL64(h10, 53); - h9 += h11; h0 ^= h9; h11 = ROTL64(h11, 42); - h10 += h0; h1 ^= h10; h0 = ROTL64(h0 , 54); + h11 += h1; h2 ^= h11; h1 = ROTL64(h1 , 44); + h0 += h2; h3 ^= h0; h2 = ROTL64(h2 , 15); + h1 += h3; h4 ^= h1; h3 = ROTL64(h3 , 34); + h2 += h4; h5 ^= h2; h4 = ROTL64(h4 , 21); + h3 += h5; h6 ^= h3; h5 = ROTL64(h5 , 38); + h4 += h6; h7 ^= h4; h6 = ROTL64(h6 , 33); + h5 += h7; h8 ^= h5; h7 = ROTL64(h7 , 10); + h6 += h8; h9 ^= h6; h8 = ROTL64(h8 , 13); + h7 += h9; h10 ^= h7; h9 = ROTL64(h9 , 38); + h8 += h10; h11 ^= h8; h10 = ROTL64(h10, 53); + h9 += h11; h0 ^= h9; h11 = ROTL64(h11, 42); + h10 += h0; h1 ^= h10; h0 = ROTL64(h0 , 54); } template @@ -145,7 +145,7 @@ class SpookyHash { h4 += GET_U64(data, 8 * 4); h5 += GET_U64(data, 8 * 5); h6 += GET_U64(data, 8 * 6); h7 += GET_U64(data, 8 * 7); h8 += GET_U64(data, 8 * 8); h9 += GET_U64(data, 8 * 9); - h10 += GET_U64(data, 8 * 10); h11 += GET_U64(data, 8 * 11); + h10 += GET_U64(data, 8 * 10); h11 += GET_U64(data, 8 * 11); } else { Mix(data, h0, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, h11); } @@ -180,7 +180,7 @@ class SpookyHash { h1 = ROTL64(h1, 37); h1 += h2; h3 ^= h1; h2 = ROTL64(h2, 62); h2 += h3; h0 ^= h2; h3 = ROTL64(h3, 34); h3 += h0; h1 ^= h3; - h0 = ROTL64(h0, 5); h0 += h1; h2 ^= h0; + h0 = ROTL64(h0, 5); h0 += h1; h2 ^= h0; h1 = ROTL64(h1, 36); h1 += h2; h3 ^= h1; } @@ -202,7 +202,7 @@ class SpookyHash { h1 ^= h0; h0 = ROTL64(h0, 26); h1 += h0; h2 ^= h1; h1 = ROTL64(h1, 51); h2 += h1; h3 ^= h2; h2 = ROTL64(h2, 28); h3 += h2; - h0 ^= h3; h3 = ROTL64(h3, 9); h0 += h3; + h0 ^= h3; h3 = ROTL64(h3, 9); h0 += h3; h1 ^= h0; h0 = ROTL64(h0, 47); h1 += h0; h2 ^= h1; h1 = ROTL64(h1, 54); h2 += h1; h3 ^= h2; h2 = ROTL64(h2, 32); h3 += h2; diff --git a/hashes/t1ha.cpp b/hashes/t1ha.cpp index 7c44a5f2..702fe601 100644 --- a/hashes/t1ha.cpp +++ b/hashes/t1ha.cpp @@ -194,10 +194,10 @@ enum t1ha_modes { }; #define MODE_NATIVE(m) (((m) == MODE_LE_NATIVE) || ((m) == MODE_BE_NATIVE)) -#define MODE_BSWAP(m) (((m) == MODE_LE_BSWAP) || ((m) == MODE_BE_BSWAP)) -#define MODE_BE_SYS(m) (((m) == MODE_BE_BSWAP) || ((m) == MODE_BE_NATIVE)) +#define MODE_BSWAP(m) (((m) == MODE_LE_BSWAP) || ((m) == MODE_BE_BSWAP)) +#define MODE_BE_SYS(m) (((m) == MODE_BE_BSWAP) || ((m) == MODE_BE_NATIVE)) #define MODE_LE_SYS(m) (((m) == MODE_LE_NATIVE) || ((m) == MODE_LE_BSWAP)) -#define MODE_BE_OUT(m) (((m) == MODE_LE_BSWAP) || ((m) == MODE_BE_NATIVE)) +#define MODE_BE_OUT(m) (((m) == MODE_LE_BSWAP) || ((m) == MODE_BE_NATIVE)) #define MODE_LE_OUT(m) (((m) == MODE_LE_NATIVE) || ((m) == MODE_BE_BSWAP)) //------------------------------------------------------------ @@ -885,7 +885,7 @@ static void t1ha2_update( t1ha_context_t * RESTRICT ctx, const void * RESTRICT d ((((uintptr_t)data) & (ALIGNMENT_64 - 1)) != 0)) { data = T1HA2_LOOP(&ctx->state, data, length); } else { - data = T1HA2_LOOP(&ctx->state, data, length); + data = T1HA2_LOOP(&ctx->state, data, length); } length &= 31; } @@ -1104,7 +1104,7 @@ static void t1ha0( const void * in, const size_t len, const seed_t seed, void * ((((uintptr_t)in) & (ALIGNMENT_32 - 1)) != 0)) { hash = t1ha0_32_impl(in, len, (uint64_t)seed); } else { - hash = t1ha0_32_impl(in, len, (uint64_t)seed); + hash = t1ha0_32_impl(in, len, (uint64_t)seed); } // To get old 0xDA6A4061 verification value for BE mode, replace // "MODE_BSWAP(mode)" with "MODE_BE_SYS(mode)", as the old code wrote @@ -1124,7 +1124,7 @@ static void t1ha1( const void * in, const size_t len, const seed_t seed, void * ((((uintptr_t)in) & (ALIGNMENT_64 - 1)) != 0)) { hash = t1ha1_impl(in, len, (uint64_t)seed); } else { - hash = t1ha1_impl(in, len, (uint64_t)seed); + hash = t1ha1_impl(in, len, (uint64_t)seed); } // To get the old 0x93F864DE verification value for BE mode, // replace "MODE_BSWAP(mode)" with "MODE_BE_SYS(mode)", as the old @@ -1148,7 +1148,7 @@ static void t1ha2( const void * in, const size_t len, const seed_t seed, void * if (use_unaligned) { in = T1HA2_LOOP(&state, in, length); } else { - in = T1HA2_LOOP(&state, in, length); + in = T1HA2_LOOP(&state, in, length); } if (!xwidth) { squash(&state); @@ -1159,11 +1159,11 @@ static void t1ha2( const void * in, const size_t len, const seed_t seed, void * } if (use_unaligned) { hash = xwidth ? - T1HA2_TAIL(&state, in, length, &xhash) : + T1HA2_TAIL(&state, in, length, &xhash) : T1HA2_TAIL(&state, in, length); } else { hash = xwidth ? - T1HA2_TAIL(&state, in, length, &xhash) : + T1HA2_TAIL(&state, in, length, &xhash) : T1HA2_TAIL(&state, in, length); } PUT_U64(hash, (uint8_t *)out, 0); @@ -1218,8 +1218,8 @@ static const uint8_t t1ha_test_pattern [64] = { 0x1F, 0xF, 8, 16, 32, 64, 0x80, 0xFE , 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0xFD, 0xFB, 0xF7, 0xEF, 0xDF, 0xBF , 0x55, 0xAA, 11, 17, 19, 23, 29, 37, 42, 43, 'a', 'b', 'c', 'd', - 'e' , 'f', 'g', 'h', 'i', 'j', 'k', 'l' , 'm', 'n', 'o', - 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' , 'w' , 'x' + 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l' , 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w' , 'x' }; static const uint64_t t1ha_refval_32le [81] = { diff --git a/hashes/xxhash.cpp b/hashes/xxhash.cpp index 6aa2496e..15f074e0 100644 --- a/hashes/xxhash.cpp +++ b/hashes/xxhash.cpp @@ -863,7 +863,7 @@ static FORCE_INLINE XXH128_hash_t XXH3_len_17to128_128b( const uint8_t * RESTRIC h128.low64 = acc.low64 + acc.high64; h128.high64 = (acc.low64 * XXH_PRIME64_1) + (acc.high64 * XXH_PRIME64_4) + - ( (len - seed ) * XXH_PRIME64_2); + ((len - seed) * XXH_PRIME64_2); h128.low64 = XXH3_avalanche(h128.low64); h128.high64 = (uint64_t)0 - XXH3_avalanche(h128.high64); return h128; @@ -896,7 +896,7 @@ static NEVER_INLINE XXH128_hash_t XXH3_len_129to240_128b( const uint8_t * RESTRI h128.low64 = acc.low64 + acc.high64; h128.high64 = (acc.low64 * XXH_PRIME64_1) + (acc.high64 * XXH_PRIME64_4) + - ( (len - seed ) * XXH_PRIME64_2); + ((len - seed) * XXH_PRIME64_2); h128.low64 = XXH3_avalanche(h128.low64); h128.high64 = (uint64_t)0 - XXH3_avalanche(h128.high64); return h128; @@ -932,8 +932,8 @@ static FORCE_INLINE void XXH3_scalarRound( void * RESTRICT acc, void const * RES uint64_t * xacc = (uint64_t * )acc; uint8_t const * xinput = (uint8_t const *)input; uint8_t const * xsecret = (uint8_t const *)secret; - uint64_t const data_val = GET_U64 (xinput, lane * 8); - uint64_t const data_key = data_val ^ GET_U64(xsecret, lane * 8); + uint64_t const data_val = GET_U64(xinput, lane * 8); + uint64_t const data_key = GET_U64(xsecret, lane * 8) ^ data_val; xacc[lane ^ 1] += data_val; /* swap adjacent lanes */ xacc[lane] += XXH_mult32to64(data_key & 0xFFFFFFFF, data_key >> 32); @@ -1190,7 +1190,7 @@ static FORCE_INLINE void XXH3_hashLong_internal_loop( uint64_t * RESTRICT acc, c size_t len, const uint8_t * RESTRICT secret, size_t secretSize ) { size_t const nbStripesPerBlock = (secretSize - XXH_STRIPE_LEN) / XXH_SECRET_CONSUME_RATE; size_t const block_len = XXH_STRIPE_LEN * nbStripesPerBlock; - size_t const nb_blocks = (len - 1 ) / block_len; + size_t const nb_blocks = (len - 1) / block_len; for (size_t n = 0; n < nb_blocks; n++) { XXH3_accumulate(acc, input + n * block_len, secret, nbStripesPerBlock); diff --git a/hashes/xxhash/xxh3-arm.h b/hashes/xxhash/xxh3-arm.h index fbd4182f..3323b399 100644 --- a/hashes/xxhash/xxh3-arm.h +++ b/hashes/xxhash/xxh3-arm.h @@ -117,7 +117,7 @@ do { \ /* Undocumented GCC/Clang operand modifier: */ \ /* %e0 = lower D half, %f0 = upper D half */ \ - __asm__ ("vzip.32 %e0, %f0" : "+w" (in)); \ + __asm__ ("vzip.32 %e0, %f0" : "+w" (in)); \ (outLo) = vget_low_u32(vreinterpretq_u32_u64(in)); \ (outHi) = vget_high_u32(vreinterpretq_u32_u64(in)); \ } while (0) diff --git a/include/hashlib/AES-aesni.h b/include/hashlib/AES-aesni.h index 7879d30d..17602ce0 100644 --- a/include/hashlib/AES-aesni.h +++ b/include/hashlib/AES-aesni.h @@ -50,7 +50,7 @@ static inline __m128i _expand_key_helper( __m128i rkey, __m128i assist ) { static int AES_KeySetup_Enc_AESNI( uint32_t rk[] /*4*(Nr + 1)*/, const uint8_t cipherKey[], int keyBits ) { __m128i * round_keys = (__m128i *)rk; - round_keys[0] = _mm_loadu_si128((__m128i *)cipherKey); + round_keys[ 0] = _mm_loadu_si128((__m128i *)cipherKey); round_keys[ 1] = _expand_key_helper(MKASSIST(round_keys[0], 0x01)); round_keys[ 2] = _expand_key_helper(MKASSIST(round_keys[1], 0x02)); round_keys[ 3] = _expand_key_helper(MKASSIST(round_keys[2], 0x04)); @@ -68,16 +68,16 @@ static int AES_KeySetup_Dec_AESNI( uint32_t rk[] /*4*(Nr + 1)*/, const uint8_t c __m128i * round_keys = (__m128i *)rk; round_keys[10] = _mm_loadu_si128((__m128i *)cipherKey); - round_keys[9] = _expand_key_helper(MKASSIST(round_keys[10], 0x01)); - round_keys[8] = _expand_key_helper(MKASSIST(round_keys[ 9], 0x02)); - round_keys[7] = _expand_key_helper(MKASSIST(round_keys[ 8], 0x04)); - round_keys[6] = _expand_key_helper(MKASSIST(round_keys[ 7], 0x08)); - round_keys[5] = _expand_key_helper(MKASSIST(round_keys[ 6], 0x10)); - round_keys[4] = _expand_key_helper(MKASSIST(round_keys[ 5], 0x20)); - round_keys[3] = _expand_key_helper(MKASSIST(round_keys[ 4], 0x40)); - round_keys[2] = _expand_key_helper(MKASSIST(round_keys[ 3], 0x80)); - round_keys[1] = _expand_key_helper(MKASSIST(round_keys[ 2], 0x1b)); - round_keys[0] = _expand_key_helper(MKASSIST(round_keys[ 1], 0x36)); + round_keys[ 9] = _expand_key_helper(MKASSIST(round_keys[10], 0x01)); + round_keys[ 8] = _expand_key_helper(MKASSIST(round_keys[ 9], 0x02)); + round_keys[ 7] = _expand_key_helper(MKASSIST(round_keys[ 8], 0x04)); + round_keys[ 6] = _expand_key_helper(MKASSIST(round_keys[ 7], 0x08)); + round_keys[ 5] = _expand_key_helper(MKASSIST(round_keys[ 6], 0x10)); + round_keys[ 4] = _expand_key_helper(MKASSIST(round_keys[ 5], 0x20)); + round_keys[ 3] = _expand_key_helper(MKASSIST(round_keys[ 4], 0x40)); + round_keys[ 2] = _expand_key_helper(MKASSIST(round_keys[ 3], 0x80)); + round_keys[ 1] = _expand_key_helper(MKASSIST(round_keys[ 2], 0x1b)); + round_keys[ 0] = _expand_key_helper(MKASSIST(round_keys[ 1], 0x36)); for (int i = 1; i < 10; i++) { round_keys[i] = _mm_aesimc_si128(round_keys[i]); } diff --git a/lib/Hashinfo.cpp b/lib/Hashinfo.cpp index 17c9b542..980204e5 100644 --- a/lib/Hashinfo.cpp +++ b/lib/Hashinfo.cpp @@ -52,13 +52,13 @@ uint32_t HashInfo::_ComputedVerifyImpl( const HashInfo * hinfo, enum HashInfo::e const uint32_t hashbits = hinfo->bits; const uint32_t hashbytes = hashbits / 8; - uint8_t * key = new uint8_t[256 ]; + uint8_t * key = new uint8_t[ 256]; uint8_t * hashes = new uint8_t[hashbytes * 256]; uint8_t * total = new uint8_t[hashbytes ]; - memset(key , 0, 256); + memset(key , 0, 256); memset(hashes, 0, hashbytes * 256); - memset(total , 0, hashbytes); + memset(total , 0, hashbytes); // Hash keys of the form {}, {0}, {0,1}, {0,1,2}... up to N=255, using // 256-N as the seed @@ -74,8 +74,8 @@ uint32_t HashInfo::_ComputedVerifyImpl( const HashInfo * hinfo, enum HashInfo::e seed_t seed = 0; seed = hinfo->Seed(0, true, 1); hash(hashes, hashbytes * 256, seed, total); - addVCodeOutput(hashes, 256 * hashbytes); - addVCodeOutput(total , hashbytes ); + addVCodeOutput(hashes, 256 * hashbytes); + addVCodeOutput(total , hashbytes); // The first four bytes of that hash, interpreted as a little-endian // integer, is our verification value diff --git a/lib/Hashlib.cpp b/lib/Hashlib.cpp index f948a3aa..856316b4 100644 --- a/lib/Hashlib.cpp +++ b/lib/Hashlib.cpp @@ -237,8 +237,8 @@ bool verifyAllHashes( bool verbose ) { } else { // Always verify little-endian first, just for consistency // for humans looking at the results. - result &= verifyHash(h, HashInfo::ENDIAN_LITTLE, verbose); - result &= verifyHash(h, HashInfo::ENDIAN_BIG , verbose); + result &= verifyHash(h, HashInfo::ENDIAN_LITTLE , verbose); + result &= verifyHash(h, HashInfo::ENDIAN_BIG , verbose); } } printf("\n"); diff --git a/main.cpp b/main.cpp index b7425da7..15ad652d 100644 --- a/main.cpp +++ b/main.cpp @@ -608,12 +608,12 @@ static bool testHash( const char * name ) { static void usage( void ) { printf("Usage: SMHasher3 [--[no]test=[,...]] [--extra] [--seed=]\n" - " [--endian=default|nondefault|native|nonnative|big|little]\n" - " [--verbose] [--vcode] [--ncpu=N] []\n" - "\n" - " SMHasher3 [--list]|[--listnames]|[--tests]|[--version]\n" - "\n" - " Hashnames can be supplied using any case letters.\n"); + " [--endian=default|nondefault|native|nonnative|big|little]\n" + " [--verbose] [--vcode] [--ncpu=N] []\n" + "\n" + " SMHasher3 [--list]|[--listnames]|[--tests]|[--version]\n" + "\n" + " Hashnames can be supplied using any case letters.\n"); } #if defined(DEBUG) diff --git a/tests/DiffDistributionTest.cpp b/tests/DiffDistributionTest.cpp index 7feda675..fee78674 100644 --- a/tests/DiffDistributionTest.cpp +++ b/tests/DiffDistributionTest.cpp @@ -63,8 +63,8 @@ template static bool DiffDistTest2( HashFn hash, const seed_t seed, bool drawDiagram ) { Rand r( 857374 ); - int keybits = sizeof(keytype) * 8; - const int keycount = 256 * 256 * 32; + int keybits = sizeof(keytype) * 8; + const int keycount = 256 * 256 * 32; keytype k; std::vector hashes( keycount ); diff --git a/tests/DifferentialTest.cpp b/tests/DifferentialTest.cpp index 26ef2f2a..9d834ce9 100644 --- a/tests/DifferentialTest.cpp +++ b/tests/DifferentialTest.cpp @@ -259,9 +259,9 @@ bool DiffTest( const HashInfo * hinfo, const bool verbose, const bool extra ) { const seed_t seed = hinfo->Seed(g_seed); - result &= DiffTestImpl, hashtype>(hash, seed, 5, reps, dumpCollisions); - result &= DiffTestImpl, hashtype >(hash, seed, 4, reps, dumpCollisions); - result &= DiffTestImpl, hashtype >(hash, seed, 3, reps, dumpCollisions); + result &= DiffTestImpl, hashtype>(hash, seed, 5, reps, dumpCollisions); + result &= DiffTestImpl, hashtype>(hash, seed, 4, reps, dumpCollisions); + result &= DiffTestImpl, hashtype>(hash, seed, 3, reps, dumpCollisions); printf("%s\n", result ? "" : g_failstr); diff --git a/tests/PerlinNoiseTest.cpp b/tests/PerlinNoiseTest.cpp index fb0cc4c8..1430b122 100644 --- a/tests/PerlinNoiseTest.cpp +++ b/tests/PerlinNoiseTest.cpp @@ -60,23 +60,23 @@ //----------------------------------------------------------------------------- // Keyset 'Perlin Noise' - X,Y coordinates on input & seed +#define INPUT_LEN_MAX 256 + template static bool PerlinNoise( int Xbits, int Ybits, int inputLen, int step, const HashInfo * hinfo, bool testColl, bool testDist, bool drawDiagram ) { - assert( 0 < Ybits && Ybits < 31); - assert( 0 < Xbits && Xbits < 31); - assert( Xbits + Ybits < 31 ); - assert(inputLen * 8 > Xbits ); // enough space to run the test + assert(0 < Ybits && Ybits < 31 ); + assert(0 < Xbits && Xbits < 31 ); + assert(Xbits + Ybits < 31 ); + assert(inputLen * 8 > Xbits ); // enough space to run the test + assert(inputLen <= INPUT_LEN_MAX); std::vector hashes; + uint8_t key[INPUT_LEN_MAX] = { 0 }; int const xMax = (1 << Xbits); int const yMax = (1 << Ybits); const HashFn hash = hinfo->hashFn(g_hashEndian); -#define INPUT_LEN_MAX 256 - assert(inputLen <= INPUT_LEN_MAX ); - uint8_t key[INPUT_LEN_MAX] = { 0 }; - printf("Generating coordinates from %3i-byte keys - %d keys\n", inputLen, xMax * yMax); addVCodeInput(yMax); diff --git a/tests/SanityTest.cpp b/tests/SanityTest.cpp index 01a2e860..8811166d 100644 --- a/tests/SanityTest.cpp +++ b/tests/SanityTest.cpp @@ -619,9 +619,10 @@ bool PrependedZeroesTest( const HashInfo * hinfo, const seed_t seed, bool verbos } void SanityTestHeader( void ) { - printf("%-25s %13s %13s %13s\n", "Name", " Sanity 1+2 ", " Zeroes ", " Thread-safe "); - printf("%-25s %13s %13s %13s\n", "-------------------------", - "-------------", "-------------", "-------------"); + printf("%-25s %13s %13s %13s\n", + "Name", " Sanity 1+2 ", " Zeroes ", " Thread-safe "); + printf("%-25s %13s %13s %13s\n", + "-------------------------", "-------------", "-------------", "-------------"); } bool SanityTest( const HashInfo * hinfo, bool oneline ) { diff --git a/tests/SeedTest.cpp b/tests/SeedTest.cpp index 2af3c57c..372bba4f 100644 --- a/tests/SeedTest.cpp +++ b/tests/SeedTest.cpp @@ -75,7 +75,7 @@ static bool SeedTestImpl( const HashInfo * hinfo, bool drawDiagram ) { const char text[64] = "The quick brown fox jumps over the lazy dog"; const int len = (int)strlen(text); - addVCodeInput(text , len); + addVCodeInput(text, len); addVCodeInput(totalkeys); //---------- @@ -118,7 +118,7 @@ static bool SparseSeedTestImpl( const HashInfo * hinfo, uint32_t maxbits, bool d const char text[64] = "Sphinx of black quartz, judge my vow"; const int len = (int)strlen(text); - addVCodeInput(text , len); + addVCodeInput(text, len); addVCodeInput(totalkeys); //---------- @@ -173,10 +173,10 @@ bool SeedTest( const HashInfo * hinfo, const bool verbose ) { if (hinfo->is32BitSeed()) { result &= SeedTestImpl (hinfo , verbose); - result &= SparseSeedTestImpl(hinfo, 7, verbose); + result &= SparseSeedTestImpl(hinfo, 7, verbose); } else { result &= SeedTestImpl (hinfo , verbose); - result &= SparseSeedTestImpl(hinfo, 5, verbose); + result &= SparseSeedTestImpl(hinfo, 5, verbose); } printf("%s\n", result ? "" : g_failstr); diff --git a/tests/SpeedTest.cpp b/tests/SpeedTest.cpp index 07bd185e..62534865 100644 --- a/tests/SpeedTest.cpp +++ b/tests/SpeedTest.cpp @@ -59,8 +59,8 @@ #include #include -constexpr int BULK_TRIALS = 2999; // Timings per hash for large (>=128b) keys -constexpr int TINY_TRIALS = 200; // Timings per hash for small (<128b) keys +constexpr int BULK_TRIALS = 2999; // Timings per hash for large (>=128b) keys +constexpr int TINY_TRIALS = 200; // Timings per hash for small (<128b) keys constexpr int TINY_SAMPLES = 15000; // Samples per timing run for small sizes //----------------------------------------------------------------------------- @@ -301,9 +301,10 @@ bool SpeedTest( const HashInfo * hinfo ) { void ShortSpeedTestHeader( void ) { printf("Bulk results are in bytes/cycle, short results are in cycles/hash\n\n"); - printf("%-25s %11s %18s %18s %18s %18s \n", "Name", " Bulk ", - " 1-8 bytes ", "9-16 bytes", "17-24 bytes", "25-32 bytes"); - printf("%-25s %11s %18s %18s %18s %18s \n", "-------------------------", "-----------", "------------------", + printf("%-25s %11s %18s %18s %18s %18s \n", + "Name", " Bulk ", " 1-8 bytes ", "9-16 bytes", "17-24 bytes", "25-32 bytes"); + printf("%-25s %11s %18s %18s %18s %18s \n", + "-------------------------", "-----------", "------------------", "------------------", "------------------", "------------------"); } diff --git a/tests/SpeedTest.h b/tests/SpeedTest.h index f6551c7d..67bc6604 100644 --- a/tests/SpeedTest.h +++ b/tests/SpeedTest.h @@ -43,6 +43,7 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ + bool SpeedTest( const HashInfo * info ); void ShortSpeedTest( const HashInfo * hinfo ); void ShortSpeedTestHeader( void ); diff --git a/util/Analyze.cpp b/util/Analyze.cpp index 784adb64..92d980c8 100644 --- a/util/Analyze.cpp +++ b/util/Analyze.cpp @@ -343,10 +343,10 @@ static void CountRangedNbCollisions( std::vector & hashes, uint64_t co // width corresponding to index i int coll = 0; for (int i = collbins - 1; i >= maxcollbins; i--) { - coll += collcounts [i]; + coll += collcounts[i]; } for (int i = maxcollbins - 1; i > hzb - minHBits; i--) { - coll += collcounts[i]; + coll += collcounts[i]; // See if this is the new peak for this window width maxcoll[i] = std::max(maxcoll[i], coll - prevcoll[i]); // Record the total number of collisions seen so far at this diff --git a/util/Blob.h b/util/Blob.h index 50f667f4..09a66934 100644 --- a/util/Blob.h +++ b/util/Blob.h @@ -255,11 +255,11 @@ class Blob { if (start <= (bitlen - 25)) { memcpy(&v, &bytes[start >> 3], 4); v = COND_BSWAP(v, isBE()); - v >>= (start & 7 ); + v >>= (start & 7); } else { memcpy(&v, &bytes[len - 4], 4); v = COND_BSWAP(v, isBE()); - v >>= 32 + start - bitlen; + v >>= (32 + start - bitlen); if ((start + count) > bitlen) { uint32_t v2; memcpy(&v2, bytes, 4); @@ -326,15 +326,15 @@ FORCE_INLINE void Blob<32>::reversebits( void ) { uint32_t v = GET_U32(bytes, 0); // swap odd and even bits - v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1); + v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1); // swap consecutive pairs - v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2); + v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2); // swap nibbles ... - v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4); + v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4); // swap bytes - v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8); + v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8); // swap 2-byte long pairs - v = ((v >> 16) ) | ((v) << 16); + v = ((v >> 16) ) | ((v ) << 16); PUT_U32(v, bytes, 0); } @@ -353,7 +353,7 @@ FORCE_INLINE void Blob<64>::reversebits( void ) { // swap 2-byte long pairs v = ((v >> 16) & UINT64_C(0x0000FFFF0000FFFF)) | ((v & UINT64_C(0x0000FFFF0000FFFF)) << 16); // swap 4-byte long pairs - v = ((v >> 32)) | ((v) << 32); + v = ((v >> 32) ) | ((v ) << 32); PUT_U64(v, bytes, 0); } diff --git a/util/Blobsort.cpp b/util/Blobsort.cpp index 2b180098..145619db 100644 --- a/util/Blobsort.cpp +++ b/util/Blobsort.cpp @@ -244,9 +244,8 @@ static bool AND( bool in ) { return in; } -template +template typename std::enable_if::value, bool>::type - static AND( bool in ) { return test_blobsort_type() && AND(in); } diff --git a/util/Blobsort.h b/util/Blobsort.h index bee308a0..3f2ae139 100644 --- a/util/Blobsort.h +++ b/util/Blobsort.h @@ -108,7 +108,7 @@ static void flagsort( T * begin, T * end, int idx ) { // counts depend on all previous bytes, since each pass operates on // a successively smaller subset of the total list to sort. size_t freqs[RADIX_SIZE] = {}; - T * ptr = begin; + T * ptr = begin; do { ++freqs[(*ptr)[idx]]; } while (++ptr < (end - 1)); diff --git a/util/VCode.cpp b/util/VCode.cpp index 4f89d828..7289e255 100644 --- a/util/VCode.cpp +++ b/util/VCode.cpp @@ -66,40 +66,40 @@ static inline void crc32c_sw_update( uint32_t * const crcptr, const void * const crc ^= wd1; if (isBE()) { crc = - crc32c_sw_table[15][crc & 0xff] ^ + crc32c_sw_table[15][ crc & 0xff] ^ crc32c_sw_table[14][(crc >> 8) & 0xff] ^ crc32c_sw_table[13][(crc >> 16) & 0xff] ^ crc32c_sw_table[12][(crc >> 24) & 0xff] ^ crc32c_sw_table[11][(crc >> 32) & 0xff] ^ crc32c_sw_table[10][(crc >> 40) & 0xff] ^ crc32c_sw_table[ 9][(crc >> 48) & 0xff] ^ - crc32c_sw_table[ 8][crc >> 56] ^ - crc32c_sw_table[ 0][wd2 & 0xff] ^ + crc32c_sw_table[ 8][ crc >> 56 ] ^ + crc32c_sw_table[ 0][ wd2 & 0xff] ^ crc32c_sw_table[ 1][(wd2 >> 8) & 0xff] ^ crc32c_sw_table[ 2][(wd2 >> 16) & 0xff] ^ crc32c_sw_table[ 3][(wd2 >> 24) & 0xff] ^ crc32c_sw_table[ 4][(wd2 >> 32) & 0xff] ^ crc32c_sw_table[ 5][(wd2 >> 40) & 0xff] ^ crc32c_sw_table[ 6][(wd2 >> 48) & 0xff] ^ - crc32c_sw_table[ 7][wd2 >> 56]; + crc32c_sw_table[ 7][ wd2 >> 56 ]; } else { crc = - crc32c_sw_table[15][crc & 0xff] ^ + crc32c_sw_table[15][ crc & 0xff] ^ crc32c_sw_table[14][(crc >> 8) & 0xff] ^ crc32c_sw_table[13][(crc >> 16) & 0xff] ^ crc32c_sw_table[12][(crc >> 24) & 0xff] ^ crc32c_sw_table[11][(crc >> 32) & 0xff] ^ crc32c_sw_table[10][(crc >> 40) & 0xff] ^ crc32c_sw_table[ 9][(crc >> 48) & 0xff] ^ - crc32c_sw_table[ 8][crc >> 56] ^ - crc32c_sw_table[ 7][wd2 & 0xff] ^ + crc32c_sw_table[ 8][ crc >> 56 ] ^ + crc32c_sw_table[ 7][ wd2 & 0xff] ^ crc32c_sw_table[ 6][(wd2 >> 8) & 0xff] ^ crc32c_sw_table[ 5][(wd2 >> 16) & 0xff] ^ crc32c_sw_table[ 4][(wd2 >> 24) & 0xff] ^ crc32c_sw_table[ 3][(wd2 >> 32) & 0xff] ^ crc32c_sw_table[ 2][(wd2 >> 40) & 0xff] ^ crc32c_sw_table[ 1][(wd2 >> 48) & 0xff] ^ - crc32c_sw_table[ 0][wd2 >> 56]; + crc32c_sw_table[ 0][ wd2 >> 56 ]; } next += 16; len -= 16; @@ -246,15 +246,15 @@ static uint32_t vcode_crc_selftest_40( uint8_t offset ) { crc32c_hw_update(&crc, buf, 40); } else #endif - crc32c_sw_update(&crc, buf, 40); + crc32c_sw_update(&crc, buf, 40); } else { #if defined(HWCRC_U64) if (use_hw) { - crc32c_hw_update(&crc, &buf[0] , 1); - crc32c_hw_update(&crc, &buf[1] , 1); - crc32c_hw_update(&crc, &buf[2] , 2); - crc32c_hw_update(&crc, &buf[4] , 4); - crc32c_hw_update(&crc, &buf[8] , 8); + crc32c_hw_update(&crc, &buf[ 0], 1); + crc32c_hw_update(&crc, &buf[ 1], 1); + crc32c_hw_update(&crc, &buf[ 2], 2); + crc32c_hw_update(&crc, &buf[ 4], 4); + crc32c_hw_update(&crc, &buf[ 8], 8); crc32c_hw_update(&crc, &buf[16], 16); crc32c_hw_update(&crc, &buf[32], 1); crc32c_hw_update(&crc, &buf[33], 1); @@ -262,18 +262,18 @@ static uint32_t vcode_crc_selftest_40( uint8_t offset ) { crc32c_hw_update(&crc, &buf[36], 4); } else { #endif - crc32c_sw_update(&crc, &buf[0] , 1); - crc32c_sw_update(&crc, &buf[1] , 1); - crc32c_sw_update(&crc, &buf[2] , 2); - crc32c_sw_update(&crc, &buf[4] , 4); - crc32c_sw_update(&crc, &buf[8] , 8); - crc32c_sw_update(&crc, &buf[16], 16); - crc32c_sw_update(&crc, &buf[32], 1); - crc32c_sw_update(&crc, &buf[33], 1); - crc32c_sw_update(&crc, &buf[34], 2); - crc32c_sw_update(&crc, &buf[36], 4); + crc32c_sw_update(&crc, &buf[ 0], 1); + crc32c_sw_update(&crc, &buf[ 1], 1); + crc32c_sw_update(&crc, &buf[ 2], 2); + crc32c_sw_update(&crc, &buf[ 4], 4); + crc32c_sw_update(&crc, &buf[ 8], 8); + crc32c_sw_update(&crc, &buf[16], 16); + crc32c_sw_update(&crc, &buf[32], 1); + crc32c_sw_update(&crc, &buf[33], 1); + crc32c_sw_update(&crc, &buf[34], 2); + crc32c_sw_update(&crc, &buf[36], 4); #if defined(HWCRC_U64) - } + } #endif } diff --git a/util/VCode.h b/util/VCode.h index b09eddbb..0fa2895b 100644 --- a/util/VCode.h +++ b/util/VCode.h @@ -135,14 +135,14 @@ static inline uint32_t crc32c_update_sw_u64( uint32_t crc, uint64_t data ) { uint64_t crc64 = crc ^ data; crc64 = - crc32c_sw_table[7][crc64 & 0xff] ^ + crc32c_sw_table[7][ crc64 & 0xff] ^ crc32c_sw_table[6][(crc64 >> 8) & 0xff] ^ crc32c_sw_table[5][(crc64 >> 16) & 0xff] ^ crc32c_sw_table[4][(crc64 >> 24) & 0xff] ^ crc32c_sw_table[3][(crc64 >> 32) & 0xff] ^ crc32c_sw_table[2][(crc64 >> 40) & 0xff] ^ crc32c_sw_table[1][(crc64 >> 48) & 0xff] ^ - crc32c_sw_table[0][crc64 >> 56]; + crc32c_sw_table[0][ crc64 >> 56 ]; return (uint32_t)crc64; }