Skip to content

Commit

Permalink
Merge pull request logcabin#229 from asowani/ppc64le_port
Browse files Browse the repository at this point in the history
Ppc64le port.
  • Loading branch information
ongardie committed Jul 26, 2017
2 parents 5ebf542 + 4d6ddc0 commit ee6c55a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Core/Time.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,15 @@ static __inline __attribute__((always_inline))
uint64_t
rdtsc()
{
#if defined(__i386) || defined(__x86_64__)
uint32_t lo, hi;
__asm__ __volatile__("rdtsc" : "=a" (lo), "=d" (hi));
return ((uint64_t(hi) << 32) | lo);
#elif defined(__powerpc64__)
return (__builtin_ppc_get_timebase());
#else
#error "Unsupported platform."
#endif
}

/**
Expand Down
6 changes: 6 additions & 0 deletions Core/TimeTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,13 @@ TEST(CoreTime, rdtsc_progressTimingSensitive) {
usleep(1000);
uint64_t b = Time::rdtsc();
EXPECT_LT(a, b);
#if defined(__i386) || defined(__x86_64__)
EXPECT_LT(a + 1000 * 1000, b);
#elif defined(__powerpc64__)
EXPECT_LT(a + 1000 * 500, b);
#else
#error "Unsupported platform."
#endif
EXPECT_LT(b, a + 10 * 1000 * 1000);
}

Expand Down

0 comments on commit ee6c55a

Please sign in to comment.