Uptime: add ffTimeGetNow() and use it

This commit is contained in:
李通洲
2023-09-12 14:50:38 +08:00
parent 2251086c0f
commit f3ec60a061
4 changed files with 29 additions and 37 deletions
+14
View File
@@ -7,6 +7,7 @@
#ifdef _WIN32
#include <synchapi.h>
#include <profileapi.h>
#include <sysinfoapi.h>
#else
#include <time.h>
#endif
@@ -26,6 +27,19 @@ static inline uint64_t ffTimeGetTick() //In msec
#endif
}
static inline uint64_t ffTimeGetNow()
{
#ifdef _WIN32
uint64_t timeNow;
GetSystemTimeAsFileTime((FILETIME*) &timeNow);
return (timeNow - 116444736000000000ull) / 10000ull;
#else
struct timespec timeNow;
clock_gettime(CLOCK_REALTIME, &timeNow);
return (uint64_t)((timeNow.tv_sec * 1000) + (timeNow.tv_nsec / 1000000));
#endif
}
static inline void ffTimeSleep(uint32_t msec)
{
#ifdef _WIN32