Add comparison functions for ktime_t I was using ktime timing for some custom debugging code and missed easy functions to compare ktime_ts. It was possible to fix this using ktime_to_ns(), but that looked a little ugly. Add explicit comparison functions instead. Signed-off-by: Andi Kleen --- include/linux/ktime.h | 9 +++++++++ 1 file changed, 9 insertions(+) Index: linux/include/linux/ktime.h =================================================================== --- linux.orig/include/linux/ktime.h +++ linux/include/linux/ktime.h @@ -103,6 +103,15 @@ static inline ktime_t ktime_set(const lo ({ (ktime_t){ .tv64 = (kt).tv64 + (nsval) }; }) /* + * ktime comparators + */ +#define ktime_before(a, b) ((a).tv64 < (b).tv64) +#define ktime_eq(a, b) ((a).tv64 == (b).tv64) +#define ktime_after(a, b) ((a).tv64 > (b).tv64) +#define ktime_after_eq(a, b) ((a).tv64 >= (b).tv64) +#define ktime_before_eq(a, b) ((a).tv64 <= (b).tv64) + +/* * Subtract a scalar nanosecod from a ktime_t variable * res = kt - nsval: */