This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -875,6 +875,29 @@ version (Windows)
875
875
export int QueryPerformanceFrequency (timer_t * );
876
876
}
877
877
}
878
+ else version (AArch64 )
879
+ {
880
+ // We cannot use ldc.intrinsics.llvm_readcyclecounter because that is not an accurate
881
+ // time counter (it is a counter of CPU cycles, where here we want a time clock).
882
+ // Also, priviledged execution rights are needed to enable correct counting with
883
+ // ldc.intrinsics.llvm_readcyclecounter on AArch64.
884
+ extern (D ) void QueryPerformanceCounter(timer_t* ctr)
885
+ {
886
+ asm { " mrs %0, cntvct_el0" : " =r" (* ctr); }
887
+ }
888
+ extern (D ) void QueryPerformanceFrequency(timer_t* freq)
889
+ {
890
+ asm { " mrs %0, cntfrq_el0" : " =r" (* freq); }
891
+ }
892
+ }
893
+ else version (LDC )
894
+ {
895
+ extern (D ) void QueryPerformanceCounter(timer_t* ctr)
896
+ {
897
+ import ldc.intrinsics: llvm_readcyclecounter;
898
+ * ctr = llvm_readcyclecounter();
899
+ }
900
+ }
878
901
else
879
902
{
880
903
extern (D ) void QueryPerformanceCounter(timer_t* ctr)
@@ -906,11 +929,6 @@ else
906
929
ret ;
907
930
}
908
931
}
909
- else version (LDC )
910
- {
911
- import ldc.intrinsics: llvm_readcyclecounter;
912
- * ctr = llvm_readcyclecounter();
913
- }
914
932
else
915
933
{
916
934
static assert (0 );
You can’t perform that action at this time.
0 commit comments