diff options
author | Nilay Vaish <nilay@cs.wisc.edu> | 2015-04-29 22:35:22 -0500 |
---|---|---|
committer | Nilay Vaish <nilay@cs.wisc.edu> | 2015-04-29 22:35:22 -0500 |
commit | 3a2731fb8cb0bcb152979fb41ba23ce2b981444f (patch) | |
tree | 250b1ca20fbf7459250388afda8b4242b0b87e12 /src/mem/ruby/common/Set.cc | |
parent | 43335495754abac71377bbd6df0c668b60b22822 (diff) | |
download | gem5-3a2731fb8cb0bcb152979fb41ba23ce2b981444f.tar.xz |
ruby: set: replace long by unsigned long
UBSan complains about negative value being shifted
Diffstat (limited to 'src/mem/ruby/common/Set.cc')
-rw-r--r-- | src/mem/ruby/common/Set.cc | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/mem/ruby/common/Set.cc b/src/mem/ruby/common/Set.cc index 280fe71b4..331aa569a 100644 --- a/src/mem/ruby/common/Set.cc +++ b/src/mem/ruby/common/Set.cc @@ -73,9 +73,9 @@ Set::clearExcess() { // now just ensure that no bits over the maximum size were set #ifdef _LP64 - long mask = 0x7FFFFFFFFFFFFFFF; + unsigned long mask = 0x7FFFFFFFFFFFFFFF; #else - long mask = 0x7FFFFFFF; + unsigned long mask = 0x7FFFFFFF; #endif // the number of populated spaces in the higest-order array slot @@ -132,10 +132,9 @@ int Set::count() const { int counter = 0; - long mask; for (int i = 0; i < m_nArrayLen; i++) { - mask = (long)0x01; + unsigned long mask = 0x01; for (int j = 0; j < LONG_BITS; j++) { // FIXME - significant performance loss when array @@ -172,14 +171,13 @@ NodeID Set::smallestElement() const { assert(count() > 0); - long x; for (int i = 0; i < m_nArrayLen; i++) { if (m_p_nArray[i] != 0) { // the least-set bit must be in here - x = m_p_nArray[i]; + unsigned long x = m_p_nArray[i]; for (int j = 0; j < LONG_BITS; j++) { - if (x & (unsigned long)1) { + if (x & 1) { return LONG_BITS * i + j; } @@ -212,7 +210,7 @@ Set::isBroadcast() const } // now check the last word, which may not be fully loaded - long mask = 1; + unsigned long mask = 1; for (int j = 0; j < (m_nSize % LONG_BITS); j++) { if ((mask & m_p_nArray[m_nArrayLen-1]) == 0) { return false; @@ -306,7 +304,7 @@ Set::setSize(int size) if (m_p_nArray && m_p_nArray != &m_p_nArray_Static[0]) delete [] m_p_nArray; - m_p_nArray = new long[m_nArrayLen]; + m_p_nArray = new unsigned long[m_nArrayLen]; } clear(); |