|
Lines 26-32
Link Here
|
| 26 |
# ifndef __has_builtin |
26 |
# ifndef __has_builtin |
| 27 |
# define __has_builtin(x) 0 /* Compatibility with non-clang compilers */ |
27 |
# define __has_builtin(x) 0 /* Compatibility with non-clang compilers */ |
| 28 |
# endif |
28 |
# endif |
| 29 |
# if __has_builtin(__builtin_readcyclecounter) |
29 |
# if __has_builtin(__builtin_readcyclecounter) && !defined(__aarch64__) |
| 30 |
# elif defined _WIN32 |
30 |
# elif defined _WIN32 |
| 31 |
# include <intrin.h> |
31 |
# include <intrin.h> |
| 32 |
# elif defined __i386__ || defined __x86_64__ |
32 |
# elif defined __i386__ || defined __x86_64__ |
|
Lines 125-131
C_MODE_START
Link Here
|
| 125 |
*/ |
125 |
*/ |
| 126 |
static inline ulonglong my_timer_cycles(void) |
126 |
static inline ulonglong my_timer_cycles(void) |
| 127 |
{ |
127 |
{ |
| 128 |
# if __has_builtin(__builtin_readcyclecounter) |
128 |
# if __has_builtin(__builtin_readcyclecounter) && !defined(__aarch64__) |
| 129 |
return __builtin_readcyclecounter(); |
129 |
return __builtin_readcyclecounter(); |
| 130 |
# elif defined _WIN32 || defined __i386__ || defined __x86_64__ |
130 |
# elif defined _WIN32 || defined __i386__ || defined __x86_64__ |
| 131 |
return __rdtsc(); |
131 |
return __rdtsc(); |
|
Lines 162-167
static inline ulonglong my_timer_cycles(void)
Link Here
|
| 162 |
{ |
162 |
{ |
| 163 |
ulonglong result; |
163 |
ulonglong result; |
| 164 |
__asm__ __volatile__ ("stck %0" : "=Q" (result) : : "cc"); |
164 |
__asm__ __volatile__ ("stck %0" : "=Q" (result) : : "cc"); |
|
|
165 |
return result; |
| 166 |
} |
| 167 |
#elif defined(__aarch64) |
| 168 |
{ |
| 169 |
ulonglong result; |
| 170 |
__asm __volatile("mrs %0, CNTVCT_EL0" : "=&r" (result)); |
| 165 |
return result; |
171 |
return result; |
| 166 |
} |
172 |
} |
| 167 |
#elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME) |
173 |
#elif defined(HAVE_SYS_TIMES_H) && defined(HAVE_GETHRTIME) |