4 * Copyright (c) 2010-2020 Institute for System Programming
5 * of the Russian Academy of Sciences.
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.
12 #include "qemu/osdep.h"
13 #include "qemu/error-report.h"
14 #include "sysemu/replay.h"
15 #include "replay-internal.h"
17 void replay_save_random(int ret
, void *buf
, size_t len
)
19 g_assert(replay_mutex_locked());
21 replay_save_instructions();
22 replay_put_event(EVENT_RANDOM
);
23 replay_put_dword(ret
);
24 replay_put_array(buf
, len
);
27 int replay_read_random(void *buf
, size_t len
)
30 g_assert(replay_mutex_locked());
32 replay_account_executed_instructions();
33 if (replay_next_event_is(EVENT_RANDOM
)) {
35 ret
= replay_get_dword();
36 replay_get_array(buf
, &buf_size
);
37 replay_finish_event();
38 g_assert(buf_size
== len
);
40 error_report("Missing random event in the replay log");