summaryrefslogtreecommitdiff
path: root/tb/top/conspiracion.cpp
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2022-12-07 20:04:15 -0600
committerAlejandro Soto <alejandro@34project.org>2022-12-07 20:04:23 -0600
commita7adc0af074826a4c68c7395d2abfd4b931955df (patch)
treee9db6027bf690ad17e66a97334a52e7f8790d36f /tb/top/conspiracion.cpp
parentc39552375661e495b344e8386649ade92a4d45b2 (diff)
Make the cycle limit optional
Diffstat (limited to '')
-rw-r--r--tb/top/conspiracion.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/tb/top/conspiracion.cpp b/tb/top/conspiracion.cpp
index bd1086a..f222e54 100644
--- a/tb/top/conspiracion.cpp
+++ b/tb/top/conspiracion.cpp
@@ -1,3 +1,4 @@
+#include <climits>
#include <cstdio>
#include <cstdint>
#include <cstdlib>
@@ -204,7 +205,7 @@ int main(int argc, char **argv)
args::ValueFlag<unsigned> cycles
(
- parser, "cycles", "Number of core cycles to run", {"cycles"}, 256
+ parser, "cycles", "Max number of core cycles to run", {"cycles"}, UINT_MAX
);
args::ValueFlag<int> control_fd
@@ -446,9 +447,10 @@ int main(int argc, char **argv)
};
unsigned i = 0;
- while(!failed && i < *cycles)
+ // Abuse unsigned overflow (cycles is UINT_MAX by default)
+ while(!failed && i + 1 <= *cycles)
{
- for(; i < *cycles; ++i)
+ for(; i + 1 <= *cycles; ++i)
{
cycle();
if(failed || top.cpu_halted) [[unlikely]]