blob: d5cb78f539861afdc82eae345ee4c8148fb2448e [file] [log] [blame]
Frederic Weisbecker39613762013-01-15 13:25:07 +01001#ifndef _ASM_GENERIC_CPUTIME_JIFFIES_H
2#define _ASM_GENERIC_CPUTIME_JIFFIES_H
3
4typedef 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
11typedef 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 Weisbeckerae8dda52013-01-16 18:02:04 +010016
17/*
Frederic Weisbeckerd8a9ce32014-03-05 16:22:37 +010018 * Convert nanoseconds <-> cputime
Frederic Weisbeckerae8dda52013-01-16 18:02:04 +010019 */
Frederic Weisbeckerd8a9ce32014-03-05 16:22:37 +010020#define cputime_to_nsecs(__ct) \
21 jiffies_to_nsecs(cputime_to_jiffies(__ct))
Frederic Weisbeckerae8dda52013-01-16 18:02:04 +010022#define nsecs_to_cputime64(__nsec) \
23 jiffies64_to_cputime64(nsecs_to_jiffies64(__nsec))
24#define nsecs_to_cputime(__nsec) \
25 jiffies_to_cputime(nsecs_to_jiffies(__nsec))
Frederic Weisbecker39613762013-01-15 13:25:07 +010026
27
28/*
29 * Convert cputime to microseconds and back.
30 */
31#define cputime_to_usecs(__ct) \
32 jiffies_to_usecs(cputime_to_jiffies(__ct))
33#define usecs_to_cputime(__usec) \
34 jiffies_to_cputime(usecs_to_jiffies(__usec))
35#define usecs_to_cputime64(__usec) \
36 jiffies64_to_cputime64(nsecs_to_jiffies64((__usec) * 1000))
37
38/*
39 * Convert cputime to seconds and back.
40 */
41#define cputime_to_secs(jif) (cputime_to_jiffies(jif) / HZ)
42#define secs_to_cputime(sec) jiffies_to_cputime((sec) * HZ)
43
44/*
45 * Convert cputime to timespec and back.
46 */
47#define timespec_to_cputime(__val) \
48 jiffies_to_cputime(timespec_to_jiffies(__val))
49#define cputime_to_timespec(__ct,__val) \
50 jiffies_to_timespec(cputime_to_jiffies(__ct),__val)
51
52/*
53 * Convert cputime to timeval and back.
54 */
55#define timeval_to_cputime(__val) \
56 jiffies_to_cputime(timeval_to_jiffies(__val))
57#define cputime_to_timeval(__ct,__val) \
58 jiffies_to_timeval(cputime_to_jiffies(__ct),__val)
59
60/*
61 * Convert cputime to clock and back.
62 */
63#define cputime_to_clock_t(__ct) \
64 jiffies_to_clock_t(cputime_to_jiffies(__ct))
65#define clock_t_to_cputime(__x) \
66 jiffies_to_cputime(clock_t_to_jiffies(__x))
67
68/*
69 * Convert cputime64 to clock.
70 */
71#define cputime64_to_clock_t(__ct) \
72 jiffies_64_to_clock_t(cputime64_to_jiffies64(__ct))
73
74#endif