cputime.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_one_jiffy jiffies_to_cputime(1)
  8. #define cputime_max ((~0UL >> 1) - 1)
  9. #define cputime_add(__a, __b) ((__a) + (__b))
  10. #define cputime_sub(__a, __b) ((__a) - (__b))
  11. #define cputime_div(__a, __n) ((__a) / (__n))
  12. #define cputime_halve(__a) ((__a) >> 1)
  13. #define cputime_eq(__a, __b) ((__a) == (__b))
  14. #define cputime_gt(__a, __b) ((__a) > (__b))
  15. #define cputime_ge(__a, __b) ((__a) >= (__b))
  16. #define cputime_lt(__a, __b) ((__a) < (__b))
  17. #define cputime_le(__a, __b) ((__a) <= (__b))
  18. #define cputime_to_jiffies(__ct) (__ct)
  19. #define cputime_to_scaled(__ct) (__ct)
  20. #define jiffies_to_cputime(__hz) (__hz)
  21. typedef u64 cputime64_t;
  22. #define cputime64_zero (0ULL)
  23. #define cputime64_add(__a, __b) ((__a) + (__b))
  24. #define cputime64_sub(__a, __b) ((__a) - (__b))
  25. #define cputime64_to_jiffies64(__ct) (__ct)
  26. #define jiffies64_to_cputime64(__jif) (__jif)
  27. #define cputime_to_cputime64(__ct) ((u64) __ct)
  28. #define cputime64_gt(__a, __b) ((__a) > (__b))
  29. #define nsecs_to_cputime64(__ct) nsecs_to_jiffies64(__ct)
  30. /*
  31. * Convert cputime to microseconds and back.
  32. */
  33. #define cputime_to_usecs(__ct) jiffies_to_usecs(__ct);
  34. #define usecs_to_cputime(__msecs) usecs_to_jiffies(__msecs);
  35. /*
  36. * Convert cputime to seconds and back.
  37. */
  38. #define cputime_to_secs(jif) ((jif) / HZ)
  39. #define secs_to_cputime(sec) ((sec) * HZ)
  40. /*
  41. * Convert cputime to timespec and back.
  42. */
  43. #define timespec_to_cputime(__val) timespec_to_jiffies(__val)
  44. #define cputime_to_timespec(__ct,__val) jiffies_to_timespec(__ct,__val)
  45. /*
  46. * Convert cputime to timeval and back.
  47. */
  48. #define timeval_to_cputime(__val) timeval_to_jiffies(__val)
  49. #define cputime_to_timeval(__ct,__val) jiffies_to_timeval(__ct,__val)
  50. /*
  51. * Convert cputime to clock and back.
  52. */
  53. #define cputime_to_clock_t(__ct) jiffies_to_clock_t(__ct)
  54. #define clock_t_to_cputime(__x) clock_t_to_jiffies(__x)
  55. /*
  56. * Convert cputime64 to clock.
  57. */
  58. #define cputime64_to_clock_t(__ct) jiffies_64_to_clock_t(__ct)
  59. #endif