| 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) | 
| Stanislaw Gruszka | a42548a | 2009-07-29 12:15:29 +0200 | [diff] [blame] | 10 | #define cputime_one_jiffy		jiffies_to_cputime(1) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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) | 
| Michael Neuling | 06b8e87 | 2008-02-06 01:36:12 -0800 | [diff] [blame] | 22 | #define cputime_to_scaled(__ct)		(__ct) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #define jiffies_to_cputime(__hz)	(__hz) | 
 | 24 |  | 
 | 25 | typedef u64 cputime64_t; | 
 | 26 |  | 
 | 27 | #define cputime64_zero (0ULL) | 
 | 28 | #define cputime64_add(__a, __b)		((__a) + (__b)) | 
| Venkatesh Pallipadi | ccb2fe2 | 2006-06-28 13:49:52 -0700 | [diff] [blame] | 29 | #define cputime64_sub(__a, __b)		((__a) - (__b)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #define cputime64_to_jiffies64(__ct)	(__ct) | 
| Venkatesh Pallipadi | ccb2fe2 | 2006-06-28 13:49:52 -0700 | [diff] [blame] | 31 | #define jiffies64_to_cputime64(__jif)	(__jif) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #define cputime_to_cputime64(__ct)	((u64) __ct) | 
 | 33 |  | 
 | 34 |  | 
 | 35 | /* | 
| Michael Holzheu | d57af9b | 2010-10-27 15:34:45 -0700 | [diff] [blame] | 36 |  * Convert cputime to microseconds and back. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 |  */ | 
| Michael Holzheu | d57af9b | 2010-10-27 15:34:45 -0700 | [diff] [blame] | 38 | #define cputime_to_usecs(__ct)		jiffies_to_usecs(__ct); | 
 | 39 | #define usecs_to_cputime(__msecs)	usecs_to_jiffies(__msecs); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 |  | 
 | 41 | /* | 
 | 42 |  * Convert cputime to seconds and back. | 
 | 43 |  */ | 
 | 44 | #define cputime_to_secs(jif)		((jif) / HZ) | 
 | 45 | #define secs_to_cputime(sec)		((sec) * HZ) | 
 | 46 |  | 
 | 47 | /* | 
 | 48 |  * Convert cputime to timespec and back. | 
 | 49 |  */ | 
 | 50 | #define timespec_to_cputime(__val)	timespec_to_jiffies(__val) | 
 | 51 | #define cputime_to_timespec(__ct,__val)	jiffies_to_timespec(__ct,__val) | 
 | 52 |  | 
 | 53 | /* | 
 | 54 |  * Convert cputime to timeval and back. | 
 | 55 |  */ | 
 | 56 | #define timeval_to_cputime(__val)	timeval_to_jiffies(__val) | 
 | 57 | #define cputime_to_timeval(__ct,__val)	jiffies_to_timeval(__ct,__val) | 
 | 58 |  | 
 | 59 | /* | 
 | 60 |  * Convert cputime to clock and back. | 
 | 61 |  */ | 
 | 62 | #define cputime_to_clock_t(__ct)	jiffies_to_clock_t(__ct) | 
 | 63 | #define clock_t_to_cputime(__x)		clock_t_to_jiffies(__x) | 
 | 64 |  | 
 | 65 | /* | 
 | 66 |  * Convert cputime64 to clock. | 
 | 67 |  */ | 
 | 68 | #define cputime64_to_clock_t(__ct)	jiffies_64_to_clock_t(__ct) | 
 | 69 |  | 
 | 70 | #endif |