summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorAnthony Gutierrez <atgutier@umich.edu>2012-08-27 20:53:20 -0400
committerAnthony Gutierrez <atgutier@umich.edu>2012-08-27 20:53:20 -0400
commit5b1614de0227b727d16443eec66c2f7900b7b1e3 (patch)
treef664b8e9cbf8e11a8193cb9026fadbcdb01480a9 /src/sim
parent85c7352462b68c1c79d8884a2cbd113a63525ddb (diff)
downloadgem5-5b1614de0227b727d16443eec66c2f7900b7b1e3.tar.xz
sim: fix overflow check in simulate because Tick is now unsigned
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/simulate.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/sim/simulate.cc b/src/sim/simulate.cc
index 5e69f0ff4..238e68787 100644
--- a/src/sim/simulate.cc
+++ b/src/sim/simulate.cc
@@ -49,12 +49,10 @@ simulate(Tick num_cycles)
{
inform("Entering event queue @ %d. Starting simulation...\n", curTick());
- if (num_cycles < 0)
- fatal("simulate: num_cycles must be >= 0 (was %d)\n", num_cycles);
- else if (curTick() + num_cycles < 0) //Overflow
- num_cycles = MaxTick;
- else
+ if (num_cycles < MaxTick - curTick())
num_cycles = curTick() + num_cycles;
+ else // counter would roll over or be set to MaxTick anyhow
+ num_cycles = MaxTick;
Event *limit_event =
new SimLoopExitEvent("simulate() limit reached", 0);