Skip to content

Commit

Permalink
fix rdtsc and rdtscp for i386 arch
Browse files Browse the repository at this point in the history
  • Loading branch information
pr3sto committed Jan 16, 2019
1 parent 5ee65b5 commit d5ece4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions cds/compiler/gcc/amd64/ts_hardwaretimestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions cds/compiler/gcc/x86/ts_hardwaretimestamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d5ece4c

Please sign in to comment.