diff options
author | hselasky <hselasky@FreeBSD.org> | 2016-05-23 12:10:28 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2016-05-23 12:10:28 +0000 |
commit | 718ffce00b5db1586afb6a957c606e1b07719b7e (patch) | |
tree | aa461a0370345bd647e218cacab7348f668e869b | |
parent | 22a26146ed9c5e79001b7038a3406db744cf7cb4 (diff) | |
download | FreeBSD-src-718ffce00b5db1586afb6a957c606e1b07719b7e.zip FreeBSD-src-718ffce00b5db1586afb6a957c606e1b07719b7e.tar.gz |
Add more ktime related functions to the LinuxKPI.
Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/ktime.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/ktime.h b/sys/compat/linuxkpi/common/include/linux/ktime.h index c9fa81c..7c6c40f 100644 --- a/sys/compat/linuxkpi/common/include/linux/ktime.h +++ b/sys/compat/linuxkpi/common/include/linux/ktime.h @@ -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) { |