From 35aa9a95e4f0dac46dfdb011b348a71144f97c34 Mon Sep 17 00:00:00 2001 From: slguan Date: Thu, 22 Aug 2019 18:26:57 +0800 Subject: [PATCH] fix the issue #370, support for compilation of vs2019 --- deps/pthread/pthread.h | 13 +++++++++++++ src/util/src/tglobalcfg.c | 9 +++++++++ src/util/src/tinterpolation.c | 10 ++++++++++ 3 files changed, 32 insertions(+) diff --git a/deps/pthread/pthread.h b/deps/pthread/pthread.h index fd27f16b76..e08bf22abc 100644 --- a/deps/pthread/pthread.h +++ b/deps/pthread/pthread.h @@ -189,6 +189,19 @@ * ------------------------------------------------------------- */ +/* + _MSC_VER 1910 vs2019 + _MSC_VER 1910 vs2017 + _MSC_VER 1900 vs2015 + _MSC_VER 1800 vs2013 + */ + +#ifdef _MSC_VER +#if _MSC_VER >= 1900 +#define HAVE_STRUCT_TIMESPEC +#endif +#endif + /* Try to avoid including windows.h */ #if (defined(__MINGW64__) || defined(__MINGW32__)) && defined(__cplusplus) #define PTW32_INCLUDE_WINDOWS_H diff --git a/src/util/src/tglobalcfg.c b/src/util/src/tglobalcfg.c index 2a3089a539..e16da7b407 100644 --- a/src/util/src/tglobalcfg.c +++ b/src/util/src/tglobalcfg.c @@ -858,6 +858,15 @@ void tsSetTimeZone() { * e.g., the local time zone of London in DST is GMT+01:00, * otherwise is GMT+00:00 */ +#ifdef _MSC_VER +#if _MSC_VER >= 1900 + // see https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname?view=vs-2019 + int64_t timezone = _timezone; + int32_t daylight = _daylight; + char **tzname = _tzname; +#endif +#endif + int32_t tz = (-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR; tz += daylight; diff --git a/src/util/src/tinterpolation.c b/src/util/src/tinterpolation.c index 12f3064d7a..55022cc7c5 100644 --- a/src/util/src/tinterpolation.c +++ b/src/util/src/tinterpolation.c @@ -16,6 +16,7 @@ #include #include +#include "os.h" #include "taosmsg.h" #include "textbuffer.h" #include "tinterpolation.h" @@ -38,6 +39,15 @@ int64_t taosGetIntervalStartTimestamp(int64_t startTime, int64_t timeRange, char * * TODO dynmaically decide the start time of a day */ +#ifdef _MSC_VER +#if _MSC_VER >= 1900 + // see https://docs.microsoft.com/en-us/cpp/c-runtime-library/daylight-dstbias-timezone-and-tzname?view=vs-2019 + int64_t timezone = _timezone; + int32_t daylight = _daylight; + char** tzname = _tzname; +#endif +#endif + int64_t revStartime = (startTime / timeRange) * timeRange + timezone * MILLISECOND_PER_SECOND; int64_t revEndtime = revStartime + timeRange - 1; if (revEndtime < startTime) { -- GitLab