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