]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/misc: more review comments
authorVMware, Inc <>
Thu, 17 Jun 2010 21:40:35 +0000 (14:40 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 17 Jun 2010 21:40:35 +0000 (14:40 -0700)
Picking up even more review comments...

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/misc/hostinfo.c
open-vm-tools/lib/misc/hostinfoPosix.c

index dad0df750f19ec3a6d7ed9509a0133f61cbf2ec2..65d035bd00e372095415f5799bac55eb2934e9ba 100644 (file)
@@ -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;
+}
index 4120cfc35133b6c511351e0c450bc6e5fa8a1a76..f7fe8a2520c23fa3e0fdc3abd22d3d4aeea0d875 100644 (file)
@@ -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;
-}
-
 /*
  *-----------------------------------------------------------------------------
  *