Date: Mon, 23 May 2016 12:10:28 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300498 - head/sys/compat/linuxkpi/common/include/linux Message-ID: <201605231210.u4NCASQG011652@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Mon May 23 12:10:28 2016 New Revision: 300498 URL: https://svnweb.freebsd.org/changeset/base/300498 Log: Add more ktime related functions to the LinuxKPI. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/linux/ktime.h Modified: head/sys/compat/linuxkpi/common/include/linux/ktime.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/ktime.h Mon May 23 12:06:34 2016 (r300497) +++ head/sys/compat/linuxkpi/common/include/linux/ktime.h Mon May 23 12:10:28 2016 (r300498) @@ -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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605231210.u4NCASQG011652>