diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2023-01-25 14:34:34 +0200 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2023-01-26 12:39:42 +0000 |
commit | 039f57b2eeacbc19f784201f4934dff4ddbc18cd (patch) | |
tree | 6fb49c79c8a4828e3252eb6237d11959cc5cd226 | |
parent | 13d8baf790e6a98a0a59e3aac5e976e8b05ce656 (diff) |
Windows: fix undefined symbol errors
Change-Id: Icc92dbe6445a1a6d911fa901cf3e6a3810864407
Reviewed-by: Sami Littow <sami.littow@qt.io>
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
-rw-r--r-- | include/licenser.h | 26 | ||||
-rw-r--r-- | include/utils.h | 2 | ||||
-rw-r--r-- | src/utils.cpp | 35 |
3 files changed, 36 insertions, 27 deletions
diff --git a/include/licenser.h b/include/licenser.h index a15f1fa..7799e09 100644 --- a/include/licenser.h +++ b/include/licenser.h @@ -53,29 +53,3 @@ private: LicdSetup *settings; }; - -#ifndef __TIME_IMP - #define __TIME_IMP - #if _WIN32 - inline int gettimeofday(struct timeval * tp, struct timezone * tzp) - { - // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's - // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) - // until 00:00:00 January 1, 1970 - static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); - - SYSTEMTIME system_time; - FILETIME file_time; - uint64_t time; - - GetSystemTime( &system_time ); - SystemTimeToFileTime( &system_time, &file_time ); - time = ((uint64_t)file_time.dwLowDateTime ) ; - time += ((uint64_t)file_time.dwHighDateTime) << 32; - - tp->tv_sec = (long) ((time - EPOCH) / 10000000L); - tp->tv_usec = (long) (system_time.wMilliseconds * 1000); - return 0; - } - #endif -#endif diff --git a/include/utils.h b/include/utils.h index f714e92..163836e 100644 --- a/include/utils.h +++ b/include/utils.h @@ -6,7 +6,6 @@ #include <sys/stat.h> #include <sys/types.h> -#include <sys/time.h> #include <iostream> #include <fstream> #include <sstream> @@ -29,6 +28,7 @@ #define SYSTEM_ROOT "C:" #else // Linux or Mac + #include <sys/time.h> #include <unistd.h> #include <dirent.h> #include <pwd.h> diff --git a/src/utils.cpp b/src/utils.cpp index 5e71b09..2c58847 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -311,6 +311,41 @@ time_t stringToEpoch(const char* theTime, const char* format) return mktime(&tmTime); } +#ifndef __TIME_IMP +#define __TIME_IMP +#if _WIN32 + +typedef struct timeval { + long tv_sec; + long tv_usec; +} timeval; + +/* + * Windows implementation of missing POSIX gettimeofday() +*/ +inline int gettimeofday(struct timeval * tp, struct timezone * tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) + // until 00:00:00 January 1, 1970 + static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime( &system_time ); + SystemTimeToFileTime( &system_time, &file_time ); + time = ((uint64_t)file_time.dwLowDateTime ) ; + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long) ((time - EPOCH) / 10000000L); + tp->tv_usec = (long) (system_time.wMilliseconds * 1000); + return 0; +} +#endif +#endif + uint64_t getTimestampNow() { // Get current time |