cmake: detect HAVE_CLOCK_GETTIME_MONOTONIC_RAW

Based on existing autotools logic.

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

Closes #11981
This commit is contained in:
Viktor Szakats 2023-09-29 02:20:44 +00:00
parent 04a3a377d8
commit da5dcb7007
No known key found for this signature in database
GPG Key ID: B5ABD165E2AEF201
3 changed files with 24 additions and 0 deletions

View 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()

View 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)

View File

@ -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