Frederic Weisbecker | 3961376 | 2013-01-15 13:25:07 +0100 | [diff] [blame] | 1 | #ifndef _ASM_GENERIC_CPUTIME_JIFFIES_H |
| 2 | #define _ASM_GENERIC_CPUTIME_JIFFIES_H |
| 3 | |
| 4 | typedef unsigned long __nocast cputime_t; |
| 5 | |
| 6 | #define cputime_one_jiffy jiffies_to_cputime(1) |
| 7 | #define cputime_to_jiffies(__ct) (__force unsigned long)(__ct) |
| 8 | #define cputime_to_scaled(__ct) (__ct) |
| 9 | #define jiffies_to_cputime(__hz) (__force cputime_t)(__hz) |
| 10 | |
| 11 | typedef u64 __nocast cputime64_t; |
| 12 | |
| 13 | #define cputime64_to_jiffies64(__ct) (__force u64)(__ct) |
| 14 | #define jiffies64_to_cputime64(__jif) (__force cputime64_t)(__jif) |
| 15 | |
Frederic Weisbecker | ae8dda5 | 2013-01-16 18:02:04 +0100 | [diff] [blame] | 16 | |
| 17 | /* |
| 18 | * Convert nanoseconds to cputime |
| 19 | */ |
| 20 | #define nsecs_to_cputime64(__nsec) \ |
| 21 | jiffies64_to_cputime64(nsecs_to_jiffies64(__nsec)) |
| 22 | #define nsecs_to_cputime(__nsec) \ |
| 23 | jiffies_to_cputime(nsecs_to_jiffies(__nsec)) |
Frederic Weisbecker | 3961376 | 2013-01-15 13:25:07 +0100 | [diff] [blame] | 24 | |
| 25 | |
| 26 | /* |
| 27 | * Convert cputime to microseconds and back. |
| 28 | */ |
| 29 | #define cputime_to_usecs(__ct) \ |
| 30 | jiffies_to_usecs(cputime_to_jiffies(__ct)) |
| 31 | #define usecs_to_cputime(__usec) \ |
| 32 | jiffies_to_cputime(usecs_to_jiffies(__usec)) |
| 33 | #define usecs_to_cputime64(__usec) \ |
| 34 | jiffies64_to_cputime64(nsecs_to_jiffies64((__usec) * 1000)) |
| 35 | |
| 36 | /* |
| 37 | * Convert cputime to seconds and back. |
| 38 | */ |
| 39 | #define cputime_to_secs(jif) (cputime_to_jiffies(jif) / HZ) |
| 40 | #define secs_to_cputime(sec) jiffies_to_cputime((sec) * HZ) |
| 41 | |
| 42 | /* |
| 43 | * Convert cputime to timespec and back. |
| 44 | */ |
| 45 | #define timespec_to_cputime(__val) \ |
| 46 | jiffies_to_cputime(timespec_to_jiffies(__val)) |
| 47 | #define cputime_to_timespec(__ct,__val) \ |
| 48 | jiffies_to_timespec(cputime_to_jiffies(__ct),__val) |
| 49 | |
| 50 | /* |
| 51 | * Convert cputime to timeval and back. |
| 52 | */ |
| 53 | #define timeval_to_cputime(__val) \ |
| 54 | jiffies_to_cputime(timeval_to_jiffies(__val)) |
| 55 | #define cputime_to_timeval(__ct,__val) \ |
| 56 | jiffies_to_timeval(cputime_to_jiffies(__ct),__val) |
| 57 | |
| 58 | /* |
| 59 | * Convert cputime to clock and back. |
| 60 | */ |
| 61 | #define cputime_to_clock_t(__ct) \ |
| 62 | jiffies_to_clock_t(cputime_to_jiffies(__ct)) |
| 63 | #define clock_t_to_cputime(__x) \ |
| 64 | jiffies_to_cputime(clock_t_to_jiffies(__x)) |
| 65 | |
| 66 | /* |
| 67 | * Convert cputime64 to clock. |
| 68 | */ |
| 69 | #define cputime64_to_clock_t(__ct) \ |
| 70 | jiffies_64_to_clock_t(cputime64_to_jiffies64(__ct)) |
| 71 | |
| 72 | #endif |