Skip to content

Commit

Permalink
Merge pull request #181 from knn-k/linuxppc64HiresClock_0.40
Browse files Browse the repository at this point in the history
(0.40.0) Linux PPC64: Use clock_gettime() for omrtime_hires_clock()
  • Loading branch information
babsingh committed Jun 23, 2023
2 parents 2e351ba + 3044f95 commit e80bff8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions port/linuxppc64/omrtime.c
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 e80bff8

Please sign in to comment.