util: replace time_stamp() implementation

Replace Windows/Xbox implementation with solution from NetXMS project.
This commit is contained in:
Dmitry Podgorny
2020-01-26 00:52:54 +02:00
parent 8cfb2d2a03
commit 6b38216124

View File

@@ -86,13 +86,24 @@ char *xmpp_strtok_r(char *s, const char *delim, char **saveptr)
*/ */
uint64_t time_stamp(void) uint64_t time_stamp(void)
{ {
#if defined(_XBOX_ONE) #if defined(_WIN32) || defined(_XBOX_ONE)
uint64_t SystemTime;
GetSystemTimeAsFileTime((FILETIME*)&SystemTime); #ifndef __GNUC__
/* Convert 100 nanosec ticks to milliseconds */ #define EPOCHFILETIME (116444736000000000i64)
return (SystemTime / 10000); #else
#elif defined(_WIN32) #define EPOCHFILETIME (116444736000000000LL)
return timeGetTime(); #endif
FILETIME ft;
LARGE_INTEGER li;
__int64 t;
GetSystemTimeAsFileTime(&ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
t = li.QuadPart; /* In 100-nanosecond intervals */
t -= EPOCHFILETIME; /* Offset to the Epoch time */
return (uint64_t)(t / 10000); /* Convert to milliseconds */
#else #else
struct timeval tv; struct timeval tv;