]> git.proxmox.com Git - mirror_qemu.git/blobdiff - replay/replay-time.c
include/exec: Move PAGE_* macros to common header
[mirror_qemu.git] / replay / replay-time.c
index f70382a88f3c9fa7c387a90765932747f04319b3..ee0ebfcf09f8497767e8b60cba26dc3aecaa2275 100644 (file)
  */
 
 #include "qemu/osdep.h"
-#include "qemu-common.h"
 #include "sysemu/replay.h"
 #include "replay-internal.h"
 #include "qemu/error-report.h"
 
-int64_t replay_save_clock(ReplayClockKind kind, int64_t clock)
+int64_t replay_save_clock(ReplayClockKind kind, int64_t clock,
+                          int64_t raw_icount)
 {
-    replay_save_instructions();
+    g_assert(replay_file);
+    g_assert(replay_mutex_locked());
 
-    if (replay_file) {
-        replay_mutex_lock();
-        replay_put_event(EVENT_CLOCK + kind);
-        replay_put_qword(clock);
-        replay_mutex_unlock();
-    }
+    /*
+     * Due to the caller's locking requirements we get the icount from it
+     * instead of using replay_save_instructions().
+     */
+    replay_advance_current_icount(raw_icount);
+    replay_put_event(EVENT_CLOCK + kind);
+    replay_put_qword(clock);
 
     return clock;
 }
@@ -44,22 +46,14 @@ void replay_read_next_clock(ReplayClockKind kind)
 }
 
 /*! Reads next clock event from the input. */
-int64_t replay_read_clock(ReplayClockKind kind)
+int64_t replay_read_clock(ReplayClockKind kind, int64_t raw_icount)
 {
-    replay_account_executed_instructions();
+    g_assert(replay_file && replay_mutex_locked());
 
-    if (replay_file) {
-        int64_t ret;
-        replay_mutex_lock();
-        if (replay_next_event_is(EVENT_CLOCK + kind)) {
-            replay_read_next_clock(kind);
-        }
-        ret = replay_state.cached_clock[kind];
-        replay_mutex_unlock();
+    replay_advance_current_icount(raw_icount);
 
-        return ret;
+    if (replay_next_event_is(EVENT_CLOCK + kind)) {
+        replay_read_next_clock(kind);
     }
-
-    error_report("REPLAY INTERNAL ERROR %d", __LINE__);
-    exit(1);
+    return replay_state.cached_clock[kind];
 }