21 #ifndef _LINUX_KTIME_H
22 #define _LINUX_KTIME_H
24 #include <linux/time.h>
48 #if BITS_PER_LONG != 64 && !defined(CONFIG_KTIME_SCALAR)
65 #if (BITS_PER_LONG == 64) || defined(CONFIG_KTIME_SCALAR)
74 static inline ktime_t ktime_set(
const long secs,
const unsigned long nsecs)
76 #if (BITS_PER_LONG == 64)
84 #define ktime_sub(lhs, rhs) \
85 ({ (ktime_t){ .tv64 = (lhs).tv64 - (rhs).tv64 }; })
88 #define ktime_add(lhs, rhs) \
89 ({ (ktime_t){ .tv64 = (lhs).tv64 + (rhs).tv64 }; })
95 #define ktime_add_ns(kt, nsval) \
96 ({ (ktime_t){ .tv64 = (kt).tv64 + (nsval) }; })
102 #define ktime_sub_ns(kt, nsval) \
103 ({ (ktime_t){ .tv64 = (kt).tv64 - (nsval) }; })
118 #define ktime_to_timespec(kt) ns_to_timespec((kt).tv64)
121 #define ktime_to_timeval(kt) ns_to_timeval((kt).tv64)
124 #define ktime_to_ns(kt) ((kt).tv64)
144 static inline ktime_t ktime_set(
const long secs,
const unsigned long nsecs)
146 return (
ktime_t) { .
tv = { .sec = secs, .nsec = nsecs } };
244 .tv_nsec = (
long) kt.tv.nsec };
256 .tv_sec = (
time_t) kt.tv.sec,
266 static inline s64 ktime_to_ns(
const ktime_t kt)
280 static inline int ktime_equal(
const ktime_t cmp1,
const ktime_t cmp2)
285 static inline s64 ktime_to_us(
const ktime_t kt)
287 struct timeval tv = ktime_to_timeval(kt);
291 static inline s64 ktime_to_ms(
const ktime_t kt)
293 struct timeval tv = ktime_to_timeval(kt);
299 return ktime_to_us(ktime_sub(later, earlier));
320 #define LOW_RES_NSEC TICK_NSEC
321 #define KTIME_LOW_RES (ktime_t){ .tv64 = LOW_RES_NSEC }
327 #define ktime_get_real_ts(ts) getnstimeofday(ts)