From d5ece4c2c229badd6426204c50f1de421ead2e80 Mon Sep 17 00:00:00 2001 From: Alexey Chirukhin Date: Wed, 16 Jan 2019 23:46:35 +0300 Subject: [PATCH] fix rdtsc and rdtscp for i386 arch --- cds/compiler/gcc/amd64/ts_hardwaretimestamp.h | 8 ++++---- cds/compiler/gcc/x86/ts_hardwaretimestamp.h | 13 ++++++------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cds/compiler/gcc/amd64/ts_hardwaretimestamp.h b/cds/compiler/gcc/amd64/ts_hardwaretimestamp.h index 7cbc40709..acd1325e6 100644 --- a/cds/compiler/gcc/amd64/ts_hardwaretimestamp.h +++ b/cds/compiler/gcc/amd64/ts_hardwaretimestamp.h @@ -11,16 +11,16 @@ namespace cds { namespace tshardwaretimestamp { { uint64_t aux; uint64_t rax, rdx; - asm volatile ("rdtscp\n" : "=a" (rax), "=d" (rdx), "=c" (aux) : : ); + __asm__ volatile ("rdtscp\n" : "=a" (rax), "=d" (rdx), "=c" (aux) : : ); return (rdx << 32) + rax; } # define CDS_ts_hardwaretimestamp_hwtime_defined static inline uint64_t get_hwtime() { - unsigned int hi, lo; - __asm__ __volatile__("rdtsc" : "=a"(lo), "=d"(hi)); - return ((uint64_t)lo) | (((uint64_t)hi) << 32); + uint64_t high, low; + __asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); + return ((uint64_t)low) | (((uint64_t)high) << 32); } }} // namespace gcc::amd64 diff --git a/cds/compiler/gcc/x86/ts_hardwaretimestamp.h b/cds/compiler/gcc/x86/ts_hardwaretimestamp.h index 1e14dfcc5..983fe2a2f 100644 --- a/cds/compiler/gcc/x86/ts_hardwaretimestamp.h +++ b/cds/compiler/gcc/x86/ts_hardwaretimestamp.h @@ -9,18 +9,17 @@ namespace cds { namespace tshardwaretimestamp { # define CDS_ts_hardwaretimestamp_hwptime_defined static inline uint64_t get_hwptime() { - uint64_t aux; - uint64_t rax, rdx; - asm volatile ("rdtscp\n" : "=a" (rax), "=d" (rdx), "=c" (aux) : : ); - return (rdx << 32) + rax; + uint64_t ret; + __asm__ volatile ("rdtscp\n" : "=A" (ret) : : "ecx"); + return ret; } # define CDS_ts_hardwaretimestamp_hwtime_defined static inline uint64_t get_hwtime() { - unsigned int hi, lo; - __asm__ __volatile__("rdtsc" : "=a"(lo), "=d"(hi)); - return ((uint64_t)lo) | (((uint64_t)hi) << 32); + uint64_t ret; + __asm__ volatile("rdtsc" : "=A"(ret)); + return ret; } }} // namespace gcc::x86