Skip to content

Commit

Permalink
Merge pull request #7044 from knn-k/linuxppc64HiresClock
Browse files Browse the repository at this point in the history
Linux PPC64: Use clock_gettime() for omrtime_hires_clock()
  • Loading branch information
babsingh authored Jun 23, 2023
2 parents 59b55e3 + 7a9830e commit 2d5ac63
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions port/linuxppc64/omrtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,16 @@ omrtime_nano_time(struct OMRPortLibrary *portLibrary)
uint64_t
omrtime_hires_clock(struct OMRPortLibrary *portLibrary)
{
struct timeval tp;

uint64_t ret = 0;
if (systemcfgP_nanos) {
return __getNanos();
ret = __getNanos();
} else {
struct timespec ts;
if (0 == clock_gettime(CLOCK_MONOTONIC_RAW, &ts)) {
ret = ((uint64_t)ts.tv_sec * OMRTIME_NANOSECONDS_PER_SECOND) + (uint64_t)ts.tv_nsec;
}
}

gettimeofday(&tp, NULL);
return ((int64_t)tp.tv_sec) * OMRTIME_HIRES_CLOCK_FREQUENCY + tp.tv_usec * (OMRTIME_HIRES_CLOCK_FREQUENCY / 1000000);
return ret;
}
/**
* Query OS for clock frequency
Expand Down

0 comments on commit 2d5ac63

Please sign in to comment.