diff options
Diffstat (limited to 'include/linux/ktime.h')
-rw-r--r-- | include/linux/ktime.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/include/linux/ktime.h b/include/linux/ktime.h index c68c7ac6b232..81bb9c7a4eb3 100644 --- a/include/linux/ktime.h +++ b/include/linux/ktime.h | |||
@@ -57,7 +57,11 @@ typedef union { | |||
57 | } ktime_t; | 57 | } ktime_t; |
58 | 58 | ||
59 | #define KTIME_MAX ((s64)~((u64)1 << 63)) | 59 | #define KTIME_MAX ((s64)~((u64)1 << 63)) |
60 | #define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC) | 60 | #if (BITS_PER_LONG == 64) |
61 | # define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC) | ||
62 | #else | ||
63 | # define KTIME_SEC_MAX LONG_MAX | ||
64 | #endif | ||
61 | 65 | ||
62 | /* | 66 | /* |
63 | * ktime_t definitions when using the 64-bit scalar representation: | 67 | * ktime_t definitions when using the 64-bit scalar representation: |
@@ -255,6 +259,12 @@ static inline s64 ktime_to_ns(const ktime_t kt) | |||
255 | 259 | ||
256 | #endif | 260 | #endif |
257 | 261 | ||
262 | static inline s64 ktime_to_us(const ktime_t kt) | ||
263 | { | ||
264 | struct timeval tv = ktime_to_timeval(kt); | ||
265 | return (s64) tv.tv_sec * USEC_PER_SEC + tv.tv_usec; | ||
266 | } | ||
267 | |||
258 | /* | 268 | /* |
259 | * The resolution of the clocks. The resolution value is returned in | 269 | * The resolution of the clocks. The resolution value is returned in |
260 | * the clock_getres() system call to give application programmers an | 270 | * the clock_getres() system call to give application programmers an |