Changeset d685cb0


Ignore:
Timestamp:
Aug 21, 2020, 7:15:27 AM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
636d115b
Parents:
e67a82d
Message:

add ARM equivalent for x86 rdtsc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/defs.hfa

    re67a82d rd685cb0  
    1010// Created On       : Thu Nov  9 13:24:10 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jan 28 22:38:27 2020
    13 // Update Count     : 9
     12// Last Modified On : Thu Aug 13 22:00:23 2020
     13// Update Count     : 19
    1414//
    1515
     
    1717
    1818#include <stdint.h>
     19#include <assert.h>
    1920
    2021#define likely(x)   __builtin_expect(!!(x), 1)
     
    4748#endif
    4849
    49 static inline long long rdtscl(void) {
    50     unsigned int lo, hi;
    51     __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
    52     return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
     50static inline long long int rdtscl(void) {
     51        #if defined( __aarch64__ )
     52        // https://github.com/google/benchmark/blob/v1.1.0/src/cycleclock.h#L116
     53        long long int virtual_timer_value;
     54        asm volatile("mrs %0, cntvct_el0" : "=r"(virtual_timer_value));
     55        return virtual_timer_value;
     56        #else
     57        unsigned int lo, hi;
     58        __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
     59        return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
     60        #endif // __ARM_ARCH
    5361}
Note: See TracChangeset for help on using the changeset viewer.