Loading...
1#ifndef _ASM_GENERIC_CPUTIME_H
2#define _ASM_GENERIC_CPUTIME_H
3
4#include <linux/time.h>
5#include <linux/jiffies.h>
6
7typedef unsigned long cputime_t;
8
9#define cputime_zero (0UL)
10#define cputime_one_jiffy jiffies_to_cputime(1)
11#define cputime_max ((~0UL >> 1) - 1)
12#define cputime_add(__a, __b) ((__a) + (__b))
13#define cputime_sub(__a, __b) ((__a) - (__b))
14#define cputime_div(__a, __n) ((__a) / (__n))
15#define cputime_halve(__a) ((__a) >> 1)
16#define cputime_eq(__a, __b) ((__a) == (__b))
17#define cputime_gt(__a, __b) ((__a) > (__b))
18#define cputime_ge(__a, __b) ((__a) >= (__b))
19#define cputime_lt(__a, __b) ((__a) < (__b))
20#define cputime_le(__a, __b) ((__a) <= (__b))
21#define cputime_to_jiffies(__ct) (__ct)
22#define cputime_to_scaled(__ct) (__ct)
23#define jiffies_to_cputime(__hz) (__hz)
24
25typedef u64 cputime64_t;
26
27#define cputime64_zero (0ULL)
28#define cputime64_add(__a, __b) ((__a) + (__b))
29#define cputime64_sub(__a, __b) ((__a) - (__b))
30#define cputime64_to_jiffies64(__ct) (__ct)
31#define jiffies64_to_cputime64(__jif) (__jif)
32#define cputime_to_cputime64(__ct) ((u64) __ct)
33#define cputime64_gt(__a, __b) ((__a) > (__b))
34
35#define nsecs_to_cputime64(__ct) nsecs_to_jiffies64(__ct)
36
37
38/*
39 * Convert cputime to microseconds and back.
40 */
41#define cputime_to_usecs(__ct) jiffies_to_usecs(__ct);
42#define usecs_to_cputime(__msecs) usecs_to_jiffies(__msecs);
43
44/*
45 * Convert cputime to seconds and back.
46 */
47#define cputime_to_secs(jif) ((jif) / HZ)
48#define secs_to_cputime(sec) ((sec) * HZ)
49
50/*
51 * Convert cputime to timespec and back.
52 */
53#define timespec_to_cputime(__val) timespec_to_jiffies(__val)
54#define cputime_to_timespec(__ct,__val) jiffies_to_timespec(__ct,__val)
55
56/*
57 * Convert cputime to timeval and back.
58 */
59#define timeval_to_cputime(__val) timeval_to_jiffies(__val)
60#define cputime_to_timeval(__ct,__val) jiffies_to_timeval(__ct,__val)
61
62/*
63 * Convert cputime to clock and back.
64 */
65#define cputime_to_clock_t(__ct) jiffies_to_clock_t(__ct)
66#define clock_t_to_cputime(__x) clock_t_to_jiffies(__x)
67
68/*
69 * Convert cputime64 to clock.
70 */
71#define cputime64_to_clock_t(__ct) jiffies_64_to_clock_t(__ct)
72
73#endif
1#ifndef _ASM_GENERIC_CPUTIME_H
2#define _ASM_GENERIC_CPUTIME_H
3
4#include <linux/time.h>
5#include <linux/jiffies.h>
6
7typedef unsigned long __nocast cputime_t;
8
9#define cputime_one_jiffy jiffies_to_cputime(1)
10#define cputime_to_jiffies(__ct) (__force unsigned long)(__ct)
11#define cputime_to_scaled(__ct) (__ct)
12#define jiffies_to_cputime(__hz) (__force cputime_t)(__hz)
13
14typedef u64 __nocast cputime64_t;
15
16#define cputime64_to_jiffies64(__ct) (__force u64)(__ct)
17#define jiffies64_to_cputime64(__jif) (__force cputime64_t)(__jif)
18
19#define nsecs_to_cputime64(__ct) \
20 jiffies64_to_cputime64(nsecs_to_jiffies64(__ct))
21
22
23/*
24 * Convert cputime to microseconds and back.
25 */
26#define cputime_to_usecs(__ct) \
27 jiffies_to_usecs(cputime_to_jiffies(__ct))
28#define usecs_to_cputime(__usec) \
29 jiffies_to_cputime(usecs_to_jiffies(__usec))
30#define usecs_to_cputime64(__usec) \
31 jiffies64_to_cputime64(nsecs_to_jiffies64((__usec) * 1000))
32
33/*
34 * Convert cputime to seconds and back.
35 */
36#define cputime_to_secs(jif) (cputime_to_jiffies(jif) / HZ)
37#define secs_to_cputime(sec) jiffies_to_cputime((sec) * HZ)
38
39/*
40 * Convert cputime to timespec and back.
41 */
42#define timespec_to_cputime(__val) \
43 jiffies_to_cputime(timespec_to_jiffies(__val))
44#define cputime_to_timespec(__ct,__val) \
45 jiffies_to_timespec(cputime_to_jiffies(__ct),__val)
46
47/*
48 * Convert cputime to timeval and back.
49 */
50#define timeval_to_cputime(__val) \
51 jiffies_to_cputime(timeval_to_jiffies(__val))
52#define cputime_to_timeval(__ct,__val) \
53 jiffies_to_timeval(cputime_to_jiffies(__ct),__val)
54
55/*
56 * Convert cputime to clock and back.
57 */
58#define cputime_to_clock_t(__ct) \
59 jiffies_to_clock_t(cputime_to_jiffies(__ct))
60#define clock_t_to_cputime(__x) \
61 jiffies_to_cputime(clock_t_to_jiffies(__x))
62
63/*
64 * Convert cputime64 to clock.
65 */
66#define cputime64_to_clock_t(__ct) \
67 jiffies_64_to_clock_t(cputime64_to_jiffies64(__ct))
68
69#endif