[lib] Fix timestamp_to_ms()
owl_timestamp_to_ms() did not convert properly the result to uint64_t. This is now fixed, but time functions are still buggy, as we do not take into account the length of tv_sec (owl_timestamp_round_to_ms() assumes that it is 9-digit long).
This commit is contained in:
parent
4ff1d194e4
commit
3815ccae8b
|
@ -126,7 +126,7 @@ int owl_timestamp_now_ns(TIMESTAMP *now)
|
|||
*/
|
||||
void owl_timestamp_round_to_ms(TIMESTAMP *now)
|
||||
{
|
||||
now->tv_nsec = now->tv_nsec / 1000000 * 1000000 ;
|
||||
now->tv_nsec = now->tv_nsec / 1000000u * 1000000u ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -151,7 +151,7 @@ TIMESTAMP owl_timeval_to_timestamp(const struct timeval d)
|
|||
{
|
||||
TIMESTAMP res ;
|
||||
res.tv_sec = d.tv_sec ;
|
||||
res.tv_nsec = d.tv_usec * 1000 ;
|
||||
res.tv_nsec = d.tv_usec * 1000u ;
|
||||
return res ;
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ TIMESTAMP owl_timeval_to_timestamp(const struct timeval d)
|
|||
*/
|
||||
uint64_t owl_timestamp_to_ms(TIMESTAMP d)
|
||||
{
|
||||
return d.tv_sec * 1000 + d.tv_nsec / 1000000 ;
|
||||
return (uint64_t) d.tv_sec * 1000u + (uint64_t) d.tv_nsec / 1000000u ;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue