VirtualBox

Ignore:
Timestamp:
Nov 22, 2023 9:57:32 AM (14 months ago)
Author:
vboxsync
Message:

libs/xpcom: Move machine dependent (MD) code for the interval API into the generic layer, bugref:10545

Location:
trunk/src/libs/xpcom18a4/nsprpub/pr
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/primpl.h

    r102233 r102234  
    117117extern void _PR_ImplicitInitialization(void);
    118118
    119 /*************************************************************************
    120 * External machine-dependent code provided by each OS.                     *                                                                     *
    121 *************************************************************************/
    122 
    123 /* Time intervals */
    124 
    125 extern PRIntervalTime _PR_MD_GET_INTERVAL(void);
    126 #define _PR_MD_GET_INTERVAL _MD_GET_INTERVAL
    127 
    128 extern PRIntervalTime _PR_MD_INTERVAL_PER_SEC(void);
    129 #define _PR_MD_INTERVAL_PER_SEC _MD_INTERVAL_PER_SEC
    130 
    131119PR_END_EXTERN_C
    132120
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinrval.c

    r102233 r102234  
    4343#include "primpl.h"
    4444
    45 #include <iprt/assert.h>
     45#include <signal.h>
     46#include <unistd.h>
     47#include <sys/types.h>
     48#include <sys/time.h>
     49#include <sys/utsname.h>
    4650
    4751/*
     
    5458PR_IMPLEMENT(PRIntervalTime) PR_IntervalNow(void)
    5559{
    56     if (!_pr_initialized) _PR_ImplicitInitialization();
    57     return _PR_MD_GET_INTERVAL();
     60#if defined(SOLARIS)
     61    union {
     62        hrtime_t hrt;  /* hrtime_t is a 64-bit (long long) integer */
     63        PRInt64 pr64;
     64    } time;
     65    PRInt64 resolution;
     66    PRIntervalTime ticks;
     67
     68    time.hrt = gethrtime();  /* in nanoseconds */
     69    /*
     70     * Convert from nanoseconds to ticks.  A tick's resolution is
     71     * 10 microseconds, or 10000 nanoseconds.
     72     */
     73    LL_I2L(resolution, 10000);
     74    LL_DIV(time.pr64, time.pr64, resolution);
     75    LL_L2UI(ticks, time.pr64);
     76    return ticks;
     77#else
     78    struct timeval time;
     79    PRIntervalTime ticks;
     80
     81    (void)GETTIMEOFDAY(&time);  /* fallicy of course */
     82    ticks = (PRUint32)time.tv_sec * PR_MSEC_PER_SEC;  /* that's in milliseconds */
     83    ticks += (PRUint32)time.tv_usec / PR_USEC_PER_MSEC;  /* so's that */
     84    return ticks;
     85#endif
    5886}  /* PR_IntervalNow */
    5987
    6088PR_EXTERN(PRUint32) PR_TicksPerSecond(void)
    6189{
    62     if (!_pr_initialized) _PR_ImplicitInitialization();
    63     return _PR_MD_INTERVAL_PER_SEC();
     90#if defined(SOLARIS)
     91    /*
     92     * Ticks have a 10-microsecond resolution.  So there are
     93     * 100000 ticks per second.
     94     */
     95    return 100000UL;
     96#else
     97    return 1000;  /* this needs some work :) */
     98#endif
    6499}  /* PR_TicksPerSecond */
    65100
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