master
h 61 lines 1.39 KB
Raw
1 /*
2 * Common qemu-thread implementation header file.
3 *
4 * Copyright Red Hat, Inc. 2018
5 *
6 * Authors:
7 * Peter Xu <peterx@redhat.com>,
8 *
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
11 */
12
13 #ifndef QEMU_THREAD_COMMON_H
14 #define QEMU_THREAD_COMMON_H
15
16 #include "qemu/thread.h"
17 #include "qemu/main-loop.h"
18 #include "trace.h"
19
20 static inline void qemu_mutex_post_init(QemuMutex *mutex)
21 {
22 #ifdef CONFIG_DEBUG_MUTEX
23 mutex->file = NULL;
24 mutex->line = 0;
25 #endif
26 mutex->initialized = true;
27 }
28
29 static inline void qemu_mutex_pre_lock(QemuMutex *mutex,
30 const char *file, int line)
31 {
32 trace_qemu_mutex_lock(mutex, file, line);
33 }
34
35 static inline void qemu_mutex_post_lock(QemuMutex *mutex,
36 const char *file, int line)
37 {
38 #ifdef CONFIG_DEBUG_MUTEX
39 mutex->file = file;
40 mutex->line = line;
41 #endif
42 trace_qemu_mutex_locked(mutex, file, line);
43 if (mutex_is_bql(mutex)) {
44 bql_update_status(true);
45 }
46 }
47
48 static inline void qemu_mutex_pre_unlock(QemuMutex *mutex,
49 const char *file, int line)
50 {
51 #ifdef CONFIG_DEBUG_MUTEX
52 mutex->file = NULL;
53 mutex->line = 0;
54 #endif
55 trace_qemu_mutex_unlock(mutex, file, line);
56 if (mutex_is_bql(mutex)) {
57 bql_update_status(false);
58 }
59 }
60
61 #endif