In 32 bit mode the "=A" constraint refers to the register pair
edx:eax, but according to GCC developers this is not the case in 64
bit mode, where it refers to "rax".
Hence, using "=A" for rdtsc is incorrect in 64 bit mode.
See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21249
static inline uint64_t
oil_profile_stamp_rdtsc (void)
{
- uint64_t ts;
+ uint32_t hi, lo;
- __asm__ __volatile__ ("rdtsc\n" : "=A" (ts));
- return ts;
+ __asm__ __volatile__ ("rdtsc\n" : "=a" (lo), "=d" (hi));
+
+ return lo | (((uint64_t)hi) << 32);
}
#define OIL_STAMP oil_profile_stamp_rdtsc