tv_add: use tv_add_usec

tv_add_usec fixes handling of 2^31 us addition overflow and the original
function, tv_add is not slower if tv_add_usec is inlined.
This commit is contained in:
Martin Pulec
2022-01-21 15:01:28 +01:00
parent 430d1941d8
commit 7db4dc7b3a

View File

@@ -102,15 +102,11 @@ uint32_t tv_diff_usec(struct timeval curr_time, struct timeval prev_time)
return tmp;
}
inline void tv_add_usec(struct timeval *ts, long long offset) ATTRIBUTE(always_inline); // to allow tv_add inline this function
void tv_add(struct timeval *ts, double offset_secs)
{
unsigned int offset = (unsigned long)(offset_secs * 1000000.0);
ts->tv_usec += offset;
while (ts->tv_usec >= 1000000) {
ts->tv_sec++;
ts->tv_usec -= 1000000;
}
tv_add_usec(ts, offset_secs * 1000000.0);
}
void tv_add_usec(struct timeval *ts, long long offset)