openbsd-ports/emulators/qemu/patches/patch-cpu-all_h
todd 5ba4e4fd59 update to 0.9.0, thanks to all who gave feedback
see http://qemu.org/changelog.html for details
new in OpenBSD, support for raw block devices
2007-05-01 12:55:13 +00:00

32 lines
812 B
Plaintext

$OpenBSD: patch-cpu-all_h,v 1.2 2007/05/01 12:55:14 todd Exp $
--- cpu-all.h.orig Mon Feb 5 17:01:54 2007
+++ cpu-all.h Tue Apr 3 08:21:26 2007
@@ -1002,13 +1002,22 @@ static inline int64_t cpu_get_real_ticks (void)
#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