Make progress towards aarch64 build

This commit is contained in:
Justine Tunney 2023-05-01 19:43:59 -07:00
parent 08ff26c817
commit ca2860947f
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
15428 changed files with 25694 additions and 23138 deletions

View file

@ -32,12 +32,21 @@ COSMOPOLITAN_C_START_
#define mfence_lfence_rdtsc_lfence() \
__RDTSC("mfence\n\tlfence\n\trdtsc\n\tlfence")
#ifdef __x86__
#define __RDTSC(ASM) \
({ \
uint64_t Rax, Rdx; \
asm volatile(ASM : "=a"(Rax), "=d"(Rdx) : /* no inputs */ : "memory"); \
Rdx << 32 | Rax; \
})
#elif defined(__aarch64__)
#define __RDTSC(ASM) \
({ \
uint64_t _Ts; \
asm volatile("mrs\t%0,cntvct_el0" : "=r"(_Ts)); \
_Ts * 48; /* the fudge factor */ \
})
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */