Ignore:
Timestamp:
Jan 6, 2012, 6:19:33 PM (7 years ago)
Author:
ksherdy
Message:

Update byte compare routine. Added generatated test cases.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/byte_compare.hpp

    r1816 r1827  
    77    Licensed to International Characters Inc.
    88       under the Academic Free License version 3.0.
    9 
    109*/
    1110
     
    1716#include "bitblock.hpp"
    1817
     18#include <iostream>
     19using namespace std;
    1920
    2021template<class T>
     
    3031IDISA_ALWAYS_INLINE bool overlap_compare(const T * x, const T * y) {
    3132    bool accum = true;
     33//cout << "accum: " << accum << endl;
     34
     35    uint8_t * p_x = (uint8_t *)x;
     36    uint8_t * p_y = (uint8_t *)y;
     37
    3238    for(int i=0; i < L/sizeof(T); i++) {
    33         accum &= compare(x,y,0);
    34         x++;
    35         y++;
     39
     40//cout << "x " << *( (T*)(p_x) ) << endl;
     41//cout << "y " << *( (T*)(p_y) ) << endl;
     42//      cout << compare(p_x,p_y,0) << endl;
     43        accum = accum && compare(p_x,p_y,0);
     44        p_x += sizeof(T);
     45        p_y += sizeof(T);
     46//cout << (void *)p_x << endl;
     47//cout << (void *)p_y << endl;
     48//cout << "accum: " << accum << endl;
    3649    }
    3750    if(L & (sizeof(T)-1)) {
    38         accum &= compare(x,y,L-sizeof(T));
    39     }
     51//      cout << L - sizeof(T) << endl;
     52        accum = accum && compare(x,y,L-sizeof(T));
     53
     54//cout << "x " << *( (T*)( (uint8_t *)x + L-sizeof(T)) ) << endl;
     55//cout << "y " << *( (T*)( (uint8_t *)y + L-sizeof(T)) ) << endl;
     56
     57//cout << "accum: " << accum << endl; 
     58  }
    4059    return accum;
    4160}
     
    4362template<class T>
    4463IDISA_ALWAYS_INLINE bool compare(const T * x, const T * y, const uint32_t offset) {
     64 
    4565    return !((*((T*)((uint8_t *)x + offset))) ^
    4666             (*((T*)((uint8_t *)y + offset))));
Note: See TracChangeset for help on using the changeset viewer.