1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #ifndef CRCUTIL_RDTSC_H_
- #define CRCUTIL_RDTSC_H_
- #include "platform.h"
- namespace crcutil {
- struct Rdtsc {
- static inline uint64 Get() {
- #if defined(_MSC_VER) && (HAVE_AMD64 || HAVE_I386)
- return __rdtsc();
- #elif defined(__GNUC__) && HAVE_AMD64
- int64 result;
- __asm__ volatile(
- "rdtsc\n"
- : "=a" (result));
- return result;
- #elif defined(__GNUC__) && HAVE_I386
-
-
-
-
-
-
- uint32 low;
- uint32 high;
- __asm__ volatile(
- "rdtsc\n"
- : "=a" (low), "=d" (high));
- return ((static_cast<uint64>(high) << 32) | low);
- #else
-
-
- return 0;
- #endif
- }
- };
- }
- #endif
|