diff options
author | Guy Harris <gharris@sonic.net> | 2020-12-20 13:31:57 -0800 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2020-12-20 13:31:57 -0800 |
commit | ca99a821b4021b2367152ed6547615b098ac7c71 (patch) | |
tree | 896284f5414cf3200bfe8b1191a60d9440b29f8a /ConfigureChecks.cmake | |
parent | 299d2f1ae5817c8d6c0f9c65efd026fc18fce43b (diff) |
Fix the way we get high-resolution time.
If we're not on Windows, use clock_gettime(CLOCK_REALTIME) *if* we have
it; otherwise, fall back on gettimeofday().
(Note: neither Linux, nor macOS, nor Windows necessarily "have"
particular APIs; particular *versions* of Linux distributions
(kernel+libc) have them, particular *versions* of macOS have them, and
particular *versions* of Windows+MSVC have them.
And Linux, Windows and macOS aren't the only platforms on which we run.)
Fixes #17101.
Diffstat (limited to 'ConfigureChecks.cmake')
-rw-r--r-- | ConfigureChecks.cmake | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake index c1292c9117..7d7ade8f2b 100644 --- a/ConfigureChecks.cmake +++ b/ConfigureChecks.cmake @@ -94,6 +94,19 @@ set(CMAKE_REQUIRED_LIBRARIES ${M_LIBRARIES}) check_symbol_exists("floorl" "math.h" HAVE_FLOORL) cmake_pop_check_state() +# +# Check whether we have clock_gettime(). +# It's not on Windows, so don't waste time checking for it. +# It's in newer POSIX, so some, but not all, UN*Xes have it. +# +if (NOT WIN32) + # + # POSIX - don't bother checking on Windows, as checks + # take time. + # + check_function_exists("clock_gettime" HAVE_CLOCK_GETTIME) +endif (NOT WIN32) + check_function_exists("getopt_long" HAVE_GETOPT_LONG) if(HAVE_GETOPT_LONG) # |