diff options
Diffstat (limited to 'include/linux/ktime.h')
-rw-r--r-- | include/linux/ktime.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h index 1bd6552cc341..f3dec45ef874 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h | |||
@@ -10,6 +10,12 @@ | |||
10 | * | 10 | * |
11 | * Started by: Thomas Gleixner and Ingo Molnar | 11 | * Started by: Thomas Gleixner and Ingo Molnar |
12 | * | 12 | * |
13 | * Credits: | ||
14 | * | ||
15 | * Roman Zippel provided the ideas and primary code snippets of | ||
16 | * the ktime_t union and further simplifications of the original | ||
17 | * code. | ||
18 | * | ||
13 | * For licencing details see kernel-base/COPYING | 19 | * For licencing details see kernel-base/COPYING |
14 | */ | 20 | */ |
15 | #ifndef _LINUX_KTIME_H | 21 | #ifndef _LINUX_KTIME_H |
@@ -90,10 +96,16 @@ static inline ktime_t ktime_set(const long secs, const unsigned long nsecs) | |||
90 | ({ (ktime_t){ .tv64 = (kt).tv64 + (nsval) }; }) | 96 | ({ (ktime_t){ .tv64 = (kt).tv64 + (nsval) }; }) |
91 | 97 | ||
92 | /* convert a timespec to ktime_t format: */ | 98 | /* convert a timespec to ktime_t format: */ |
93 | #define timespec_to_ktime(ts) ktime_set((ts).tv_sec, (ts).tv_nsec) | 99 | static inline ktime_t timespec_to_ktime(struct timespec ts) |
100 | { | ||
101 | return ktime_set(ts.tv_sec, ts.tv_nsec); | ||
102 | } | ||
94 | 103 | ||
95 | /* convert a timeval to ktime_t format: */ | 104 | /* convert a timeval to ktime_t format: */ |
96 | #define timeval_to_ktime(tv) ktime_set((tv).tv_sec, (tv).tv_usec * 1000) | 105 | static inline ktime_t timeval_to_ktime(struct timeval tv) |
106 | { | ||
107 | return ktime_set(tv.tv_sec, tv.tv_usec * NSEC_PER_USEC); | ||
108 | } | ||
97 | 109 | ||
98 | /* Map the ktime_t to timespec conversion to ns_to_timespec function */ | 110 | /* Map the ktime_t to timespec conversion to ns_to_timespec function */ |
99 | #define ktime_to_timespec(kt) ns_to_timespec((kt).tv64) | 111 | #define ktime_to_timespec(kt) ns_to_timespec((kt).tv64) |