Browse Source

Compilation fixes on specific platforms (e.g. debian 8)

pull/271/head
Luca Deri 4 years ago
parent
commit
d610308156
  1. 18
      pearson.c

18
pearson.c

@ -79,8 +79,10 @@ void pearson_hash_256 (uint8_t *out, const uint8_t *in, size_t len) {
uint8_t upper[8] = { 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 };
uint8_t lower[8] = { 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
uint64_t upper_hash_mask = *(uint64_t*)&upper;
uint64_t lower_hash_mask = *(uint64_t*)&lower;
uint64_t *upper_hash_mask_ptr = (uint64_t*)&upper;
uint64_t *lower_hash_mask_ptr = (uint64_t*)&lower;
uint64_t upper_hash_mask = *upper_hash_mask_ptr;
uint64_t lower_hash_mask = *lower_hash_mask_ptr;
uint64_t high_upper_hash_mask = upper_hash_mask + 0x1010101010101010;
uint64_t high_lower_hash_mask = lower_hash_mask + 0x1010101010101010;
@ -88,8 +90,9 @@ void pearson_hash_256 (uint8_t *out, const uint8_t *in, size_t len) {
uint64_t lower_hash = 0;
uint64_t high_upper_hash = 0;
uint64_t high_lower_hash = 0;
size_t i;
for (size_t i = 0; i < len; i++) {
for (i = 0; i < len; i++) {
// broadcast the character, xor into hash, make them different permutations
uint64_t c = (uint8_t)in[i];
c |= c << 8;
@ -168,13 +171,16 @@ void pearson_hash_128 (uint8_t *out, const uint8_t *in, size_t len) {
uint8_t upper[8] = { 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08 };
uint8_t lower[8] = { 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00 };
uint64_t upper_hash_mask = *(uint64_t*)&upper;
uint64_t lower_hash_mask = *(uint64_t*)&lower;
uint64_t *upper_hash_mask_ptr = (uint64_t*)&upper;
uint64_t *lower_hash_mask_ptr = (uint64_t*)&lower;
uint64_t upper_hash_mask = *upper_hash_mask_ptr;
uint64_t lower_hash_mask = *lower_hash_mask_ptr;
uint64_t upper_hash = 0;
uint64_t lower_hash = 0;
size_t i;
for (size_t i = 0; i < len; i++) {
for (i = 0; i < len; i++) {
// broadcast the character, xor into hash, make them different permutations
uint64_t c = (uint8_t)in[i];
c |= c << 8;

Loading…
Cancel
Save