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:
Daniel Stone
2017-03-01 11:34:02 +00:00
committed by Pekka Paalanen
parent 61f6d7d372
commit 37ad7e3bae
3 changed files with 23 additions and 1 deletions
+9
View File
@@ -60,6 +60,15 @@ ZUC_TEST(timespec_test, timespec_to_nsec)
ZUC_ASSERT_EQ(timespec_to_nsec(&a), (NSEC_PER_SEC * 4ULL) + 4);
}
ZUC_TEST(timespec_test, timespec_to_msec)
{
struct timespec a;
a.tv_sec = 4;
a.tv_nsec = 4000000;
ZUC_ASSERT_EQ(timespec_to_msec(&a), (4000ULL) + 4);
}
ZUC_TEST(timespec_test, millihz_to_nsec)
{
ZUC_ASSERT_EQ(millihz_to_nsec(60000), 16666666);