diff mbox series

[06/18] qemu-thread: Introduce QEMU_MUTEX_INITIALIZER

Message ID 20240923162208.90745-7-iii@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Stop all qemu-cpu threads on a breakpoint | expand

Commit Message

Ilya Leoshkevich Sept. 23, 2024, 4:13 p.m. UTC
Allow static initialization of mutexes.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 include/qemu/thread-posix.h | 6 ++++++
 include/qemu/thread-win32.h | 6 ++++++
 2 files changed, 12 insertions(+)

Comments

Richard Henderson Oct. 5, 2024, 7:30 p.m. UTC | #1
On 9/23/24 09:13, Ilya Leoshkevich wrote:
> Allow static initialization of mutexes.
> 
> Signed-off-by: Ilya Leoshkevich<iii@linux.ibm.com>
> ---
>   include/qemu/thread-posix.h | 6 ++++++
>   include/qemu/thread-win32.h | 6 ++++++
>   2 files changed, 12 insertions(+)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h
index 5f2f3d1386b..fc0846bfa7c 100644
--- a/include/qemu/thread-posix.h
+++ b/include/qemu/thread-posix.h
@@ -13,6 +13,12 @@  struct QemuMutex {
     bool initialized;
 };
 
+#ifdef CONFIG_DEBUG_MUTEX
+#define QEMU_MUTEX_INITIALIZER {PTHREAD_MUTEX_INITIALIZER, NULL, 0, true}
+#else
+#define QEMU_MUTEX_INITIALIZER {PTHREAD_MUTEX_INITIALIZER, true}
+#endif
+
 /*
  * QemuRecMutex cannot be a typedef of QemuMutex lest we have two
  * compatible cases in _Generic.  See qemu/lockable.h.
diff --git a/include/qemu/thread-win32.h b/include/qemu/thread-win32.h
index d95af4498fc..ed1f2d0e733 100644
--- a/include/qemu/thread-win32.h
+++ b/include/qemu/thread-win32.h
@@ -12,6 +12,12 @@  struct QemuMutex {
     bool initialized;
 };
 
+#ifdef CONFIG_DEBUG_MUTEX
+#define QEMU_MUTEX_INITIALIZER {SRWLOCK_INIT, NULL, 0, true}
+#else
+#define QEMU_MUTEX_INITIALIZER {SRWLOCK_INIT, true}
+#endif
+
 typedef struct QemuRecMutex QemuRecMutex;
 struct QemuRecMutex {
     CRITICAL_SECTION lock;