]> git.ipfire.org Git - thirdparty/qemu.git/blame - replay/replay-time.c
replay: push replay_mutex_lock up the call tree
[thirdparty/qemu.git] / replay / replay-time.c
CommitLineData
8eda206e
PD
1/*
2 * replay-time.c
3 *
4 * Copyright (c) 2010-2015 Institute for System Programming
5 * of the Russian Academy of Sciences.
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2 or later.
8 * See the COPYING file in the top-level directory.
9 *
10 */
11
d38ea87a 12#include "qemu/osdep.h"
8eda206e
PD
13#include "qemu-common.h"
14#include "sysemu/replay.h"
15#include "replay-internal.h"
16#include "qemu/error-report.h"
17
18int64_t replay_save_clock(ReplayClockKind kind, int64_t clock)
19{
8eda206e
PD
20
21 if (replay_file) {
d759c951
AB
22 g_assert(replay_mutex_locked());
23
24 replay_save_instructions();
8eda206e
PD
25 replay_put_event(EVENT_CLOCK + kind);
26 replay_put_qword(clock);
8eda206e
PD
27 }
28
29 return clock;
30}
31
32void replay_read_next_clock(ReplayClockKind kind)
33{
f186d64d 34 unsigned int read_kind = replay_state.data_kind - EVENT_CLOCK;
8eda206e
PD
35
36 assert(read_kind == kind);
37
38 int64_t clock = replay_get_qword();
39
40 replay_check_error();
41 replay_finish_event();
42
43 replay_state.cached_clock[read_kind] = clock;
44}
45
46/*! Reads next clock event from the input. */
47int64_t replay_read_clock(ReplayClockKind kind)
48{
d759c951
AB
49 g_assert(replay_file && replay_mutex_locked());
50
8eda206e
PD
51 replay_account_executed_instructions();
52
53 if (replay_file) {
54 int64_t ret;
8eda206e
PD
55 if (replay_next_event_is(EVENT_CLOCK + kind)) {
56 replay_read_next_clock(kind);
57 }
58 ret = replay_state.cached_clock[kind];
8eda206e
PD
59
60 return ret;
61 }
62
63 error_report("REPLAY INTERNAL ERROR %d", __LINE__);
64 exit(1);
65}