mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 06:10:56 +00:00
[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:
parent
a91dac60d9
commit
5d4013b485
1 changed files with 10 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue