Lines Matching refs:ktime_t
4 * ktime_t - nanosecond-resolution time format.
16 * the ktime_t union and further simplifications of the original
28 * ktime_t:
33 * NOPs and most arithmetic ktime_t operations are plain arithmetic
57 } ktime_t;
63 * ktime_t definitions when using the 64-bit scalar representation:
69 * ktime_set - Set a ktime_t variable from a seconds/nanoseconds value
73 * Return the ktime_t representation of the value
75 static inline ktime_t ktime_set(const long secs, const unsigned long nsecs)
79 return (ktime_t){ .tv64 = KTIME_MAX };
81 return (ktime_t) { .tv64 = (s64)secs * NSEC_PER_SEC + (s64)nsecs };
84 /* Subtract two ktime_t variables. rem = lhs -rhs: */
86 ({ (ktime_t){ .tv64 = (lhs).tv64 - (rhs).tv64 }; })
88 /* Add two ktime_t variables. res = lhs + rhs: */
90 ({ (ktime_t){ .tv64 = (lhs).tv64 + (rhs).tv64 }; })
93 * Add a ktime_t variable and a scalar nanosecond value.
97 ({ (ktime_t){ .tv64 = (kt).tv64 + (nsval) }; })
99 /* convert a timespec to ktime_t format: */
100 static inline ktime_t timespec_to_ktime(struct timespec ts)
105 /* convert a timeval to ktime_t format: */
106 static inline ktime_t timeval_to_ktime(struct timeval tv)
111 /* Map the ktime_t to timespec conversion to ns_to_timespec function */
114 /* Map the ktime_t to timeval conversion to ns_to_timeval function */
117 /* Convert ktime_t to nanoseconds - NOP in the scalar storage format: */
123 * Helper macros/inlines to get the ktime_t math right in the timespec
137 /* Set a ktime_t variable to a value in sec/nsec representation: */
138 static inline ktime_t ktime_set(const long secs, const unsigned long nsecs)
140 return (ktime_t) { .tv = { .sec = secs, .nsec = nsecs } };
144 * ktime_sub - subtract two ktime_t variables
150 static inline ktime_t ktime_sub(const ktime_t lhs, const ktime_t rhs)
152 ktime_t res;
162 * ktime_add - add two ktime_t variables
168 static inline ktime_t ktime_add(const ktime_t add1, const ktime_t add2)
170 ktime_t res;
188 * ktime_add_ns - Add a scalar nanoseconds value to a ktime_t variable
192 * Returns the sum of kt and nsec in ktime_t format
194 extern ktime_t ktime_add_ns(const ktime_t kt, u64 nsec);
197 * timespec_to_ktime - convert a timespec to ktime_t format
200 * Returns a ktime_t variable with the converted timespec value
202 static inline ktime_t timespec_to_ktime(const struct timespec ts)
204 return (ktime_t) { .tv = { .sec = (s32)ts.tv_sec,
209 * timeval_to_ktime - convert a timeval to ktime_t format
212 * Returns a ktime_t variable with the converted timeval value
214 static inline ktime_t timeval_to_ktime(const struct timeval tv)
216 return (ktime_t) { .tv = { .sec = (s32)tv.tv_sec,
221 * ktime_to_timespec - convert a ktime_t variable to timespec format
222 * @kt: the ktime_t variable to convert
226 static inline struct timespec ktime_to_timespec(const ktime_t kt)
233 * ktime_to_timeval - convert a ktime_t variable to timeval format
234 * @kt: the ktime_t variable to convert
238 static inline struct timeval ktime_to_timeval(const ktime_t kt)
246 * ktime_to_ns - convert a ktime_t variable to scalar nanoseconds
247 * @kt: the ktime_t variable to convert
251 static inline u64 ktime_to_ns(const ktime_t kt)
264 #define KTIME_REALTIME_RES (ktime_t){ .tv64 = TICK_NSEC }
265 #define KTIME_MONOTONIC_RES (ktime_t){ .tv64 = TICK_NSEC }