Commit | Line | Data |
---|---|---|
1da177e4 LT |
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) | |
06b8e878 | 21 | #define cputime_to_scaled(__ct) (__ct) |
1da177e4 LT |
22 | #define jiffies_to_cputime(__hz) (__hz) |
23 | ||
24 | typedef u64 cputime64_t; | |
25 | ||
26 | #define cputime64_zero (0ULL) | |
27 | #define cputime64_add(__a, __b) ((__a) + (__b)) | |
ccb2fe20 | 28 | #define cputime64_sub(__a, __b) ((__a) - (__b)) |
1da177e4 | 29 | #define cputime64_to_jiffies64(__ct) (__ct) |
ccb2fe20 | 30 | #define jiffies64_to_cputime64(__jif) (__jif) |
1da177e4 LT |
31 | #define cputime_to_cputime64(__ct) ((u64) __ct) |
32 | ||
33 | ||
34 | /* | |
35 | * Convert cputime to milliseconds and back. | |
36 | */ | |
37 | #define cputime_to_msecs(__ct) jiffies_to_msecs(__ct) | |
38 | #define msecs_to_cputime(__msecs) msecs_to_jiffies(__msecs) | |
39 | ||
40 | /* | |
41 | * Convert cputime to seconds and back. | |
42 | */ | |
43 | #define cputime_to_secs(jif) ((jif) / HZ) | |
44 | #define secs_to_cputime(sec) ((sec) * HZ) | |
45 | ||
46 | /* | |
47 | * Convert cputime to timespec and back. | |
48 | */ | |
49 | #define timespec_to_cputime(__val) timespec_to_jiffies(__val) | |
50 | #define cputime_to_timespec(__ct,__val) jiffies_to_timespec(__ct,__val) | |
51 | ||
52 | /* | |
53 | * Convert cputime to timeval and back. | |
54 | */ | |
55 | #define timeval_to_cputime(__val) timeval_to_jiffies(__val) | |
56 | #define cputime_to_timeval(__ct,__val) jiffies_to_timeval(__ct,__val) | |
57 | ||
58 | /* | |
59 | * Convert cputime to clock and back. | |
60 | */ | |
61 | #define cputime_to_clock_t(__ct) jiffies_to_clock_t(__ct) | |
62 | #define clock_t_to_cputime(__x) clock_t_to_jiffies(__x) | |
63 | ||
64 | /* | |
65 | * Convert cputime64 to clock. | |
66 | */ | |
67 | #define cputime64_to_clock_t(__ct) jiffies_64_to_clock_t(__ct) | |
68 | ||
69 | #endif |