From: Anthony Gutierrez Date: Tue, 28 Aug 2012 00:53:20 +0000 (-0400) Subject: sim: fix overflow check in simulate because Tick is now unsigned X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5b1614de0227b727d16443eec66c2f7900b7b1e3;p=gem5.git sim: fix overflow check in simulate because Tick is now unsigned --- 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);