From ea981d08060fe069c64fb777a6a23545766f2f79 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Fri, 29 Jan 2021 13:23:28 +0800 Subject: [PATCH] monotonic/msvclibx: fix compilation on linux --- deps/rmonotonic/CMakeLists.txt | 6 +++++- deps/rmonotonic/src/monotonic.c | 2 ++ src/util/src/ttimer.c | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/deps/rmonotonic/CMakeLists.txt b/deps/rmonotonic/CMakeLists.txt index 119b3c3114..b870b7d6d7 100644 --- a/deps/rmonotonic/CMakeLists.txt +++ b/deps/rmonotonic/CMakeLists.txt @@ -2,6 +2,10 @@ AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCE_LIST) add_definitions(-DUSE_PROCESSOR_CLOCK) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../MsvcLibX/include) + ADD_LIBRARY(rmonotonic ${SOURCE_LIST}) TARGET_INCLUDE_DIRECTORIES(rmonotonic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc) -TARGET_LINK_LIBRARIES(rmonotonic MsvcLibXw) +IF (TD_WINDOWS) + TARGET_LINK_LIBRARIES(rmonotonic MsvcLibXw) +ENDIF () diff --git a/deps/rmonotonic/src/monotonic.c b/deps/rmonotonic/src/monotonic.c index 37023ce273..622ac1b075 100644 --- a/deps/rmonotonic/src/monotonic.c +++ b/deps/rmonotonic/src/monotonic.c @@ -7,8 +7,10 @@ #undef NDEBUG #include +#if defined(_WIN32) || defined(_WIN64) #include "msvcTime.h" #include "msvcStdio.h" +#endif /* The function pointer for clock retrieval. */ monotime (*getMonotonicUs)(void) = NULL; diff --git a/src/util/src/ttimer.c b/src/util/src/ttimer.c index 1fe2d2f872..6029edf512 100644 --- a/src/util/src/ttimer.c +++ b/src/util/src/ttimer.c @@ -506,7 +506,6 @@ static void taosTmrModuleInit(void) { pthread_mutex_init(&tmrCtrlMutex, NULL); - tmrInfo("ttimer monotonic clock source:%s", monotonicInit()); int64_t now = getMonotonicMs(); for (int i = 0; i < tListLen(wheels); i++) { time_wheel_t* wheel = wheels + i; @@ -538,6 +537,8 @@ static void taosTmrModuleInit(void) { } void* taosTmrInit(int maxNumOfTmrs, int resolution, int longest, const char* label) { + tmrInfo("ttimer monotonic clock source:%s", monotonicInit()); + pthread_once(&tmrModuleInit, taosTmrModuleInit); pthread_mutex_lock(&tmrCtrlMutex); -- GitLab