summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/rts.c9
-rw-r--r--lib/rts.h2
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/rts.c b/lib/rts.c
index 68cd6d67..51c99af0 100644
--- a/lib/rts.c
+++ b/lib/rts.c
@@ -347,13 +347,18 @@ void elf_tohost(mpz_t *rop, const unit u)
static uint64_t g_cycle_count = 0;
static uint64_t g_cycle_limit;
+/* NB Also increments cycle_count */
+bool cycle_limit_reached(const unit u)
+{
+ return ++g_cycle_count >= g_cycle_limit && g_cycle_limit != 0;
+}
+
unit cycle_count(const unit u)
{
- if (++g_cycle_count >= g_cycle_limit && g_cycle_limit != 0) {
+ if (cycle_limit_reached(UNIT)) {
printf("\n[Sail] cycle limit %" PRId64 " reached\n", g_cycle_limit);
exit(EXIT_SUCCESS);
}
-
return UNIT;
}
diff --git a/lib/rts.h b/lib/rts.h
index 86b7f1f1..032d48b8 100644
--- a/lib/rts.h
+++ b/lib/rts.h
@@ -109,6 +109,8 @@ void trace_end(void);
* Functions for counting and limiting cycles
*/
+bool cycle_limit_reached(const unit);
+
unit cycle_count(const unit);
/*