Changeset 1964


Ignore:
Timestamp:
Mar 24, 2012, 4:04:47 PM (7 years ago)
Author:
ksherdy
Message:

Minor modifications.

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/bitblock.hpp

    r1950 r1964  
    1010=============================================================================*/
    1111
    12 #define NDEBUG //if NDEBUG then disable assertions
     12//#define NDEBUG //if NDEBUG then disable assertions
    1313
    1414#define __STDC_LIMIT_MACROS
  • trunk/lib/hash.hpp

    r1951 r1964  
    88=============================================================================*/
    99
    10 #define HASH_HPP_DEBUG
     10// #define HASH_HPP_DEBUG
    1111
    1212#include "../lib/bitblock.hpp"
     
    2121//
    2222// 'bit_slice' and 'byte_slice' slice forward via a static cast to the
    23 // uint64_t type at the position of the base address + idx
    24 // and require sizeof(uint64_t) bytes of addtional padding.
     23// uint64_t type at the position of the base address + bit_idx
     24// and require up to sizeof(uint64_t) bytes of additional padding.
    2525//
    2626///////////////////////////////////////////////////////////////////////////////
    2727
    2828static int32_t bytes2bits(int32_t bytes) { return bytes * 8; }
    29 static int32_t bits2bytes(int32_t bits) { return (bits + 8) / (8); } // return ((bits & (8-1) != 0) ? (bits + 8) / (8) : (bits/8));
     29static int32_t bits2bytes(int32_t bits) /*{ return (bits + 8) / (8); } */ { return ((bits & (8-1) != 0) ? (bits + 8) / (8) : (bits/8)); }
     30static IDISA_ALWAYS_INLINE uint64_t gen_mask(const uint32_t mask_bits);
    3031
    31 static IDISA_ALWAYS_INLINE uint64_t gen_mask(const uint32_t mask_bits);
    3232//static IDISA_ALWAYS_INLINE uint64_t byte_slice(const uint8_t * base, const int32_t byte_idx, const uint32_t slice_bytes);
     33//static IDISA_ALWAYS_INLINE uint64_t byte_compress_hash(const uint8_t * h0, const uint8_t * h1, const int32_t byte_idx, const uint32_t slice_bytes, const uint32_t hash_bytes);
     34
    3335static IDISA_ALWAYS_INLINE uint64_t bit_slice(const uint8_t * base, const int32_t bit_idx, const uint32_t slice_bits);
    34 static IDISA_ALWAYS_INLINE uint64_t compress_hash(const uint8_t * h0, const uint8_t * h1, const uint32_t slice_bits, const uint32_t hash_bits);
     36static IDISA_ALWAYS_INLINE uint64_t bit_compress_hash(const uint8_t * h0, const uint8_t * h1, const int32_t bit_idx, const uint32_t slice_bits, const uint32_t hash_bits);
    3537
    3638///////////////////////////////////////////////////////////////////////////////
     
    8587}
    8688
    87 static IDISA_ALWAYS_INLINE uint64_t compress_hash(const uint8_t * h0, const uint8_t * h1, const int32_t bit_idx, const uint32_t slice_bits, const uint32_t hash_bits) {
     89static IDISA_ALWAYS_INLINE uint64_t bit_compress_hash(const uint8_t * h0, const uint8_t * h1, const int32_t bit_idx, const uint32_t slice_bits, const uint32_t hash_bits) {
    8890
    89     assert(hash_size > 0 && hash_size <= 64);
    90     assert(slice_size >= hash_size);
     91    assert(hash_bits > 0 && hash_bits <= 64);
     92    assert(slice_bits >= hash_bits);
    9193
    9294    uint64_t x0 = bit_slice(h0,bit_idx,hash_bits);
     
    9496
    9597    assert(x0 != x1);
     98    uint64_t mask = gen_mask(slice_bits);
    9699    uint64_t r = x0 ^ x1;
    97100
     
    104107#endif
    105108
    106     return r;
     109    return r  & mask;
    107110}
    108111
Note: See TracChangeset for help on using the changeset viewer.