mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-18 02:43:42 +02:00
change time_monotonic_ms() from time_t to int64_t
time_monotonic_ms values did wrap every ~24 days, leading to problems in code that did not cope with that. Instead of fixing all places where relative comparisons with time_monotonic_ms() are made, just use a bigger datatype. Convert all users to the new type.
This commit is contained in:
committed by
Jacek Jendrzej
parent
ea30b22119
commit
99c8168d2c
@@ -2,7 +2,7 @@
|
||||
#include <stdio.h> /* for perror */
|
||||
#include <time.h>
|
||||
|
||||
time_t time_monotonic_ms(void)
|
||||
int64_t time_monotonic_ms(void)
|
||||
{
|
||||
struct timespec t;
|
||||
time_t ret;
|
||||
@@ -11,7 +11,7 @@ time_t time_monotonic_ms(void)
|
||||
perror("time_monotonic_ms clock_gettime");
|
||||
return -1;
|
||||
}
|
||||
ret = ((t.tv_sec + 604800)& 0x01FFFFF) * 1000; /* avoid overflow */
|
||||
ret = (t.tv_sec + 604800) * (int64_t)1000; /* avoid overflow */
|
||||
ret += t.tv_nsec / 1000000;
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user