Protect left shift from shifting too far.
On some systems, 1UL<<X will make a mess if X is the size of an unsigned long. This especially seems to be a problem on i386 systems. Protect those shifts in the vvp_net.cc.
This commit is contained in:
parent
a12a6d925a
commit
5ddd35565f
|
|
@ -363,12 +363,13 @@ unsigned long* vvp_vector4_t::subarray(unsigned adr, unsigned wid) const
|
||||||
through that word. */
|
through that word. */
|
||||||
unsigned long atmp = abits_val_ >> adr;
|
unsigned long atmp = abits_val_ >> adr;
|
||||||
unsigned long btmp = bbits_val_ >> adr;
|
unsigned long btmp = bbits_val_ >> adr;
|
||||||
atmp &= (1UL << wid) - 1;
|
if (wid < BIT2_PER_WORD) {
|
||||||
btmp &= (1UL << wid) - 1;
|
atmp &= (1UL << wid) - 1;
|
||||||
|
btmp &= (1UL << wid) - 1;
|
||||||
|
}
|
||||||
if (btmp) goto x_out;
|
if (btmp) goto x_out;
|
||||||
|
|
||||||
val[0] = atmp;
|
val[0] = atmp;
|
||||||
return val;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
@ -385,19 +386,21 @@ unsigned long* vvp_vector4_t::subarray(unsigned adr, unsigned wid) const
|
||||||
btmp >>= off;
|
btmp >>= off;
|
||||||
|
|
||||||
unsigned long trans = BITS_PER_WORD - off;
|
unsigned long trans = BITS_PER_WORD - off;
|
||||||
if (trans > (8*sizeof(val[0]) - val_off))
|
if (trans > (BIT2_PER_WORD - val_off))
|
||||||
trans = 8*sizeof(val[0]) - val_off;
|
trans = BIT2_PER_WORD - val_off;
|
||||||
if (wid < trans)
|
if (wid < trans)
|
||||||
trans = wid;
|
trans = wid;
|
||||||
atmp &= (1UL << trans) - 1;
|
if (trans < BIT2_PER_WORD) {
|
||||||
btmp &= (1UL << trans) - 1;
|
atmp &= (1UL << trans) - 1;
|
||||||
|
btmp &= (1UL << trans) - 1;
|
||||||
|
}
|
||||||
if (btmp) goto x_out;
|
if (btmp) goto x_out;
|
||||||
|
|
||||||
val[val_ptr] |= atmp << val_off;
|
val[val_ptr] |= atmp << val_off;
|
||||||
adr += trans;
|
adr += trans;
|
||||||
wid -= trans;
|
wid -= trans;
|
||||||
val_off += trans;
|
val_off += trans;
|
||||||
if (val_off == 8*sizeof(val[0])) {
|
if (val_off == BIT2_PER_WORD) {
|
||||||
val_ptr += 1;
|
val_ptr += 1;
|
||||||
val_off = 0;
|
val_off = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -572,7 +575,6 @@ void vvp_vector4_t::set_vec(unsigned adr, const vvp_vector4_t&that)
|
||||||
((that.bbits_ptr_[sptr] >> (remain-tail))&mask);
|
((that.bbits_ptr_[sptr] >> (remain-tail))&mask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue