Changeset 1852 for trunk


Ignore:
Timestamp:
Jan 18, 2012, 5:25:04 PM (7 years ago)
Author:
ksherdy
Message:

Update template parameter structure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/byte_compare.hpp

    r1841 r1852  
    2626#define BYTE_COMPARE_HPP
    2727
     28#include "bitblock.hpp"
    2829#include <string.h>
    2930#include <stdint.h>
    30 #include "bitblock.hpp"
    31 
    3231#include <iostream>
    3332using namespace std;
    3433
    35 template<class T, uint32_t L> IDISA_ALWAYS_INLINE bool overlap_compare(const T * x, const T * y);
    36 template<class T> IDISA_ALWAYS_INLINE bool overlap_compare(const T * x, const T* y, uint32_t lgth);
    37 template<class T> IDISA_ALWAYS_INLINE bool compare(const T * x, const T * y, const uint32_t offset);
     34template<class T, uint32_t L> IDISA_ALWAYS_INLINE bool overlap_compare(const uint8_t * x, const uint8_t * y);
     35template<class T> IDISA_ALWAYS_INLINE bool overlap_compare(const uint8_t * x, const uint8_t * y, uint32_t lgth);
     36template<class T> IDISA_ALWAYS_INLINE bool compare(const uint8_t * x, const uint8_t * y, const uint32_t offset);
    3837IDISA_ALWAYS_INLINE bool mem_compare(const unsigned char * x, const unsigned char * y, uint32_t lgth);
    3938
    40 
    4139template<class T, uint32_t L>
    42 IDISA_ALWAYS_INLINE bool overlap_compare(const T * x, const T * y) {
     40IDISA_ALWAYS_INLINE bool overlap_compare(const uint8_t * x, const uint8_t * y) {
    4341
    4442    bool accum = true;
    45     T * p_x = (T*) x;
    46     T * p_y = (T*) y;
     43    uint8_t * p_x = (uint8_t*)x;
     44    uint8_t * p_y = (uint8_t*)y;
    4745
    4846    for(int i=0; i < L/sizeof(T); i++) {
    49         accum = accum && compare(p_x,p_y,0);
    50         p_x++;
    51         p_y++;
     47        accum = accum && compare<T>(p_x,p_y,0);
     48        p_x+=sizeof(T);
     49        p_y+=sizeof(T);
    5250    }
    5351    if(L & (sizeof(T)-1)) {
    54         accum = accum && compare(x,y,L-sizeof(T));
     52        accum = accum && compare<T>(x,y,L-sizeof(T));
    5553    }
    5654    return accum;
     
    5856
    5957template<class T>
    60 IDISA_ALWAYS_INLINE bool overlap_compare(const T * x, const T* y, uint32_t lgth) {
     58IDISA_ALWAYS_INLINE bool overlap_compare(const uint8_t * x, const uint8_t * y, uint32_t lgth) {
    6159
    6260    bool accum = true;
    63     T * p_x = (T*) x;
    64     T * p_y = (T*) y;
     61    uint8_t * p_x = (uint8_t*)x;
     62    uint8_t * p_y = (uint8_t*)y;
    6563
    6664    for(int i=0; i < lgth/sizeof(T); i++) {
    67         accum = accum && compare(p_x,p_y,0);
    68         p_x++;
    69         p_y++;
     65        accum = accum && compare<T>(p_x,p_y,0);
     66        p_x+=sizeof(T);
     67        p_y+=sizeof(T);
    7068    }
    7169    if(lgth & (sizeof(T)-1)) {
    72         accum = accum && compare(x,y,lgth-sizeof(T));
     70        accum = accum && compare<T>(x,y,lgth-sizeof(T));
    7371    }
    7472    return accum;
     
    7674
    7775template<class T>
    78 IDISA_ALWAYS_INLINE bool compare(const T * x, const T * y, const uint32_t offset) {
     76IDISA_ALWAYS_INLINE bool compare(const uint8_t * x, const uint8_t * y, const uint32_t offset) {
    7977    return !((*((T*)((uint8_t *)x + offset))) ^
    8078             (*((T*)((uint8_t *)y + offset))));
     
    8280
    8381template<>
    84 IDISA_ALWAYS_INLINE bool compare<BitBlock>(const BitBlock * x, const BitBlock * y, const uint32_t offset) {
     82IDISA_ALWAYS_INLINE bool compare<BitBlock>(const uint8_t * x, const uint8_t * y, const uint32_t offset) {
    8583    BitBlock temp = simd_xor(bitblock::load_unaligned((BitBlock*) ((uint8_t *)x + offset)),
    8684                             bitblock::load_unaligned((BitBlock*) ((uint8_t *)y + offset)));
Note: See TracChangeset for help on using the changeset viewer.