timet.patch 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. diff -Naur a/vboxdrv/include/iprt/time.h b/vboxdrv/include/iprt/time.h
  2. --- a/vboxdrv/include/iprt/time.h 2020-02-27 08:29:15.598443630 +0300
  3. +++ b/vboxdrv/include/iprt/time.h 2020-02-27 09:11:28.528393987 +0300
  4. @@ -366,6 +366,7 @@
  5. * @param pTime The time spec to interpret.
  6. * @param pTimeval Where to store the time as POSIX timeval.
  7. */
  8. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
  9. DECLINLINE(struct timeval *) RTTimeSpecGetTimeval(PCRTTIMESPEC pTime, struct timeval *pTimeval)
  10. {
  11. int64_t i64 = RTTimeSpecGetMicro(pTime);
  12. @@ -392,12 +393,14 @@
  13. {
  14. return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
  15. }
  16. +#endif
  17. #endif /* various ways of detecting struct timeval */
  18. /* PORTME: Add struct timespec guard macro here. */
  19. #if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
  20. || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
  21. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
  22. /**
  23. * Gets the time as POSIX timespec.
  24. *
  25. @@ -431,16 +434,17 @@
  26. {
  27. return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
  28. }
  29. +#endif
  30. +#endif /* various ways of detecting struct timespec */
  31. +
  32. # ifdef _LINUX_TIME64_H
  33. DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
  34. {
  35. return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
  36. }
  37. -# endif
  38. -#endif /* various ways of detecting struct timespec */
  39. -
  40. +#endif
  41. /** The offset of the unix epoch and the base for NT time (in 100ns units).
  42. diff -Naur a/vboxdrv/r0drv/linux/time-r0drv-linux.c b/vboxdrv/r0drv/linux/time-r0drv-linux.c
  43. --- a/vboxdrv/r0drv/linux/time-r0drv-linux.c 2020-02-27 08:29:15.608443629 +0300
  44. +++ b/vboxdrv/r0drv/linux/time-r0drv-linux.c 2020-02-27 09:00:17.518407138 +0300
  45. @@ -43,8 +43,8 @@
  46. * Use ktime_get_ts, this is also what clock_gettime(CLOCK_MONOTONIC,) is using.
  47. */
  48. uint64_t u64;
  49. - struct timespec Ts;
  50. - ktime_get_ts(&Ts);
  51. + struct timespec64 Ts;
  52. + ktime_get_ts64(&Ts);
  53. u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec;
  54. return u64;
  55. diff -Naur a/vboxnetadp/include/iprt/time.h b/vboxnetadp/include/iprt/time.h
  56. --- a/vboxnetadp/include/iprt/time.h 2020-02-27 08:29:15.598443630 +0300
  57. +++ b/vboxnetadp/include/iprt/time.h 2020-02-27 09:11:28.528393987 +0300
  58. @@ -366,6 +366,7 @@
  59. * @param pTime The time spec to interpret.
  60. * @param pTimeval Where to store the time as POSIX timeval.
  61. */
  62. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
  63. DECLINLINE(struct timeval *) RTTimeSpecGetTimeval(PCRTTIMESPEC pTime, struct timeval *pTimeval)
  64. {
  65. int64_t i64 = RTTimeSpecGetMicro(pTime);
  66. @@ -392,12 +393,14 @@
  67. {
  68. return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
  69. }
  70. +#endif
  71. #endif /* various ways of detecting struct timeval */
  72. /* PORTME: Add struct timespec guard macro here. */
  73. #if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
  74. || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
  75. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
  76. /**
  77. * Gets the time as POSIX timespec.
  78. *
  79. @@ -431,16 +434,17 @@
  80. {
  81. return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
  82. }
  83. +#endif
  84. +#endif /* various ways of detecting struct timespec */
  85. +
  86. # ifdef _LINUX_TIME64_H
  87. DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
  88. {
  89. return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
  90. }
  91. -# endif
  92. -#endif /* various ways of detecting struct timespec */
  93. -
  94. +#endif
  95. /** The offset of the unix epoch and the base for NT time (in 100ns units).
  96. diff -Naur a/vboxnetflt/include/iprt/time.h b/vboxnetflt/include/iprt/time.h
  97. --- a/vboxnetflt/include/iprt/time.h 2020-02-27 08:29:15.588443630 +0300
  98. +++ b/vboxnetflt/include/iprt/time.h 2020-02-27 09:11:28.528393987 +0300
  99. @@ -366,6 +366,7 @@
  100. * @param pTime The time spec to interpret.
  101. * @param pTimeval Where to store the time as POSIX timeval.
  102. */
  103. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
  104. DECLINLINE(struct timeval *) RTTimeSpecGetTimeval(PCRTTIMESPEC pTime, struct timeval *pTimeval)
  105. {
  106. int64_t i64 = RTTimeSpecGetMicro(pTime);
  107. @@ -392,12 +393,14 @@
  108. {
  109. return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
  110. }
  111. +#endif
  112. #endif /* various ways of detecting struct timeval */
  113. /* PORTME: Add struct timespec guard macro here. */
  114. #if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
  115. || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
  116. +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
  117. /**
  118. * Gets the time as POSIX timespec.
  119. *
  120. @@ -431,16 +434,17 @@
  121. {
  122. return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
  123. }
  124. +#endif
  125. +#endif /* various ways of detecting struct timespec */
  126. +
  127. # ifdef _LINUX_TIME64_H
  128. DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
  129. {
  130. return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
  131. }
  132. -# endif
  133. -#endif /* various ways of detecting struct timespec */
  134. -
  135. +#endif
  136. /** The offset of the unix epoch and the base for NT time (in 100ns units).