Add more ktime related functions to the LinuxKPI.

Obtained from:	kmacy @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2016-05-23 12:10:28 +00:00
parent 08a5e6ec7f
commit 7dfa8b2c4e

View File

@ -51,6 +51,24 @@ ktime_to_ns(ktime_t kt)
return kt.tv64;
}
static inline int64_t
ktime_divns(const ktime_t kt, int64_t div)
{
return kt.tv64 / div;
}
static inline int64_t
ktime_to_us(ktime_t kt)
{
return ktime_divns(kt, NSEC_PER_USEC);
}
static inline int64_t
ktime_to_ms(ktime_t kt)
{
return ktime_divns(kt, NSEC_PER_MSEC);
}
static inline struct timeval
ktime_to_timeval(ktime_t kt)
{
@ -89,6 +107,20 @@ ktime_sub(ktime_t lhs, ktime_t rhs)
return (lhs);
}
static inline int64_t
ktime_us_delta(ktime_t later, ktime_t earlier)
{
ktime_t diff = ktime_sub(later, earlier);
return ktime_to_us(diff);
}
static inline int64_t
ktime_ms_delta(ktime_t later, ktime_t earlier)
{
ktime_t diff = ktime_sub(later, earlier);
return ktime_to_ms(diff);
}
static inline ktime_t
ktime_add(ktime_t lhs, ktime_t rhs)
{