@@ -26,13 +26,20 @@ extern "C" {
2626 // Intel (and later model AMD) Fetch Time-StampCounter
2727 // WARNING: This value may be affected by speedstep and may vary randomly across cores.
2828 __inline__ uint64_t rdtsc (void ) {
29+ #ifdef __x86_64__
30+
2931 uint32_t lo, hi;
3032 __asm__ __volatile__ ( // serialize
3133 " xorl %%eax,%%eax \n cpuid"
3234 ::: " %rax" , " %rbx" , " %rcx" , " %rdx" );
3335 /* We cannot use "=A", since this would use %rax on x86_64 and return only the lower 32bits of the TSC */
3436 __asm__ __volatile__ (" rdtsc" : " =a" (lo), " =d" (hi));
3537 return (uint64_t )hi << 32 | lo;
38+ #elif defined(__aarch64__)
39+ uint64_t val;
40+ __asm __volatile (" mrs %0, cntvct_el0" : " =r" (val));
41+ return val;
42+ #endif
3643 }
3744}
3845
@@ -91,7 +98,7 @@ class AutoTSC {
9198public:
9299 uint64_t start;
93100 const char *label;
94- AccumTSCRecord *rec;
101+ AccumTSCRecord *rec;
95102 AutoTSC (const char * lbl, AccumTSCRecord* rec) : rec(rec) {
96103 label = lbl;
97104 start = rdtsc ();
@@ -121,8 +128,8 @@ public:
121128#define prefetch (x ) __builtin_prefetch(x)
122129
123130
124- // #define CHECKPOINTV(msg, ...) fprintf(stderr, "%d %s:%d::%s() "msg"\n", getpid(), __FILE__, __LINE__, __PRETTY_FUNCTION__,__VA_ARGS__);
125- #define CHECKPOINTV (msg, ...)
131+ // #define CHECKPOINTV(msg, ...) fprintf(stderr, "%d %s:%d::%s() "msg"\n", getpid(), __FILE__, __LINE__, __PRETTY_FUNCTION__,__VA_ARGS__);
132+ #define CHECKPOINTV (msg, ...)
126133
127134// #define TRACE_LOCKS
128135#define PRINT_LOCK_TRACE (msg ) { \
0 commit comments