cputime.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef _ASM_GENERIC_CPUTIME_H
  2. #define _ASM_GENERIC_CPUTIME_H
  3. #include <linux/time.h>
  4. #include <linux/jiffies.h>
  5. typedef unsigned long cputime_t;
  6. #define cputime_zero (0UL)
  7. #define cputime_max ((~0UL >> 1) - 1)
  8. #define cputime_add(__a, __b) ((__a) + (__b))
  9. #define cputime_sub(__a, __b) ((__a) - (__b))
  10. #define cputime_div(__a, __n) ((__a) / (__n))
  11. #define cputime_halve(__a) ((__a) >> 1)
  12. #define cputime_eq(__a, __b) ((__a) == (__b))
  13. #define cputime_gt(__a, __b) ((__a) > (__b))
  14. #define cputime_ge(__a, __b) ((__a) >= (__b))
  15. #define cputime_lt(__a, __b) ((__a) < (__b))
  16. #define cputime_le(__a, __b) ((__a) <= (__b))
  17. #define cputime_to_jiffies(__ct) (__ct)
  18. #define jiffies_to_cputime(__hz) (__hz)
  19. typedef u64 cputime64_t;
  20. #define cputime64_zero (0ULL)
  21. #define cputime64_add(__a, __b) ((__a) + (__b))
  22. #define cputime64_to_jiffies64(__ct) (__ct)
  23. #define cputime_to_cputime64(__ct) ((u64) __ct)
  24. /*
  25. * Convert cputime to milliseconds and back.
  26. */
  27. #define cputime_to_msecs(__ct) jiffies_to_msecs(__ct)
  28. #define msecs_to_cputime(__msecs) msecs_to_jiffies(__msecs)
  29. /*
  30. * Convert cputime to seconds and back.
  31. */
  32. #define cputime_to_secs(jif) ((jif) / HZ)
  33. #define secs_to_cputime(sec) ((sec) * HZ)
  34. /*
  35. * Convert cputime to timespec and back.
  36. */
  37. #define timespec_to_cputime(__val) timespec_to_jiffies(__val)
  38. #define cputime_to_timespec(__ct,__val) jiffies_to_timespec(__ct,__val)
  39. /*
  40. * Convert cputime to timeval and back.
  41. */
  42. #define timeval_to_cputime(__val) timeval_to_jiffies(__val)
  43. #define cputime_to_timeval(__ct,__val) jiffies_to_timeval(__ct,__val)
  44. /*
  45. * Convert cputime to clock and back.
  46. */
  47. #define cputime_to_clock_t(__ct) jiffies_to_clock_t(__ct)
  48. #define clock_t_to_cputime(__x) clock_t_to_jiffies(__x)
  49. /*
  50. * Convert cputime64 to clock.
  51. */
  52. #define cputime64_to_clock_t(__ct) jiffies_64_to_clock_t(__ct)
  53. #endif