From: VMware, Inc <> Date: Thu, 17 Jun 2010 21:40:35 +0000 (-0700) Subject: lib/misc: more review comments X-Git-Tag: 2010.06.16-268169~90 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0067d84464df5c50bda71f55823c803c19fceba7;p=thirdparty%2Fopen-vm-tools.git lib/misc: more review comments Picking up even more review comments... Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/misc/hostinfo.c b/open-vm-tools/lib/misc/hostinfo.c index dad0df750..65d035bd0 100644 --- a/open-vm-tools/lib/misc/hostinfo.c +++ b/open-vm-tools/lib/misc/hostinfo.c @@ -546,3 +546,52 @@ Hostinfo_TouchXen(void) return FALSE; } + + +/* + *----------------------------------------------------------------------------- + * + * Hostinfo_RawSystemTimerUS -- + * + * Return the raw time. + * - Do this as fast as is practical; no locks are used + * - These timers may go backwards or make no forward progress + * + * Hostinfo_SystemTimerUS -- + * + * Return the time. + * - These timers are documented to never go backwards. + * - These timers may take locks + * + * NOTES: + * These are the routines to use when performing timing measurements. + * + * The value returned is valid (finish-time - start-time) only within a + * single process. Don't send a time measurement obtained with these + * routines to another process and expect a relative time measurement + * to be correct. + * + * The actual resolution of these "clocks" are undefined - it varies + * depending on hardware, OSen and OS versions. + * + * Results: + * The time in microseconds is returned. Zero upon error. + * + * Side effects: + * None. + * + *----------------------------------------------------------------------------- + */ + +VmTimeType +Hostinfo_RawSystemTimerUS(void) +{ + return Hostinfo_RawSystemTimerNS() / 1000; +} + + +VmTimeType +Hostinfo_SystemTimerUS(void) +{ + return Hostinfo_SystemTimerNS() / 1000; +} diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index 4120cfc35..f7fe8a252 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -1463,14 +1463,12 @@ Hostinfo_LogLoadAverage(void) *----------------------------------------------------------------------------- * * Hostinfo_RawSystemTimerNS -- - * Hostinfo_RawSystemTimerUS -- * * Return the raw time. * - Do this as fast as is practical; no locks are used * - These timers may go backwards or make no forward progress * * Hostinfo_SystemTimerNS -- - * Hostinfo_SystemTimerUS -- * * Return the time. * - These timers are documented to never go backwards. @@ -1488,7 +1486,7 @@ Hostinfo_LogLoadAverage(void) * depending on hardware, OSen and OS versions. * * Results: - * The time in nanoseconds or microseconds is returned. Zero upon error. + * The time in nanoseconds is returned. Zero upon error. * * Side effects: * None. @@ -1543,13 +1541,6 @@ Hostinfo_SystemTimerNS(void) { return Hostinfo_RawSystemTimerNS(); } - - -VmTimeType -Hostinfo_SystemTimerUS(void) -{ - return Hostinfo_RawSystemTimerNS() / 1000ULL; -} #elif defined(VMX86_SERVER) VmTimeType Hostinfo_RawSystemTimerNS(void) @@ -1578,13 +1569,6 @@ Hostinfo_SystemTimerNS(void) { return Hostinfo_RawSystemTimerNS(); } - - -VmTimeType -Hostinfo_SystemTimerUS(void) -{ - return Hostinfo_RawSystemTimerNS() / 1000; -} #else VmTimeType Hostinfo_RawSystemTimerNS(void) @@ -1620,9 +1604,12 @@ Hostinfo_SystemTimerNS(void) /* * TODO: research using -lrt and clock_gettime. + * + * These routines live in lib/misc and cannot use routines from other + * libraries, including lib/lock. */ - pthread_mutex_lock(&mutex); // use native mechanism, just like Windows + pthread_mutex_lock(&mutex); // Use native mechanism, just like Windows curTime = Hostinfo_RawSystemTimerNS(); @@ -1651,22 +1638,9 @@ exit: return newTime; } - - -VmTimeType -Hostinfo_SystemTimerUS(void) -{ - return Hostinfo_SystemTimerNS() / 1000; -} #endif -VmTimeType -Hostinfo_RawSystemTimerUS(void) -{ - return Hostinfo_RawSystemTimerNS() / 1000ULL; -} - /* *----------------------------------------------------------------------------- *