coroutine: Rename qemu_coroutine_inc/dec_pool_size()
[qemu.git] / replay / replay-random.c
blobafc7a0fcccaabe2b3f213bdb362d8cda13f85579
1 /*
2 * replay-random.c
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)
29 int ret = 0;
30 g_assert(replay_mutex_locked());
32 replay_account_executed_instructions();
33 if (replay_next_event_is(EVENT_RANDOM)) {
34 size_t buf_size = 0;
35 ret = replay_get_dword();
36 replay_get_array(buf, &buf_size);
37 replay_finish_event();
38 g_assert(buf_size == len);
39 } else {
40 error_report("Missing random event in the replay log");
41 exit(1);
43 return ret;