aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ia64
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ia64')
-rw-r--r--arch/ia64/include/asm/cputime.h69
1 files changed, 32 insertions, 37 deletions
diff --git a/arch/ia64/include/asm/cputime.h b/arch/ia64/include/asm/cputime.h
index 6073b187528a..461e52f0277f 100644
--- a/arch/ia64/include/asm/cputime.h
+++ b/arch/ia64/include/asm/cputime.h
@@ -26,59 +26,51 @@
26#include <linux/jiffies.h> 26#include <linux/jiffies.h>
27#include <asm/processor.h> 27#include <asm/processor.h>
28 28
29typedef u64 cputime_t; 29typedef u64 __nocast cputime_t;
30typedef u64 cputime64_t; 30typedef u64 __nocast cputime64_t;
31 31
32#define cputime_zero ((cputime_t)0)
33#define cputime_one_jiffy jiffies_to_cputime(1) 32#define cputime_one_jiffy jiffies_to_cputime(1)
34#define cputime_max ((~((cputime_t)0) >> 1) - 1)
35#define cputime_add(__a, __b) ((__a) + (__b))
36#define cputime_sub(__a, __b) ((__a) - (__b))
37#define cputime_div(__a, __n) ((__a) / (__n))
38#define cputime_halve(__a) ((__a) >> 1)
39#define cputime_eq(__a, __b) ((__a) == (__b))
40#define cputime_gt(__a, __b) ((__a) > (__b))
41#define cputime_ge(__a, __b) ((__a) >= (__b))
42#define cputime_lt(__a, __b) ((__a) < (__b))
43#define cputime_le(__a, __b) ((__a) <= (__b))
44
45#define cputime64_zero ((cputime64_t)0)
46#define cputime64_add(__a, __b) ((__a) + (__b))
47#define cputime64_sub(__a, __b) ((__a) - (__b))
48#define cputime_to_cputime64(__ct) (__ct)
49 33
50/* 34/*
51 * Convert cputime <-> jiffies (HZ) 35 * Convert cputime <-> jiffies (HZ)
52 */ 36 */
53#define cputime_to_jiffies(__ct) ((__ct) / (NSEC_PER_SEC / HZ)) 37#define cputime_to_jiffies(__ct) \
54#define jiffies_to_cputime(__jif) ((__jif) * (NSEC_PER_SEC / HZ)) 38 ((__force u64)(__ct) / (NSEC_PER_SEC / HZ))
55#define cputime64_to_jiffies64(__ct) ((__ct) / (NSEC_PER_SEC / HZ)) 39#define jiffies_to_cputime(__jif) \
56#define jiffies64_to_cputime64(__jif) ((__jif) * (NSEC_PER_SEC / HZ)) 40 (__force cputime_t)((__jif) * (NSEC_PER_SEC / HZ))
41#define cputime64_to_jiffies64(__ct) \
42 ((__force u64)(__ct) / (NSEC_PER_SEC / HZ))
43#define jiffies64_to_cputime64(__jif) \
44 (__force cputime64_t)((__jif) * (NSEC_PER_SEC / HZ))
57 45
58/* 46/*
59 * Convert cputime <-> microseconds 47 * Convert cputime <-> microseconds
60 */ 48 */
61#define cputime_to_usecs(__ct) ((__ct) / NSEC_PER_USEC) 49#define cputime_to_usecs(__ct) \
62#define usecs_to_cputime(__usecs) ((__usecs) * NSEC_PER_USEC) 50 ((__force u64)(__ct) / NSEC_PER_USEC)
51#define usecs_to_cputime(__usecs) \
52 (__force cputime_t)((__usecs) * NSEC_PER_USEC)
63 53
64/* 54/*
65 * Convert cputime <-> seconds 55 * Convert cputime <-> seconds
66 */ 56 */
67#define cputime_to_secs(__ct) ((__ct) / NSEC_PER_SEC) 57#define cputime_to_secs(__ct) \
68#define secs_to_cputime(__secs) ((__secs) * NSEC_PER_SEC) 58 ((__force u64)(__ct) / NSEC_PER_SEC)
59#define secs_to_cputime(__secs) \
60 (__force cputime_t)((__secs) * NSEC_PER_SEC)
69 61
70/* 62/*
71 * Convert cputime <-> timespec (nsec) 63 * Convert cputime <-> timespec (nsec)
72 */ 64 */
73static inline cputime_t timespec_to_cputime(const struct timespec *val) 65static inline cputime_t timespec_to_cputime(const struct timespec *val)
74{ 66{
75 cputime_t ret = val->tv_sec * NSEC_PER_SEC; 67 u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_nsec;
76 return (ret + val->tv_nsec); 68 return (__force cputime_t) ret;
77} 69}
78static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val) 70static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val)
79{ 71{
80 val->tv_sec = ct / NSEC_PER_SEC; 72 val->tv_sec = (__force u64) ct / NSEC_PER_SEC;
81 val->tv_nsec = ct % NSEC_PER_SEC; 73 val->tv_nsec = (__force u64) ct % NSEC_PER_SEC;
82} 74}
83 75
84/* 76/*
@@ -86,25 +78,28 @@ static inline void cputime_to_timespec(const cputime_t ct, struct timespec *val)
86 */ 78 */
87static inline cputime_t timeval_to_cputime(struct timeval *val) 79static inline cputime_t timeval_to_cputime(struct timeval *val)
88{ 80{
89 cputime_t ret = val->tv_sec * NSEC_PER_SEC; 81 u64 ret = val->tv_sec * NSEC_PER_SEC + val->tv_usec * NSEC_PER_USEC;
90 return (ret + val->tv_usec * NSEC_PER_USEC); 82 return (__force cputime_t) ret;
91} 83}
92static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val) 84static inline void cputime_to_timeval(const cputime_t ct, struct timeval *val)
93{ 85{
94 val->tv_sec = ct / NSEC_PER_SEC; 86 val->tv_sec = (__force u64) ct / NSEC_PER_SEC;
95 val->tv_usec = (ct % NSEC_PER_SEC) / NSEC_PER_USEC; 87 val->tv_usec = ((__force u64) ct % NSEC_PER_SEC) / NSEC_PER_USEC;
96} 88}
97 89
98/* 90/*
99 * Convert cputime <-> clock (USER_HZ) 91 * Convert cputime <-> clock (USER_HZ)
100 */ 92 */
101#define cputime_to_clock_t(__ct) ((__ct) / (NSEC_PER_SEC / USER_HZ)) 93#define cputime_to_clock_t(__ct) \
102#define clock_t_to_cputime(__x) ((__x) * (NSEC_PER_SEC / USER_HZ)) 94 ((__force u64)(__ct) / (NSEC_PER_SEC / USER_HZ))
95#define clock_t_to_cputime(__x) \
96 (__force cputime_t)((__x) * (NSEC_PER_SEC / USER_HZ))
103 97
104/* 98/*
105 * Convert cputime64 to clock. 99 * Convert cputime64 to clock.
106 */ 100 */
107#define cputime64_to_clock_t(__ct) cputime_to_clock_t((cputime_t)__ct) 101#define cputime64_to_clock_t(__ct) \
102 cputime_to_clock_t((__force cputime_t)__ct)
108 103
109#endif /* CONFIG_VIRT_CPU_ACCOUNTING */ 104#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
110#endif /* __IA64_CPUTIME_H */ 105#endif /* __IA64_CPUTIME_H */