Skip to content

Commit

Permalink
Rework slightly so that std::chrono is always used on __arm__ platfor…
Browse files Browse the repository at this point in the history
…ms to avoid x86 assembler!
  • Loading branch information
fluffyfreak committed Jan 16, 2016
1 parent 1748828 commit fffd081
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions contrib/profiler/Profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
#undef fastcall

//#define USE_CHRONO
#if !defined(USE_CHRONO) && defined(__arm__)
// this isn't optional for __arm__ builds
#define USE_CHRONO
#endif

#if defined(USE_CHRONO)
#include <chrono>
#endif

#if defined(_MSC_VER)
#undef __PRETTY_FUNCTION__
Expand Down Expand Up @@ -144,16 +151,18 @@ namespace Profiler {
calls += b.calls;
}

#if defined(__GNUC__)
static inline u64 getticks() {
u32 __a,__d;
asm volatile("rdtsc" : "=a" (__a), "=d" (__d));
return ( u64(__a) | u64(__d) << 32 );
}
#elif defined(__ICC) || defined(__ICL)
static inline u64 getticks() { return _rdtsc(); }
#elif defined(_MSC_VER) && !defined(USE_CHRONO)
static inline u64 getticks() { __asm { rdtsc }; }
#if !defined(USE_CHRONO)
#if defined(__GNUC__)
static inline u64 getticks() {
u32 __a,__d;
asm volatile("rdtsc" : "=a" (__a), "=d" (__d));
return ( u64(__a) | u64(__d) << 32 );
}
#elif defined(__ICC) || defined(__ICL)
static inline u64 getticks() { return _rdtsc(); }
#elif defined(_MSC_VER)
static inline u64 getticks() { __asm { rdtsc }; }
#endif
#else
static inline u64 getticks() { return std::chrono::high_resolution_clock::now().time_since_epoch().count(); }
#endif
Expand Down

0 comments on commit fffd081

Please sign in to comment.