From a41654b4f1fe1d521fa81208394120ed1f3956d6 Mon Sep 17 00:00:00 2001 From: Roman Fomin Date: Mon, 19 Aug 2024 15:01:06 +0700 Subject: [PATCH] fix building on Win7 (#1849) --- CMakeLists.txt | 11 +++++++++++ config.h.in | 1 + src/i_timer.c | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fb69e8e..b10ba459 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,17 @@ check_library_exists(m pow "" HAVE_LIBM) check_include_file("dirent.h" HAVE_DIRENT_H) check_symbol_exists(strcasecmp "strings.h" HAVE_DECL_STRCASECMP) check_symbol_exists(strncasecmp "strings.h" HAVE_DECL_STRNCASECMP) +check_c_source_compiles(" + #include + int main() + { + CreateWaitableTimerEx(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, + TIMER_ALL_ACCESS); + return 0; + } + " + HAVE_HIGH_RES_TIMER +) check_c_source_compiles(" #include int main() diff --git a/config.h.in b/config.h.in index 088899f3..26e6b2db 100644 --- a/config.h.in +++ b/config.h.in @@ -6,6 +6,7 @@ #cmakedefine HAVE_DIRENT_H #cmakedefine01 HAVE_DECL_STRCASECMP #cmakedefine01 HAVE_DECL_STRNCASECMP +#cmakedefine HAVE_HIGH_RES_TIMER #cmakedefine HAVE__DIV64 #cmakedefine HAVE_ALSA #cmakedefine HAVE_FLUIDSYNTH diff --git a/src/i_timer.c b/src/i_timer.c index ed6101cd..723e96c3 100644 --- a/src/i_timer.c +++ b/src/i_timer.c @@ -148,11 +148,13 @@ void I_InitTimer(void) #ifdef _WIN32 // Create an unnamed waitable timer. + hTimer = NULL; + #ifdef HAVE_HIGH_RES_TIMER hTimer = CreateWaitableTimerEx(NULL, NULL, CREATE_WAITABLE_TIMER_MANUAL_RESET | CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS); - + #endif if (hTimer == NULL) { hTimer = CreateWaitableTimer(NULL, TRUE, NULL);