VirtualBox

Ticket #19312: timet.patch

File timet.patch, 5.5 KB (added by s.zharkoff, 5 years ago)

The patch is working for 5.6-rc3+, but will break older versions :(

  • vboxdrv/include/iprt/time.h

    diff -Naur a/vboxdrv/include/iprt/time.h b/vboxdrv/include/iprt/time.h
    a b  
    366366 * @param   pTime       The time spec to interpret.
    367367 * @param   pTimeval    Where to store the time as POSIX timeval.
    368368 */
     369#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
    369370DECLINLINE(struct timeval *) RTTimeSpecGetTimeval(PCRTTIMESPEC pTime, struct timeval *pTimeval)
    370371{
    371372    int64_t i64 = RTTimeSpecGetMicro(pTime);
     
    392393{
    393394    return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
    394395}
     396#endif
    395397#endif /* various ways of detecting struct timeval */
    396398
    397399
    398400/* PORTME: Add struct timespec guard macro here. */
    399401#if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
    400402 || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
     403#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
    401404/**
    402405 * Gets the time as POSIX timespec.
    403406 *
     
    431434{
    432435    return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
    433436}
     437#endif
    434438
    435439
     440#endif /* various ways of detecting struct timespec */
     441
    436442# ifdef _LINUX_TIME64_H
    437443DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
    438444{
    439445    return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
    440446}
    441 # endif
    442 #endif /* various ways of detecting struct timespec */
    443 
     447#endif
    444448
    445449
    446450/** The offset of the unix epoch and the base for NT time (in 100ns units).
  • vboxdrv/r0drv/linux/time-r0drv-linux.c

    diff -Naur a/vboxdrv/r0drv/linux/time-r0drv-linux.c b/vboxdrv/r0drv/linux/time-r0drv-linux.c
    a b  
    4343     * Use ktime_get_ts, this is also what clock_gettime(CLOCK_MONOTONIC,) is using.
    4444     */
    4545    uint64_t u64;
    46     struct timespec Ts;
    47     ktime_get_ts(&Ts);
     46    struct timespec64 Ts;
     47    ktime_get_ts64(&Ts);
    4848    u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec;
    4949    return u64;
    5050
  • vboxnetadp/include/iprt/time.h

    diff -Naur a/vboxnetadp/include/iprt/time.h b/vboxnetadp/include/iprt/time.h
    a b  
    366366 * @param   pTime       The time spec to interpret.
    367367 * @param   pTimeval    Where to store the time as POSIX timeval.
    368368 */
     369#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
    369370DECLINLINE(struct timeval *) RTTimeSpecGetTimeval(PCRTTIMESPEC pTime, struct timeval *pTimeval)
    370371{
    371372    int64_t i64 = RTTimeSpecGetMicro(pTime);
     
    392393{
    393394    return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
    394395}
     396#endif
    395397#endif /* various ways of detecting struct timeval */
    396398
    397399
    398400/* PORTME: Add struct timespec guard macro here. */
    399401#if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
    400402 || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
     403#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
    401404/**
    402405 * Gets the time as POSIX timespec.
    403406 *
     
    431434{
    432435    return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
    433436}
     437#endif
    434438
    435439
     440#endif /* various ways of detecting struct timespec */
     441
    436442# ifdef _LINUX_TIME64_H
    437443DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
    438444{
    439445    return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
    440446}
    441 # endif
    442 #endif /* various ways of detecting struct timespec */
    443 
     447#endif
    444448
    445449
    446450/** The offset of the unix epoch and the base for NT time (in 100ns units).
  • vboxnetflt/include/iprt/time.h

    diff -Naur a/vboxnetflt/include/iprt/time.h b/vboxnetflt/include/iprt/time.h
    a b  
    366366 * @param   pTime       The time spec to interpret.
    367367 * @param   pTimeval    Where to store the time as POSIX timeval.
    368368 */
     369#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
    369370DECLINLINE(struct timeval *) RTTimeSpecGetTimeval(PCRTTIMESPEC pTime, struct timeval *pTimeval)
    370371{
    371372    int64_t i64 = RTTimeSpecGetMicro(pTime);
     
    392393{
    393394    return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
    394395}
     396#endif
    395397#endif /* various ways of detecting struct timeval */
    396398
    397399
    398400/* PORTME: Add struct timespec guard macro here. */
    399401#if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
    400402 || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
     403#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 5, 99)
    401404/**
    402405 * Gets the time as POSIX timespec.
    403406 *
     
    431434{
    432435    return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
    433436}
     437#endif
    434438
    435439
     440#endif /* various ways of detecting struct timespec */
     441
    436442# ifdef _LINUX_TIME64_H
    437443DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
    438444{
    439445    return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
    440446}
    441 # endif
    442 #endif /* various ways of detecting struct timespec */
    443 
     447#endif
    444448
    445449
    446450/** The offset of the unix epoch and the base for NT time (in 100ns units).

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy