Changeset 1869 for trunk


Ignore:
Timestamp:
Jan 21, 2012, 1:31:11 PM (7 years ago)
Author:
ksherdy
Message:

Updated routine to 'slice' at a position.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/byte_util.hpp

    r1868 r1869  
    77using namespace std;
    88
    9 /* WARNING - Buffer pointer cast to integer type; padding of additional bytes may be necessary. */
     9/* WARNING - Buffer pointer cast to integer type. Pad bytes as necessary. */
    1010
    1111template<class T, uint32_t SF>
     
    1515static IDISA_ALWAYS_INLINE T slice(const uint8_t * buffer, const uint32_t pos, const uint32_t lgth) {
    1616
    17     assert(sizeof(T)>lgth);
     17    T shift = *((T *)(buffer+pos)); // >> (pos * SF);
     18
     19    // if(lgth != sizeof(T)) {
    1820
    1921    const T ZERO  = 0;
    20     T shift = (*((T *)buffer)) >> (pos * SF);
    2122    T mask = ~(~ZERO << (lgth * SF));
    2223    return shift & mask;
     24
     25    // }  else { return shift; }
     26
    2327}
    2428
Note: See TracChangeset for help on using the changeset viewer.