Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASM_GENERIC_CPUTIME_H |
| 2 | #define _ASM_GENERIC_CPUTIME_H |
| 3 | |
| 4 | #include <linux/time.h> |
| 5 | #include <linux/jiffies.h> |
| 6 | |
| 7 | typedef unsigned long cputime_t; |
| 8 | |
| 9 | #define cputime_zero (0UL) |
| 10 | #define cputime_max ((~0UL >> 1) - 1) |
| 11 | #define cputime_add(__a, __b) ((__a) + (__b)) |
| 12 | #define cputime_sub(__a, __b) ((__a) - (__b)) |
| 13 | #define cputime_div(__a, __n) ((__a) / (__n)) |
| 14 | #define cputime_halve(__a) ((__a) >> 1) |
| 15 | #define cputime_eq(__a, __b) ((__a) == (__b)) |
| 16 | #define cputime_gt(__a, __b) ((__a) > (__b)) |
| 17 | #define cputime_ge(__a, __b) ((__a) >= (__b)) |
| 18 | #define cputime_lt(__a, __b) ((__a) < (__b)) |
| 19 | #define cputime_le(__a, __b) ((__a) <= (__b)) |
| 20 | #define cputime_to_jiffies(__ct) (__ct) |
| 21 | #define jiffies_to_cputime(__hz) (__hz) |
| 22 | |
| 23 | typedef u64 cputime64_t; |
| 24 | |
| 25 | #define cputime64_zero (0ULL) |
| 26 | #define cputime64_add(__a, __b) ((__a) + (__b)) |
Venkatesh Pallipadi | ccb2fe2 | 2006-06-28 13:49:52 -0700 | [diff] [blame] | 27 | #define cputime64_sub(__a, __b) ((__a) - (__b)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #define cputime64_to_jiffies64(__ct) (__ct) |
Venkatesh Pallipadi | ccb2fe2 | 2006-06-28 13:49:52 -0700 | [diff] [blame] | 29 | #define jiffies64_to_cputime64(__jif) (__jif) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #define cputime_to_cputime64(__ct) ((u64) __ct) |
| 31 | |
| 32 | |
| 33 | /* |
| 34 | * Convert cputime to milliseconds and back. |
| 35 | */ |
| 36 | #define cputime_to_msecs(__ct) jiffies_to_msecs(__ct) |
| 37 | #define msecs_to_cputime(__msecs) msecs_to_jiffies(__msecs) |
| 38 | |
| 39 | /* |
| 40 | * Convert cputime to seconds and back. |
| 41 | */ |
| 42 | #define cputime_to_secs(jif) ((jif) / HZ) |
| 43 | #define secs_to_cputime(sec) ((sec) * HZ) |
| 44 | |
| 45 | /* |
| 46 | * Convert cputime to timespec and back. |
| 47 | */ |
| 48 | #define timespec_to_cputime(__val) timespec_to_jiffies(__val) |
| 49 | #define cputime_to_timespec(__ct,__val) jiffies_to_timespec(__ct,__val) |
| 50 | |
| 51 | /* |
| 52 | * Convert cputime to timeval and back. |
| 53 | */ |
| 54 | #define timeval_to_cputime(__val) timeval_to_jiffies(__val) |
| 55 | #define cputime_to_timeval(__ct,__val) jiffies_to_timeval(__ct,__val) |
| 56 | |
| 57 | /* |
| 58 | * Convert cputime to clock and back. |
| 59 | */ |
| 60 | #define cputime_to_clock_t(__ct) jiffies_to_clock_t(__ct) |
| 61 | #define clock_t_to_cputime(__x) clock_t_to_jiffies(__x) |
| 62 | |
| 63 | /* |
| 64 | * Convert cputime64 to clock. |
| 65 | */ |
| 66 | #define cputime64_to_clock_t(__ct) jiffies_64_to_clock_t(__ct) |
| 67 | |
| 68 | #endif |