]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qemu-thread: Use futex if available for QemuLockCnt
authorAkihiko Odaki <akihiko.odaki@daynix.com>
Thu, 29 May 2025 05:45:55 +0000 (14:45 +0900)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 6 Jun 2025 12:32:55 +0000 (14:32 +0200)
This unlocks the futex-based implementation of QemuLockCnt to Windows.

Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
Link: https://lore.kernel.org/r/20250529-event-v5-6-53b285203794@daynix.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/qemu/lockcnt.h
util/lockcnt.c

index f4b62a3f70117a767430a7d090717d66d372673d..5a2800e3f18206deb20ceba0699ba5c6f8ca3bad 100644 (file)
@@ -17,7 +17,7 @@
 typedef struct QemuLockCnt QemuLockCnt;
 
 struct QemuLockCnt {
-#ifndef CONFIG_LINUX
+#ifndef HAVE_FUTEX
     QemuMutex mutex;
 #endif
     unsigned count;
index ca27d8e61a5cec13a7d1ad1ea8e405b382246df8..92c9f8ceca883523d697906bd5eaf33ea5d39e32 100644 (file)
 #include "qemu/atomic.h"
 #include "trace.h"
 
-#ifdef CONFIG_LINUX
-#include "qemu/futex.h"
+#ifdef HAVE_FUTEX
 
-/* On Linux, bits 0-1 are a futex-based lock, bits 2-31 are the counter.
+/*
+ * When futex is available, bits 0-1 are a futex-based lock, bits 2-31 are the
+ * counter.
  * For the mutex algorithm see Ulrich Drepper's "Futexes Are Tricky" (ok,
  * this is not the most relaxing citation I could make...).  It is similar
  * to mutex2 in the paper.