Skip to content

Commit ca0a918

Browse files
jdupakppisa
authored andcommitted
Core: use QElapsedTimer also in aclintmtimer
1 parent 759d64a commit ca0a918

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/machine/memory/backend/aclintmtimer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ AclintMtimer::AclintMtimer(Endian simulated_machine_endian)
2121
value = 0;
2222
}
2323

24-
mtime_start_offset = QTime::currentTime();
24+
clock.start();
2525
qt_timer_id = -1;
2626
}
2727

@@ -31,9 +31,7 @@ AclintMtimer::~AclintMtimer() {
3131
}
3232

3333
uint64_t AclintMtimer::mtime_fetch_current() const {
34-
QTime current_time = QTime::currentTime();
35-
36-
mtime_last_current_fetch = mtime_start_offset.msecsTo(current_time) * (uint64_t)10000;
34+
mtime_last_current_fetch = clock.elapsed() * (uint64_t)10000;
3735

3836
return mtime_last_current_fetch;
3937
}

src/machine/memory/backend/aclintmtimer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <QTime>
88
#include <cstdint>
9+
#include <qelapsedtimer.h>
910

1011
namespace machine { namespace aclint {
1112

@@ -63,8 +64,8 @@ namespace machine { namespace aclint {
6364
unsigned mtimecmp_count;
6465
uint64_t mtimecmp_value[ACLINT_MTIMECMP_COUNT_MAX] {};
6566

67+
QElapsedTimer clock;
6668
const uint8_t mtimer_irq_level;
67-
QTime mtime_start_offset;
6869
uint64_t mtime_user_offset = 0;
6970
mutable uint64_t mtime_last_current_fetch = 0;
7071
mutable bool mtimer_irq_active = false;

0 commit comments

Comments
 (0)