From: Viktor Szakats Date: Fri, 29 Sep 2023 02:20:44 +0000 (+0000) Subject: cmake: detect `HAVE_CLOCK_GETTIME_MONOTONIC_RAW` X-Git-Tag: curl-8_4_0~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da5dcb70071fc895852bc17660b0d4fed3ffbfb1;p=thirdparty%2Fcurl.git cmake: detect `HAVE_CLOCK_GETTIME_MONOTONIC_RAW` Based on existing autotools logic. Ref: #11964 (effort to sync cmake detections with autotools) Closes #11981 --- diff --git a/CMake/OtherTests.cmake b/CMake/OtherTests.cmake index 31bb026b72..d67a9059bc 100644 --- a/CMake/OtherTests.cmake +++ b/CMake/OtherTests.cmake @@ -200,3 +200,22 @@ if(NOT DEFINED HAVE_GETADDRINFO_THREADSAFE) set(_source_epilogue "${_save_epilogue}") endif() + +if(NOT DEFINED HAVE_CLOCK_GETTIME_MONOTONIC_RAW) + set(_save_epilogue "${_source_epilogue}") + set(_source_epilogue "#undef inline") + + add_header_include(HAVE_SYS_TYPES_H "sys/types.h") + add_header_include(HAVE_SYS_TIME_H "sys/time.h") + + check_c_source_compiles("${_source_epilogue} + #include + int main(void) + { + struct timespec ts; + (void)clock_gettime(CLOCK_MONOTONIC_RAW, &ts); + return 0; + }" HAVE_CLOCK_GETTIME_MONOTONIC_RAW) + + set(_source_epilogue "${_save_epilogue}") +endif() diff --git a/CMake/Platforms/WindowsCache.cmake b/CMake/Platforms/WindowsCache.cmake index a616bf0c11..39cefd0545 100644 --- a/CMake/Platforms/WindowsCache.cmake +++ b/CMake/Platforms/WindowsCache.cmake @@ -103,6 +103,7 @@ if(NOT UNIX) set(HAVE_GETEUID 0) set(HAVE_UTIME 1) set(HAVE_GMTIME_R 0) + set(HAVE_CLOCK_GETTIME_MONOTONIC_RAW 0) set(HAVE_GETHOSTBYNAME_R 0) set(HAVE_SIGNAL 1) set(HAVE_LINUX_TCP_H 0) diff --git a/lib/curl_config.h.cmake b/lib/curl_config.h.cmake index 266cf13df2..ae137c0349 100644 --- a/lib/curl_config.h.cmake +++ b/lib/curl_config.h.cmake @@ -186,6 +186,10 @@ /* Define to 1 if you have the clock_gettime function and monotonic timer. */ #cmakedefine HAVE_CLOCK_GETTIME_MONOTONIC 1 +/* Define to 1 if you have the clock_gettime function and raw monotonic timer. + */ +#cmakedefine HAVE_CLOCK_GETTIME_MONOTONIC_RAW 1 + /* Define to 1 if you have the `closesocket' function. */ #cmakedefine HAVE_CLOSESOCKET 1