Changeset 1887 for trunk


Ignore:
Timestamp:
Jan 27, 2012, 6:40:30 AM (7 years ago)
Author:
cameron
Message:

Allow for signed scanblock_t.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/bitblock_scan.hpp

    r1861 r1887  
    2828        uint32_t blk;
    2929        scanblock_t scan_blk;
     30        /* The test here needs to be != 0, not > 0, in case scanblock_t is signed.*/
     31        IDISA_ALWAYS_INLINE bool has_bit(scanblock_t x) const {return x != 0;};
    3032};
    3133
     
    5052        IDISA_ALWAYS_INLINE uint32_t scan_to_next() {
    5153                while (this->blk < (sizeof(bitblock_t)/sizeof(scanblock_t))){
    52                         if(this->scan_blk > 0){
     54                        if(has_bit(this->scan_blk)){
    5355                                this->pos = scan_forward_zeroes(this->scan_blk) + (this->blk * (sizeof(scanblock_t)*8));
    5456                                this->scan_blk = this->scan_blk & (this->scan_blk-1);  // clear rightmost bit
     
    8890        IDISA_ALWAYS_INLINE uint32_t scan_to_next() {
    8991                while (this->blk > 0){
    90                         if(this->scan_blk > 0){
     92                        if(has_bit(this->scan_blk)){
    9193                                this->pos = (sizeof(scanblock_t)*8 - scan_backward_zeroes(this->scan_blk) -1) + ( (this->blk-1) * sizeof(scanblock_t)*8 );
    9294                                this->scan_blk = this->scan_blk ^ (1 << this->pos); // clear leftmost bit
Note: See TracChangeset for help on using the changeset viewer.