timespec: Add timespec_to_msec helper
Paralleling timespec_to_nsec, converts to milliseconds. Signed-off-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> [Pekka: added doc about flooring] Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
committed by
Pekka Paalanen
parent
61f6d7d372
commit
37ad7e3bae
@@ -93,6 +93,19 @@ timespec_to_nsec(const struct timespec *a)
|
||||
return (int64_t)a->tv_sec * NSEC_PER_SEC + a->tv_nsec;
|
||||
}
|
||||
|
||||
/* Convert timespec to milliseconds
|
||||
*
|
||||
* \param a timespec
|
||||
* \return milliseconds
|
||||
*
|
||||
* Rounding to integer milliseconds happens always down (floor()).
|
||||
*/
|
||||
static inline int64_t
|
||||
timespec_to_msec(const struct timespec *a)
|
||||
{
|
||||
return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
/* Convert milli-Hertz to nanoseconds
|
||||
*
|
||||
* \param mhz frequency in mHz, not zero
|
||||
|
||||
Reference in New Issue
Block a user