diff options
author | Giacomo Travaglini <giacomo.travaglini@arm.com> | 2019-03-21 15:41:04 +0000 |
---|---|---|
committer | Giacomo Travaglini <giacomo.travaglini@arm.com> | 2019-03-22 10:01:10 +0000 |
commit | d94e5b5d91c1a4f29264bee9c13edbdb70d0417e (patch) | |
tree | bb2da4b992981e1588949a5dc644d30b6aae48e3 /src/base/circular_queue.hh | |
parent | bbcbde7a924ca1ca58df997cfe9f750c285e5564 (diff) | |
download | gem5-d94e5b5d91c1a4f29264bee9c13edbdb70d0417e.tar.xz |
base: Fix CircularQueue's operator-= when negative subtraction
Using operator-= when the rhs is a negative value is equivalent
to using += on -rhs. This is fixing rounding in that scenario.
Change-Id: Ia22e51f81a6805d27fd6b2115d288bb23421d00f
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17528
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/base/circular_queue.hh')
-rw-r--r-- | src/base/circular_queue.hh | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/base/circular_queue.hh b/src/base/circular_queue.hh index f368ed0d1..da3da8b28 100644 --- a/src/base/circular_queue.hh +++ b/src/base/circular_queue.hh @@ -323,12 +323,12 @@ class CircularQueue : private std::vector<T> assert(_cq); /* C does not do euclidean division, so we have to adjust */ - if (t >= 0) + if (t >= 0) { _round += (-t + _idx) / _cq->capacity(); - else - _round += (-t + _idx - _cq->capacity() + 1) / _cq->capacity(); - - _idx = _cq->moduloSub(_idx, t); + _idx = _cq->moduloSub(_idx, t); + } else { + *this += -t; + } return *this; } |