diff options
Diffstat (limited to 'src/pal')
-rw-r--r-- | src/pal/src/config.h.in | 1 | ||||
-rw-r--r-- | src/pal/src/configure.cmake | 13 | ||||
-rw-r--r-- | src/pal/src/misc/time.cpp | 12 |
3 files changed, 23 insertions, 3 deletions
diff --git a/src/pal/src/config.h.in b/src/pal/src/config.h.in index 143679d5a7..672cfe1d31 100644 --- a/src/pal/src/config.h.in +++ b/src/pal/src/config.h.in @@ -82,6 +82,7 @@ #cmakedefine01 HAVE_WORKING_GETTIMEOFDAY #cmakedefine01 HAVE_WORKING_CLOCK_GETTIME #cmakedefine01 HAVE_CLOCK_MONOTONIC +#cmakedefine01 HAVE_CLOCK_MONOTONIC_COARSE #cmakedefine01 HAVE_MACH_ABSOLUTE_TIME #cmakedefine01 HAVE_CLOCK_THREAD_CPUTIME #cmakedefine01 STATVFS64_PROTOTYPE_BROKEN diff --git a/src/pal/src/configure.cmake b/src/pal/src/configure.cmake index 333f0094c5..d130e14123 100644 --- a/src/pal/src/configure.cmake +++ b/src/pal/src/configure.cmake @@ -343,6 +343,19 @@ int main() }" HAVE_CLOCK_MONOTONIC) check_cxx_source_runs(" #include <stdlib.h> +#include <time.h> +#include <sys/time.h> + +int main() +{ + int ret; + struct timespec ts; + ret = clock_gettime(CLOCK_MONOTONIC_COARSE, &ts); + + exit(ret); +}" HAVE_CLOCK_MONOTONIC_COARSE) +check_cxx_source_runs(" +#include <stdlib.h> #include <mach/mach_time.h> int main() diff --git a/src/pal/src/misc/time.cpp b/src/pal/src/misc/time.cpp index 2f20c60914..939c86996a 100644 --- a/src/pal/src/misc/time.cpp +++ b/src/pal/src/misc/time.cpp @@ -337,12 +337,18 @@ GetTickCount64() { ULONGLONG retval = 0; -#if HAVE_CLOCK_MONOTONIC +#if HAVE_CLOCK_MONOTONIC_COARSE || HAVE_CLOCK_MONOTONIC { + clockid_t clockType = +#if HAVE_CLOCK_MONOTONIC_COARSE + CLOCK_MONOTONIC_COARSE; // good enough resolution, fastest speed +#else + CLOCK_MONOTONIC; +#endif struct timespec ts; - if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) + if (clock_gettime(clockType, &ts) != 0) { - ASSERT("clock_gettime(CLOCK_MONOTONIC) failed; errno is %d (%s)\n", errno, strerror(errno)); + ASSERT("clock_gettime(CLOCK_MONOTONIC*) failed; errno is %d (%s)\n", errno, strerror(errno)); goto EXIT; } retval = (ts.tv_sec * tccSecondsToMillieSeconds)+(ts.tv_nsec / tccMillieSecondsToNanoSeconds); |