[util] Use clock_gettime for Sys_LongTime

While QF doesn't currently use nanoseconds, having access to a clock
that is not affected by setting system time is nice, and as a bonus, can
handle suspends should the need arise.
This commit is contained in:
Bill Currie 2021-08-27 11:22:57 +09:00
parent a91dac60d9
commit 5d4013b485

View file

@ -388,14 +388,22 @@ Sys_LongTime (void)
+ ((currqpccount - lastqpccount) * 1000000 / qpcfreq) + qpcfudge);
# endif
#else
struct timeval tp;
struct timezone tzp;
int64_t now;
static int64_t start_time;
#ifdef CLOCK_BOOTTIME
struct timespec tp;
clock_gettime (CLOCK_BOOTTIME, &tp);
now = tp.tv_sec * 1000000 + tp.tv_nsec / 1000;
#else
struct timeval tp;
struct timezone tzp;
gettimeofday (&tp, &tzp);
now = tp.tv_sec * 1000000 + tp.tv_usec;
#endif
if (first) {
first = false;