Il 16/07/2014 14:18, Sebastian Tanase ha scritto:
-    static int64_t clocks_offset;
-    if (!icount_align_option) {
-        return;
+    static int64_t realtime_clock_value;

Does this really need to be static?

+    if (icount_align_option || !realtime_clock_value) {
+        realtime_clock_value = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
     }
-    sc->realtime_clock = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
     /* Compute offset between the 2 clocks. */
     if (!clocks_offset) {
-        clocks_offset = sc->realtime_clock -
+        clocks_offset = realtime_clock_value -
                         qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
     }

Isn't clocks_offset roughly the same as -timers_state.cpu_clock_offset? If so, you could be some simplification in the code. Feel free to move the TimersState struct definition to include/sysemu/cpus.h and make timers_state public.

+    cpu_fprintf(f, "Host - Guest clock  %ld(ms)\n",
+                (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - clocks_offset -
+                 qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL))/SCALE_MS);

I think this is (cpu_get_clock() - cpu_get_icount()) / SCALE_MS.

Paolo

Reply via email to