summaryrefslogtreecommitdiffstats
path: root/include/linux/ktime.h
diff options
context:
space:
mode:
authorDaniel Borkmann <dxchgb@gmail.com>2012-10-28 08:27:19 +0000
committerDavid S. Miller <davem@davemloft.net>2012-11-03 14:50:15 -0400
commit398f382c0a5bd62f0f31871e844700e1b9fd1ad3 (patch)
treec1456d193eb4089de48f9aed8459fbf806433563 /include/linux/ktime.h
parente6c022a4fa2d2d9ca9d0a7ac3b05ad988f39fc30 (diff)
downloadlinux-398f382c0a5bd62f0f31871e844700e1b9fd1ad3.tar.gz
linux-398f382c0a5bd62f0f31871e844700e1b9fd1ad3.tar.bz2
linux-398f382c0a5bd62f0f31871e844700e1b9fd1ad3.zip
pktgen: clean up ktime_t helpers
Some years ago, the ktime_t helper functions ktime_now() and ktime_lt() have been introduced. Instead of defining them inside pktgen.c, they should either use ktime_t library functions or, if not available, they should be defined in ktime.h, so that also others can benefit from them. ktime_compare() is introduced with a similar notion as in timespec_compare(). Signed-off-by: Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch> Cc: Cong Wang <xiyou.wangcong@gmail.com> Cc: Stephen Hemminger <shemminger@vyatta.com> Cc: Thomas Gleixner <tglx@linutronix.de> Acked-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/ktime.h')
-rw-r--r--include/linux/ktime.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 06177ba10a16..e83512f63df5 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -282,6 +282,25 @@ static inline int ktime_equal(const ktime_t cmp1, const ktime_t cmp2)
return cmp1.tv64 == cmp2.tv64;
}
+/**
+ * ktime_compare - Compares two ktime_t variables for less, greater or equal
+ * @cmp1: comparable1
+ * @cmp2: comparable2
+ *
+ * Returns ...
+ * cmp1 < cmp2: return <0
+ * cmp1 == cmp2: return 0
+ * cmp1 > cmp2: return >0
+ */
+static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2)
+{
+ if (cmp1.tv64 < cmp2.tv64)
+ return -1;
+ if (cmp1.tv64 > cmp2.tv64)
+ return 1;
+ return 0;
+}
+
static inline s64 ktime_to_us(const ktime_t kt)
{
struct timeval tv = ktime_to_timeval(kt);