VirtualBox

Ignore:
Timestamp:
Nov 30, 2023 8:12:27 AM (18 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
160526
Message:

libs/xpcom: Convert the PR_Waitfunction to take the timeout in milliseconds and get rid of PR_Interval* and use RTTime*, bugref:10545

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

Legend:

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

    r102346 r102390  
    4545#include "prbit.h"
    4646#include "prclist.h"
    47 #include "prinrval.h"
    4847#include "prlong.h"
    4948#include "prmem.h"
  • trunk/src/libs/xpcom18a4/nsprpub/pr/include/prbit.h

    r102245 r102390  
    4646
    4747/*
    48 ** A prbitmap_t is a long integer that can be used for bitmaps
    49 */
    50 typedef unsigned long prbitmap_t;
    51 
    52 #define PR_TEST_BIT(_map,_bit) \
    53     ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] & (1L << ((_bit) & (PR_BITS_PER_LONG-1))))
    54 #define PR_SET_BIT(_map,_bit) \
    55     ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] |= (1L << ((_bit) & (PR_BITS_PER_LONG-1))))
    56 #define PR_CLEAR_BIT(_map,_bit) \
    57     ((_map)[(_bit)>>PR_BITS_PER_LONG_LOG2] &= ~(1L << ((_bit) & (PR_BITS_PER_LONG-1))))
    58 
    59 /*
    6048** Compute the log of the least power of 2 greater than or equal to n
    6149*/
     
    10088}
    10189
    102 /*
    103 ** Macro version of PR_CeilingLog2: Compute the log of the least power of
    104 ** 2 greater than or equal to _n. The result is returned in _log2.
    105 */
    106 #define PR_CEILING_LOG2(_log2,_n)   \
    107   PR_BEGIN_MACRO                    \
    108     PRUint32 j_ = (PRUint32)(_n);       \
    109     (_log2) = 0;                    \
    110     if ((j_) & ((j_)-1))            \
    111         (_log2) += 1;               \
    112     if ((j_) >> 16)                 \
    113         (_log2) += 16, (j_) >>= 16; \
    114     if ((j_) >> 8)                  \
    115         (_log2) += 8, (j_) >>= 8;   \
    116     if ((j_) >> 4)                  \
    117         (_log2) += 4, (j_) >>= 4;   \
    118     if ((j_) >> 2)                  \
    119         (_log2) += 2, (j_) >>= 2;   \
    120     if ((j_) >> 1)                  \
    121         (_log2) += 1;               \
    122   PR_END_MACRO
     90PR_END_EXTERN_C
    12391
    124 /*
    125 ** Macro version of PR_FloorLog2: Compute the log of the greatest power of
    126 ** 2 less than or equal to _n. The result is returned in _log2.
    127 **
    128 ** This is equivalent to finding the highest set bit in the word.
    129 */
    130 #define PR_FLOOR_LOG2(_log2,_n)   \
    131   PR_BEGIN_MACRO                    \
    132     PRUint32 j_ = (PRUint32)(_n);       \
    133     (_log2) = 0;                    \
    134     if ((j_) >> 16)                 \
    135         (_log2) += 16, (j_) >>= 16; \
    136     if ((j_) >> 8)                  \
    137         (_log2) += 8, (j_) >>= 8;   \
    138     if ((j_) >> 4)                  \
    139         (_log2) += 4, (j_) >>= 4;   \
    140     if ((j_) >> 2)                  \
    141         (_log2) += 2, (j_) >>= 2;   \
    142     if ((j_) >> 1)                  \
    143         (_log2) += 1;               \
    144   PR_END_MACRO
    145 
    146 PR_END_EXTERN_C
    14792#endif /* prbit_h___ */
  • trunk/src/libs/xpcom18a4/nsprpub/pr/include/prmon.h

    r102216 r102390  
    4040
    4141#include "prtypes.h"
    42 #include "prinrval.h"
     42
     43#include <iprt/types.h>
    4344
    4445#ifdef VBOX_WITH_XPCOM_NAMESPACE_CLEANUP
     
    105106** Returns PR_FAILURE if the caller has not entered the monitor.
    106107*/
    107 NSPR_API(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime ticks);
     108NSPR_API(PRStatus) PR_Wait(PRMonitor *mon, RTMSINTERVAL msWait);
    108109
    109110/*
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c

    r102243 r102390  
    285285
    286286static PRIntn pt_TimedWait(
    287     pthread_cond_t *cv, pthread_mutex_t *ml, PRIntervalTime timeout)
     287    pthread_cond_t *cv, pthread_mutex_t *ml, RTMSINTERVAL msTimeout)
    288288{
    289289    int rv;
    290290    struct timeval now;
    291291    struct timespec tmo;
    292     PRUint32 ticks = PR_TicksPerSecond();
    293 
    294     tmo.tv_sec = (PRInt32)(timeout / ticks);
    295     tmo.tv_nsec = (PRInt32)(timeout - (tmo.tv_sec * ticks));
    296     tmo.tv_nsec = (PRInt32)PR_IntervalToMicroseconds(PT_NANOPERMICRO * tmo.tv_nsec);
     292
     293    tmo.tv_sec = (PRInt32)(msTimeout / RT_MS_1SEC);
     294    tmo.tv_nsec = (PRInt32)((msTimeout - (tmo.tv_sec * RT_MS_1SEC)) * RT_NS_1MS);
    297295
    298296    /* pthreads wants this in absolute time, off we go ... */
     
    367365}  /* PR_DestroyCondVar */
    368366
    369 PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout)
     367PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PRCondVar *cvar, RTMSINTERVAL msTimeout)
    370368{
    371369    PRIntn rv;
     
    394392    cvar->lock->locked = PR_FALSE;
    395393
    396     if (timeout == PR_INTERVAL_NO_TIMEOUT)
     394    if (msTimeout == RT_INDEFINITE_WAIT)
    397395        rv = pthread_cond_wait(&cvar->cv, &cvar->lock->mutex);
    398396    else
    399         rv = pt_TimedWait(&cvar->cv, &cvar->lock->mutex, timeout);
     397        rv = pt_TimedWait(&cvar->cv, &cvar->lock->mutex, msTimeout);
    400398
    401399    /* We just got the lock back - this better be empty */
     
    545543}  /* PR_ExitMonitor */
    546544
    547 PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor *mon, PRIntervalTime timeout)
     545PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor *mon, RTMSINTERVAL msTimeout)
    548546{
    549547    PRStatus rv;
     
    565563    _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner);
    566564   
    567     rv = PR_WaitCondVar(mon->cvar, timeout);
     565    rv = PR_WaitCondVar(mon->cvar, msTimeout);
    568566
    569567    /* reinstate the intresting information */
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