Merge pull request #1990 from DeepChannel/fix/nanos-rollover
fix: possible rollover of nanoseconds in clock.h
This commit is contained in:
commit
e021d6e979
1 changed files with 4 additions and 0 deletions
|
|
@ -82,6 +82,10 @@ static inline TSClock clock_after(TSClock base, TSDuration duration) {
|
|||
TSClock result = base;
|
||||
result.tv_sec += duration / 1000000;
|
||||
result.tv_nsec += (duration % 1000000) * 1000;
|
||||
if (result.tv_nsec >= 1000000000) {
|
||||
result.tv_nsec -= 1000000000;
|
||||
++(result.tv_sec);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue