[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <152261532989.30503.8240475094491126505.stgit@warthog.procyon.org.uk>
Date: Sun, 01 Apr 2018 21:42:09 +0100
From: David Howells <dhowells@...hat.com>
To: linux-kernel@...r.kernel.org
Subject: [PATCH 19/45] C++: Turn ktime_add/sub_ns() into inline template
functions
Turn ktime ns arithmetic functions into template functions to handle the
nanosecond value type conversion correctly.
Signed-off-by: David Howells <dhowells@...hat.com>
---
include/linux/ktime.h | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 5b9fddbaac41..d46a16f23ffc 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -58,13 +58,21 @@ static inline ktime_t ktime_set(const s64 secs, const unsigned long nsecs)
* Add a ktime_t variable and a scalar nanosecond value.
* res = kt + nsval:
*/
-#define ktime_add_ns(kt, nsval) ((kt) + (nsval))
+template <typename NSVAL>
+static inline ktime_t ktime_add_ns(ktime_t kt, NSVAL nsval)
+{
+ return kt + nsval;
+}
/*
* Subtract a scalar nanosecod from a ktime_t variable
* res = kt - nsval:
*/
-#define ktime_sub_ns(kt, nsval) ((kt) - (nsval))
+template <typename NSVAL>
+static inline ktime_t ktime_sub_ns(ktime_t kt, NSVAL nsval)
+{
+ return kt - nsval;
+}
/* convert a timespec to ktime_t format: */
static inline ktime_t timespec_to_ktime(struct timespec ts)
Powered by blists - more mailing lists