qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Patch: cpu-all.h for better cycle counter


From: Todd T. Fries
Subject: [Qemu-devel] Patch: cpu-all.h for better cycle counter
Date: Tue, 20 Mar 2007 21:37:28 -0500
User-agent: Mutt/1.5.12-2006-07-14

This is relative to the 20070319 snapshot.

--- cpu-all.h.orig      Fri Mar 16 18:58:11 2007
+++ cpu-all.h   Tue Mar 20 21:14:10 2007
@@ -1012,13 +1012,22 @@ static inline int64_t cpu_get_real_ticks
 #endif
 }
 #else
-/* The host CPU doesn't have an easily accessible cycle counter.
-   Just return a monotonically increasing vlue.  This will be totally wrong,
-   but hopefully better than nothing.  */
+# warning non-optimized CPU
+#include <sys/time.h>
+#include <time.h>
+
 static inline int64_t cpu_get_real_ticks (void)
 {
-    static int64_t ticks = 0;
-    return ticks++;
+       struct timeval tv;
+       static int64_t i = 0;
+       int64_t j;
+        
+       gettimeofday(&tv, NULL);
+       do {
+          j = (tv.tv_sec * (uint64_t) 1000000) + tv.tv_usec;
+       } while (i == j);
+       i = j;
+       return j;
 }
 #endif
 
-- 
Todd Fries .. address@hidden

 _____________________________________________
|                                             \  1.636.410.0632 (voice)
| Free Daemon Consulting, LLC                 \  1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com             \  1.866.792.3418 (FAX)
| "..in support of free software solutions."  \          250797 (FWD)
|                                             \
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
                                                 
              37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
                        http://todd.fries.net/pgp.txt





reply via email to

[Prev in Thread] Current Thread [Next in Thread]