]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: detect `HAVE_CLOCK_GETTIME_MONOTONIC_RAW`
authorViktor Szakats <commit@vsz.me>
Fri, 29 Sep 2023 02:20:44 +0000 (02:20 +0000)
committerViktor Szakats <commit@vsz.me>
Fri, 29 Sep 2023 18:30:34 +0000 (18:30 +0000)
Based on existing autotools logic.

Ref: #11964 (effort to sync cmake detections with autotools)

Closes #11981

CMake/OtherTests.cmake
CMake/Platforms/WindowsCache.cmake
lib/curl_config.h.cmake

index 31bb026b720df1e8e185ff32797af35ae757625c..d67a9059bcdeaab9738f000c314aca50964faf5b 100644 (file)
@@ -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 <time.h>
+    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()
index a616bf0c110a961ba93f780571df290168314c1c..39cefd0545ce6a7f01fb60c8f42ea8a645685537 100644 (file)
@@ -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)
index 266cf13df2524fef5e1195c7fa6e0709aaebe46b..ae137c0349bd1f02dc2ec34ac1236f0772ce587d 100644 (file)
 /* 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