summaryrefslogtreecommitdiffstats
path: root/include/linux/ktime.h
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-06-11 18:19:28 +0200
committerDavid S. Miller <davem@davemloft.net>2014-06-11 12:23:17 -0700
commit67cb9366ff5f99868100198efba5ca88aaa6ad25 (patch)
tree0e95142623a1bee9d773489ef0c126af91021724 /include/linux/ktime.h
parent9181a6bd18009bf417bc865fd862075c335cc1dd (diff)
downloadtalos-op-linux-67cb9366ff5f99868100198efba5ca88aaa6ad25.tar.gz
talos-op-linux-67cb9366ff5f99868100198efba5ca88aaa6ad25.zip
ktime: add ktime_after and ktime_before helper
Add two minimal helper functions analogous to time_before() and time_after() that will later on both be needed by SCTP code. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/ktime.h')
-rw-r--r--include/linux/ktime.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 31c0cd1c941a..de9e46e6bcc9 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -304,6 +304,30 @@ static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2)
return 0;
}
+/**
+ * ktime_after - Compare if a ktime_t value is bigger than another one.
+ * @cmp1: comparable1
+ * @cmp2: comparable2
+ *
+ * Return: true if cmp1 happened after cmp2.
+ */
+static inline bool ktime_after(const ktime_t cmp1, const ktime_t cmp2)
+{
+ return ktime_compare(cmp1, cmp2) > 0;
+}
+
+/**
+ * ktime_before - Compare if a ktime_t value is smaller than another one.
+ * @cmp1: comparable1
+ * @cmp2: comparable2
+ *
+ * Return: true if cmp1 happened before cmp2.
+ */
+static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2)
+{
+ return ktime_compare(cmp1, cmp2) < 0;
+}
+
static inline s64 ktime_to_us(const ktime_t kt)
{
struct timeval tv = ktime_to_timeval(kt);
OpenPOWER on IntegriCloud