]>
Commit | Line | Data |
---|---|---|
f1aff7aa PX |
1 | /* |
2 | * Common qemu-thread implementation header file. | |
3 | * | |
4 | * Copyright Red Hat, Inc. 2018 | |
5 | * | |
6 | * Authors: | |
7 | * Peter Xu <[email protected]>, | |
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/typedefs.h" | |
17 | #include "qemu/thread.h" | |
18 | #include "trace.h" | |
19 | ||
20 | static inline void qemu_mutex_post_init(QemuMutex *mutex) | |
21 | { | |
ba59fb77 PB |
22 | #ifdef CONFIG_DEBUG_MUTEX |
23 | mutex->file = NULL; | |
24 | mutex->line = 0; | |
25 | #endif | |
f1aff7aa PX |
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 | { | |
ba59fb77 PB |
38 | #ifdef CONFIG_DEBUG_MUTEX |
39 | mutex->file = file; | |
40 | mutex->line = line; | |
41 | #endif | |
f1aff7aa PX |
42 | trace_qemu_mutex_locked(mutex, file, line); |
43 | } | |
44 | ||
45 | static inline void qemu_mutex_pre_unlock(QemuMutex *mutex, | |
46 | const char *file, int line) | |
47 | { | |
ba59fb77 PB |
48 | #ifdef CONFIG_DEBUG_MUTEX |
49 | mutex->file = NULL; | |
50 | mutex->line = 0; | |
51 | #endif | |
f1aff7aa PX |
52 | trace_qemu_mutex_unlock(mutex, file, line); |
53 | } | |
54 | ||
55 | #endif |