diff options
| author | Robert Norton | 2018-06-27 16:18:00 +0100 |
|---|---|---|
| committer | Robert Norton | 2018-06-27 18:03:12 +0100 |
| commit | 230cbb018b6808b103d1a815de64d48422a88191 (patch) | |
| tree | a2d9a05de365db72ee23008e13b732b7154f098a /lib | |
| parent | a7e350250069a46652d2f07351701d814024d882 (diff) | |
Add a new function cycle_limit_reached that returns bool, allowing for graceful exit on reaching cycle limit. This aids coverage and valgrind instrumentation.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rts.c | 9 | ||||
| -rw-r--r-- | lib/rts.h | 2 |
2 files changed, 9 insertions, 2 deletions
@@ -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; } @@ -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); /* |
