File tree Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Expand file tree Collapse file tree 1 file changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -18,17 +18,14 @@ extern "C"
18
18
{
19
19
(void )unused;
20
20
static uint32_t rollover = 0 ;
21
- static uint64_t last_measure = 0 ;
21
+ static uint32_t last_measure = 0 ;
22
22
23
- uint64_t m = micros ();
24
- tp->tv_sec = m / 1000000 ;
25
- tp->tv_nsec = (m % 1000000 ) * 1000 ;
26
-
27
- // Rollover handling
23
+ uint32_t m = micros ();
28
24
rollover += (m < last_measure) ? 1 : 0 ;
29
- uint64_t rollover_extra_us = rollover * micro_rollover_useconds;
30
- tp->tv_sec += rollover_extra_us / 1000000 ;
31
- tp->tv_nsec += (rollover_extra_us % 1000000 ) * 1000 ;
25
+
26
+ uint64_t real_us = (uint64_t ) (m + rollover * micro_rollover_useconds);
27
+ tp->tv_sec = real_us / 1000000 ;
28
+ tp->tv_nsec = (real_us % 1000000 ) * 1000 ;
32
29
last_measure = m;
33
30
34
31
return 0 ;
You can’t perform that action at this time.
0 commit comments