cputime_jiffies.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _ASM_GENERIC_CPUTIME_JIFFIES_H
  2. #define _ASM_GENERIC_CPUTIME_JIFFIES_H
  3. typedef unsigned long __nocast cputime_t;
  4. #define cmpxchg_cputime(ptr, old, new) cmpxchg(ptr, old, new)
  5. #define cputime_one_jiffy jiffies_to_cputime(1)
  6. #define cputime_to_jiffies(__ct) (__force unsigned long)(__ct)
  7. #define cputime_to_scaled(__ct) (__ct)
  8. #define jiffies_to_cputime(__hz) (__force cputime_t)(__hz)
  9. typedef u64 __nocast cputime64_t;
  10. #define cputime64_to_jiffies64(__ct) (__force u64)(__ct)
  11. #define jiffies64_to_cputime64(__jif) (__force cputime64_t)(__jif)
  12. /*
  13. * Convert nanoseconds <-> cputime
  14. */
  15. #define cputime_to_nsecs(__ct) \
  16. jiffies_to_nsecs(cputime_to_jiffies(__ct))
  17. #define nsecs_to_cputime64(__nsec) \
  18. jiffies64_to_cputime64(nsecs_to_jiffies64(__nsec))
  19. #define nsecs_to_cputime(__nsec) \
  20. jiffies_to_cputime(nsecs_to_jiffies(__nsec))
  21. /*
  22. * Convert cputime to microseconds and back.
  23. */
  24. #define cputime_to_usecs(__ct) \
  25. jiffies_to_usecs(cputime_to_jiffies(__ct))
  26. #define usecs_to_cputime(__usec) \
  27. jiffies_to_cputime(usecs_to_jiffies(__usec))
  28. #define usecs_to_cputime64(__usec) \
  29. jiffies64_to_cputime64(nsecs_to_jiffies64((__usec) * 1000))
  30. /*
  31. * Convert cputime to seconds and back.
  32. */
  33. #define cputime_to_secs(jif) (cputime_to_jiffies(jif) / HZ)
  34. #define secs_to_cputime(sec) jiffies_to_cputime((sec) * HZ)
  35. /*
  36. * Convert cputime to timespec and back.
  37. */
  38. #define timespec_to_cputime(__val) \
  39. jiffies_to_cputime(timespec_to_jiffies(__val))
  40. #define cputime_to_timespec(__ct,__val) \
  41. jiffies_to_timespec(cputime_to_jiffies(__ct),__val)
  42. /*
  43. * Convert cputime to timeval and back.
  44. */
  45. #define timeval_to_cputime(__val) \
  46. jiffies_to_cputime(timeval_to_jiffies(__val))
  47. #define cputime_to_timeval(__ct,__val) \
  48. jiffies_to_timeval(cputime_to_jiffies(__ct),__val)
  49. /*
  50. * Convert cputime to clock and back.
  51. */
  52. #define cputime_to_clock_t(__ct) \
  53. jiffies_to_clock_t(cputime_to_jiffies(__ct))
  54. #define clock_t_to_cputime(__x) \
  55. jiffies_to_cputime(clock_t_to_jiffies(__x))
  56. /*
  57. * Convert cputime64 to clock.
  58. */
  59. #define cputime64_to_clock_t(__ct) \
  60. jiffies_64_to_clock_t(cputime64_to_jiffies64(__ct))
  61. #endif