VirtualBox

Changeset 85208 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jul 10, 2020 11:58:39 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139184
Message:

iprt/time-r0drv-linux.c: Cleaned up RTTimeNow a little, we try use the linux kernel version rather than header blockers for deciding how to do stuff. Define RTTIME_INCL_TIMEVAL/SPEC when we need these helper just in case we get something wrong in iprt/time.h again. bugref:9757

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c

    r83484 r85208  
    3232#include "the-linux-kernel.h"
    3333#include "internal/iprt.h"
     34/* Make sure we have the setting functions we need for RTTimeNow: */
     35#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
     36# define RTTIME_INCL_TIMEVAL
     37#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
     38# define RTTIME_INCL_TIMESPEC
     39#endif
    3440#include <iprt/time.h>
    3541#include <iprt/asm.h>
     
    183189{
    184190    IPRT_LINUX_SAVE_EFL_AC();
    185 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
    186 /* On Linux 4.20, time.h includes time64.h and we have to use 64-bit times. */
    187 # ifdef _LINUX_TIME64_H
     191#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)
    188192    struct timespec64 Ts;
    189     ktime_get_real_ts64(&Ts);
    190 # else
     193    ktime_get_real_ts64(&Ts);   /* ktime_get_real_ts64 was added as a macro in 3.17, function since 4.18. */
     194    IPRT_LINUX_RESTORE_EFL_AC();
     195    return RTTimeSpecSetTimespec64(pTime, &Ts);
     196
     197#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
    191198    struct timespec Ts;
    192     ktime_get_real_ts(&Ts);
    193 # endif
     199    ktime_get_real_ts(&Ts);     /* ktime_get_real_ts was removed in Linux 4.20. */
    194200    IPRT_LINUX_RESTORE_EFL_AC();
    195 # ifdef _LINUX_TIME64_H
    196     return RTTimeSpecSetTimespec64(pTime, &Ts);
    197 # else
    198201    return RTTimeSpecSetTimespec(pTime, &Ts);
    199 # endif
    200 #else   /* < 2.6.16 */
     202
     203#else /* < 2.6.16 */
    201204    struct timeval Tv;
    202205    do_gettimeofday(&Tv);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette