Changeset 102234 in vbox for trunk/src/libs/xpcom18a4/nsprpub
- Timestamp:
- Nov 22, 2023 9:57:32 AM (14 months ago)
- 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 117 117 extern void _PR_ImplicitInitialization(void); 118 118 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_INTERVAL127 128 extern PRIntervalTime _PR_MD_INTERVAL_PER_SEC(void);129 #define _PR_MD_INTERVAL_PER_SEC _MD_INTERVAL_PER_SEC130 131 119 PR_END_EXTERN_C 132 120 -
trunk/src/libs/xpcom18a4/nsprpub/pr/src/misc/prinrval.c
r102233 r102234 43 43 #include "primpl.h" 44 44 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> 46 50 47 51 /* … … 54 58 PR_IMPLEMENT(PRIntervalTime) PR_IntervalNow(void) 55 59 { 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 58 86 } /* PR_IntervalNow */ 59 87 60 88 PR_EXTERN(PRUint32) PR_TicksPerSecond(void) 61 89 { 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 64 99 } /* PR_TicksPerSecond */ 65 100
Note:
See TracChangeset
for help on using the changeset viewer.