VirtualBox

Changeset 52822 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 23, 2014 10:25:34 AM (10 years ago)
Author:
vboxsync
Message:

Runtime: Fix RTTimeMilliTS() on FreeBSD. Use macros for time units rather than hardcoded values.

Location:
trunk/src/VBox/Runtime
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/darwin/time-r0drv-darwin.cpp

    r48935 r52822  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    6868RTDECL(uint64_t) RTTimeMilliTS(void)
    6969{
    70     return rtTimeGetSystemNanoTS() / 1000000;
     70    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    7171}
    7272
     
    8080RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    8181{
    82     return rtTimeGetSystemNanoTS() / 1000000;
     82    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    8383}
    8484
     
    9494#endif
    9595    clock_get_calendar_nanotime(&uSecs, &uNanosecs);
    96     return RTTimeSpecSetNano(pTime, (uint64_t)uSecs * 1000000000 + uNanosecs);
     96    return RTTimeSpecSetNano(pTime, (uint64_t)uSecs * RT_NS_1SEC + uNanosecs);
    9797}
    9898
  • trunk/src/VBox/Runtime/r0drv/freebsd/time-r0drv-freebsd.c

    r18972 r52822  
    4343    struct timespec tsp;
    4444    nanouptime(&tsp);
    45     return tsp.tv_sec * UINT64_C(1000000000)
     45    return tsp.tv_sec * RT_NS_1SEC_64
    4646         + tsp.tv_nsec;
    4747}
     
    5050RTDECL(uint64_t) RTTimeMilliTS(void)
    5151{
    52     return RTTimeNanoTS() / 1000;
     52    return RTTimeNanoTS() / RT_NS_1MS;
    5353}
    5454
     
    7272    return RTTimeSpecSetTimespec(pTime, &tsp);
    7373}
     74
  • trunk/src/VBox/Runtime/r0drv/haiku/time-r0drv-haiku.c

    r43403 r52822  
    55
    66/*
    7  * Copyright (C) 2012 Oracle Corporation
     7 * Copyright (C) 2012-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3939DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void)
    4040{
    41     return system_time() * 1000;
     41    return system_time() * RT_NS_1US;
    4242}
    4343
     
    4545DECLINLINE(uint64_t) rtTimeGetSystemMilliTS(void)
    4646{
    47     return system_time() / 1000;
     47    return system_time() / RT_NS_1US;
    4848}
    4949
     
    7575RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
    7676{
    77     return RTTimeSpecSetNano(pTime, real_time_clock_usecs() * 1000);
     77    return RTTimeSpecSetNano(pTime, real_time_clock_usecs() * RT_NS_1US);
    7878}
    7979
  • trunk/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c

    r44528 r52822  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4646    struct timespec Ts;
    4747    ktime_get_ts(&Ts);
    48     u64 = Ts.tv_sec * UINT64_C(1000000000) + Ts.tv_nsec;
     48    u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec;
    4949    return u64;
    5050
     
    149149RTDECL(uint64_t) RTTimeMilliTS(void)
    150150{
    151     return rtTimeGetSystemNanoTS() / 1000000;
     151    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    152152}
    153153RT_EXPORT_SYMBOL(RTTimeMilliTS);
     
    163163RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    164164{
    165     return rtTimeGetSystemNanoTS() / 1000000;
     165    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    166166}
    167167RT_EXPORT_SYMBOL(RTTimeSystemMilliTS);
  • trunk/src/VBox/Runtime/r0drv/nt/time-r0drv-nt.cpp

    r48935 r52822  
    55
    66/*
    7  * Copyright (C) 2007-2010 Oracle Corporation
     7 * Copyright (C) 2007-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8080RTDECL(uint64_t) RTTimeMilliTS(void)
    8181{
    82     return rtTimeGetSystemNanoTS() / 1000000;
     82    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    8383}
    8484
     
    9292RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    9393{
    94     return rtTimeGetSystemNanoTS() / 1000000;
     94    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    9595}
    9696
  • trunk/src/VBox/Runtime/r0drv/solaris/time-r0drv-solaris.c

    r44528 r52822  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4343RTDECL(uint64_t) RTTimeMilliTS(void)
    4444{
    45     return RTTimeNanoTS() / 1000000;
     45    return RTTimeNanoTS() / RT_NS_1MS;
    4646}
    4747
     
    5555RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    5656{
    57     return RTTimeNanoTS() / 1000000;
     57    return RTTimeNanoTS() / RT_NS_1MS;
    5858}
    5959
     
    6666    TimeSpec = tod_get();
    6767    mutex_exit(&tod_lock);
    68     return RTTimeSpecSetNano(pTime, (uint64_t)TimeSpec.tv_sec * 1000000000 + TimeSpec.tv_nsec);
     68    return RTTimeSpecSetNano(pTime, (uint64_t)TimeSpec.tv_sec * RT_NS_1SEC + TimeSpec.tv_nsec);
    6969}
    7070
  • trunk/src/VBox/Runtime/r0drv/solaris/timer-r0drv-solaris.c

    r48186 r52822  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
  • trunk/src/VBox/Runtime/r3/darwin/time-darwin.cpp

    r48935 r52822  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8989    struct timeval tv;
    9090    gettimeofday(&tv, NULL);
    91     return (uint64_t)tv.tv_sec  * (uint64_t)(1000 * 1000 * 1000)
    92          + (uint64_t)(tv.tv_usec * 1000);
     91    return (uint64_t)tv.tv_sec  * RT_NS_1SEC_64
     92         + (uint64_t)(tv.tv_usec * RT_NS_1US);
    9393}
    9494
     
    102102RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    103103{
    104     return rtTimeGetSystemNanoTS() / 1000000;
     104    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    105105}
    106106
  • trunk/src/VBox/Runtime/r3/haiku/time-haiku.cpp

    r45356 r52822  
    55
    66/*
    7  * Copyright (C) 2012-2013 Oracle Corporation
     7 * Copyright (C) 2012-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4444DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void)
    4545{
    46     return (uint64_t)system_time() * 1000;
     46    return (uint64_t)system_time() * RT_NS_1US;
    4747}
    4848
     
    7272RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    7373{
    74     return rtTimeGetSystemNanoTS() / 1000000;
     74    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    7575}
    7676
     
    8383    return VINF_SUCCESS;
    8484}
     85
  • trunk/src/VBox/Runtime/r3/linux/time-linux.cpp

    r48935 r52822  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    119119        struct timespec ts;
    120120        if (!mono_clock(&ts))
    121             return (uint64_t)ts.tv_sec * (uint64_t)(1000 * 1000 * 1000)
     121            return (uint64_t)ts.tv_sec * RT_NS_1SEC_64
    122122                 + ts.tv_nsec;
    123123        fMonoClock = false;
     
    127127    struct timeval tv;
    128128    gettimeofday(&tv, NULL);
    129     return (uint64_t)tv.tv_sec  * (uint64_t)(1000 * 1000 * 1000)
    130          + (uint64_t)(tv.tv_usec * 1000);
     129    return (uint64_t)tv.tv_sec  * RT_NS_1SEC_64
     130         + (uint64_t)(tv.tv_usec * RT_NS_1US);
    131131}
    132132
     
    156156RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    157157{
    158     return rtTimeGetSystemNanoTS() / 1000000;
     158    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    159159}
    160160
  • trunk/src/VBox/Runtime/r3/posix/time-posix.cpp

    r48935 r52822  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    4747        struct timespec ts;
    4848        if (!clock_gettime(CLOCK_MONOTONIC, &ts))
    49             return (uint64_t)ts.tv_sec * (uint64_t)(1000 * 1000 * 1000)
     49            return (uint64_t)ts.tv_sec * RT_NS_1SEC_64
    5050                 + ts.tv_nsec;
    5151        s_fMonoClock = false;
     
    5656    struct timeval tv;
    5757    gettimeofday(&tv, NULL);
    58     return (uint64_t)tv.tv_sec  * (uint64_t)(1000 * 1000 * 1000)
    59          + (uint64_t)(tv.tv_usec * 1000);
     58    return (uint64_t)tv.tv_sec  * RT_NS_1SEC_64
     59         + (uint64_t)(tv.tv_usec * RT_NS_1US);
    6060}
    6161
     
    8585RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    8686{
    87     return rtTimeGetSystemNanoTS() / 1000000;
     87    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    8888}
    8989
  • trunk/src/VBox/Runtime/r3/win/time-win.cpp

    r48935 r52822  
    55
    66/*
    7  * Copyright (C) 2006-2010 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    7979     * This would work if it didn't flip over every 49 (or so) days.
    8080     */
    81     return (uint64_t)GetTickCount() * (uint64_t)1000000;
     81    return (uint64_t)GetTickCount() * RT_NS_1MS_64;
    8282
    8383#elif defined USE_PERFORMANCE_COUNTER
     
    9090    {
    9191        if (!QueryPerformanceFrequency(&llFreq))
    92             return (uint64_t)GetTickCount() * (uint64_t)1000000;
     92            return (uint64_t)GetTickCount() * RT_NS_1MS_64;
    9393        llFreq.QuadPart /=    1000;
    9494        uMult            = 1000000;     /* no math genius, but this seemed to help avoiding floating point. */
     
    9898    if (QueryPerformanceCounter(&ll))
    9999        return (ll.QuadPart * uMult) / llFreq.QuadPart;
    100     return (uint64_t)GetTickCount() * (uint64_t)1000000;
     100    return (uint64_t)GetTickCount() * RT_NS_1MS_64;
    101101
    102102#elif defined USE_FILE_TIME
     
    149149RTDECL(uint64_t) RTTimeSystemMilliTS(void)
    150150{
    151     return rtTimeGetSystemNanoTS() / 1000000;
     151    return rtTimeGetSystemNanoTS() / RT_NS_1MS;
    152152}
    153153
     
    196196    Tzi.Bias = 0;
    197197    if (GetTimeZoneInformation(&Tzi) != TIME_ZONE_ID_INVALID)
    198         return -(int64_t)Tzi.Bias * 60*1000*1000*1000;
     198        return -(int64_t)Tzi.Bias * 60 * RT_NS_1MS_64;
    199199    return 0;
    200200}
Note: See TracChangeset for help on using the changeset viewer.

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