mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-11-04 23:55:08 +01:00
Prevent CNTVCT_EL0 reads from being optimised out by the compiler
Without this the compiler will assume the read always produces the same value, causing issues when the register is used to time function execution
This commit is contained in:
parent
1df98ba57f
commit
0e1aa765fc
@ -27,7 +27,7 @@ namespace skyline::util {
|
||||
u64 frequency;
|
||||
asm("MRS %0, CNTFRQ_EL0" : "=r"(frequency));
|
||||
u64 ticks;
|
||||
asm("MRS %0, CNTVCT_EL0" : "=r"(ticks));
|
||||
asm volatile("MRS %0, CNTVCT_EL0" : "=r"(ticks));
|
||||
return static_cast<i64>(((ticks / frequency) * constant::NsInSecond) + (((ticks % frequency) * constant::NsInSecond + (frequency / 2)) / frequency));
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ namespace skyline::util {
|
||||
*/
|
||||
inline u64 GetTimeTicks() {
|
||||
u64 ticks;
|
||||
asm("MRS %0, CNTVCT_EL0" : "=r"(ticks));
|
||||
asm volatile("MRS %0, CNTVCT_EL0" : "=r"(ticks));
|
||||
return ticks;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user