Skip to content

Commit

Permalink
Manual formatting fixups (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
fwojcik committed Jul 21, 2022
1 parent 6cb4b33 commit 225f3c1
Show file tree
Hide file tree
Showing 43 changed files with 449 additions and 442 deletions.
6 changes: 3 additions & 3 deletions hashes/beamsplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<bswap>(h[0], (uint8_t *)out, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion hashes/blake2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
};
Expand Down
5 changes: 2 additions & 3 deletions hashes/blake3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
70 changes: 35 additions & 35 deletions hashes/blake3/compress-portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]]);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions hashes/blake3/compress-sse2.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}

Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions hashes/blake3/compress-sse41.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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]);
}

Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions hashes/blockpearson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ template <bool bswap>
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);

Expand Down Expand Up @@ -121,8 +121,8 @@ template <bool bswap>
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);

Expand Down Expand Up @@ -164,8 +164,8 @@ template <bool bswap>
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);

Expand Down
28 changes: 14 additions & 14 deletions hashes/cityhash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ static uint32_t Hash32Len5to12( const uint8_t * s, size_t len, uint32_t seed ) {
template <bool bswap>
static uint32_t Hash32Len13to24( const uint8_t * s, size_t len, uint32_t seed ) {
uint32_t a = Fetch32<bswap>(s - 4 + (len >> 1));
uint32_t b = Fetch32<bswap>(s + 4);
uint32_t c = Fetch32<bswap>(s + len - 8);
uint32_t b = Fetch32<bswap>(s + 4 );
uint32_t c = Fetch32<bswap>(s + len - 8 );
uint32_t d = Fetch32<bswap>(s + (len >> 1));
uint32_t e = Fetch32<bswap>(s);
uint32_t f = Fetch32<bswap>(s + len - 4);
uint32_t e = Fetch32<bswap>(s );
uint32_t f = Fetch32<bswap>(s + len - 4 );
uint32_t h = seed + len;

return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
Expand Down Expand Up @@ -287,8 +287,8 @@ static uint64_t HashLen0to16( const uint8_t * s, size_t len ) {
// in that case.
template <bool bswap>
static uint64_t HashLen17to32( const uint8_t * s, size_t len ) {
uint64_t a = Fetch64<bswap>(s ) * k1;
uint64_t b = Fetch64<bswap>(s + 8);
uint64_t a = Fetch64<bswap>(s ) * k1;
uint64_t b = Fetch64<bswap>(s + 8 );
uint64_t c = Fetch64<bswap>(s + len - 8) * k2;
uint64_t d = Fetch64<bswap>(s + len - 16) * k0;

Expand All @@ -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<bswap>(s + 8);
a += Fetch64<bswap>(s + 8 );
c += ROTR64(a, 7);
a += Fetch64<bswap>(s + 16 );
uint64_t vf = a + z;
Expand Down Expand Up @@ -346,7 +346,7 @@ static uint64_t CityHash64( const uint8_t * s, size_t len ) {
len = (len - 1) & ~static_cast<size_t>(63);
do {
x = ROTR64(x + y + v.first + Fetch64<bswap>(s + 8), 37) * k1;
y = ROTR64(y + v.second + Fetch64 <bswap>(s + 48), 42) * k1;
y = ROTR64(y + v.second + Fetch64<bswap>(s + 48), 42) * k1;
x ^= w.second;
y += v.first + Fetch64<bswap>(s + 40);
z = ROTR64(z + w.first, 33) * k1;
Expand Down Expand Up @@ -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<bswap>(s + 8), 37) * k1;
y = ROTR64(y + v.second + Fetch64 <bswap>(s + 48), 42) * k1;
y = ROTR64(y + v.second + Fetch64<bswap>(s + 48), 42) * k1;
x ^= w.second;
y += v.first + Fetch64<bswap>(s + 40);
z = ROTR64(z + w.first, 33) * k1;
Expand All @@ -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 <bswap>(s + len - tail_done + 16);
w.first += Fetch64<bswap>(s + len - tail_done + 16);
x = x * k0 + w.first;
z += w.second + Fetch64 <bswap>(s + len - tail_done);
z += w.second + Fetch64<bswap>(s + len - tail_done);
w.second += v.first;
v = WeakHashLen32WithSeeds<bswap>(s + len - tail_done, v.first + z, v.second);
}
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 9 additions & 9 deletions hashes/crc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -397,7 +397,7 @@ REGISTER_HASH(CRC_32C,
$.bits = 32,
$.verification_LE = 0x6E6071BD,
$.verification_BE = 0x6E6071BD,
$.initfn = CRC32_init<POLY_CRC32C>,
$.initfn = CRC32_init<POLY_CRC32C>,
$.hashfn_native = CRC32<POLY_CRC32C>,
$.hashfn_bswap = CRC32<POLY_CRC32C>
);
6 changes: 3 additions & 3 deletions hashes/discohash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bswap, false, oldver>(ds, key8Arr , (uint32_t)len);
round<false, false, oldver>(ds, (uint8_t *)seedbuf, 16 );
round<false, true, oldver>( ds, (uint8_t *)ds, STATE );
round<bswap, false, oldver>(ds, key8Arr , (uint32_t)len);
round<false, false, oldver>(ds, (uint8_t *)seedbuf, 16);
round<false, true, oldver>(ds, (uint8_t *)ds , STATE );

/*
*
Expand Down
Loading

0 comments on commit 225f3c1

Please sign in to comment.