feat: start implementing arm64 support (#313)
This commit is contained in:
parent
5e07f9d687
commit
ae3083a549
|
|
@ -66,10 +66,17 @@ typedef FILE fp_outfile;
|
|||
|
||||
/* compiler-gcc.h */
|
||||
#ifdef __GNUC__
|
||||
#ifdef __aarch64__
|
||||
#define barrier() __asm__ __volatile__("" : : : "memory")
|
||||
#define mb() asm volatile("dmb ish" : : : "memory")
|
||||
#define rmb() asm volatile("dmb ishld" : : : "memory")
|
||||
#define wmb() asm volatile("dmb ishst" : : : "memory")
|
||||
#else // __aarch64__
|
||||
#define barrier() __asm__ __volatile__("" : : : "memory")
|
||||
#define mb() asm volatile("mfence" : : : "memory")
|
||||
#define rmb() asm volatile("lfence" : : : "memory")
|
||||
#define wmb() asm volatile("sfence" : : : "memory")
|
||||
#endif // ! __aarch64__
|
||||
#define read_barrier_depends() \
|
||||
do { \
|
||||
} while (0)
|
||||
|
|
|
|||
|
|
@ -38,12 +38,6 @@ static inline __attribute__((always_inline)) u64 monotonic()
|
|||
return (u64)ts.tv_sec * (1000 * 1000 * 1000) + ts.tv_nsec;
|
||||
}
|
||||
|
||||
#include <x86intrin.h>
|
||||
static inline __attribute__((always_inline)) u64 fp_monotonic_time_ns(void)
|
||||
{
|
||||
return __rdtsc();
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
|||
10
util/time.h
10
util/time.h
|
|
@ -147,7 +147,9 @@ struct monotonic_clock {
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef __x86_64__
|
||||
#include <x86intrin.h>
|
||||
#endif
|
||||
/**
|
||||
* Monotonic, std::chrono compatible clock using `__rdtsc()` as the backend.
|
||||
*/
|
||||
|
|
@ -159,5 +161,13 @@ struct rdtsc_clock {
|
|||
using duration = std::chrono::duration<rep, period>;
|
||||
using time_point = std::chrono::time_point<monotonic_clock>;
|
||||
|
||||
#ifdef __aarch64__
|
||||
static inline __attribute__((always_inline)) time_point now() {
|
||||
uint64_t val;
|
||||
__asm__ __volatile__("mrs %0, cntvct_el0" : "=r"(val));
|
||||
return time_point{duration{val}};
|
||||
}
|
||||
#else
|
||||
static inline __attribute__((always_inline)) time_point now() { return time_point{duration{__rdtsc()}}; }
|
||||
#endif
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue