lockable: remove QemuLockable from typedefs.h
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 2 May 2024 14:32:25 +0000 (16:32 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 3 May 2024 13:47:48 +0000 (15:47 +0200)
Using QemuLockable almost always requires going through QEMU_MAKE_LOCKABLE().
Therefore, there is little point in having the typedef always present.  Move
it to lockable.h, with only a small adjustment to coroutine.h (which has
a tricky co-dependency with lockable.h due to defining CoMutex *and*
using QemuLockable as a part of the CoQueue API).

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/qemu/coroutine.h
include/qemu/lockable.h
include/qemu/typedefs.h

index e6aff453017d158059148f20924e9cd68287e601..ff3084538b873c9c4bbe562078571b9e3074c004 100644 (file)
@@ -84,6 +84,8 @@ static inline coroutine_fn void qemu_co_mutex_assert_locked(CoMutex *mutex)
            mutex->holder == qemu_coroutine_self());
 }
 
+#include "qemu/lockable.h"
+
 /**
  * CoQueues are a mechanism to queue coroutines in order to continue executing
  * them later.  They are similar to condition variables, but they need help
@@ -281,8 +283,6 @@ void qemu_coroutine_inc_pool_size(unsigned int additional_pool_size);
  */
 void qemu_coroutine_dec_pool_size(unsigned int additional_pool_size);
 
-#include "qemu/lockable.h"
-
 /**
  * Sends a (part of) iovec down a socket, yielding when the socket is full, or
  * Receives data into a (part of) iovec from a socket,
index 9823220446d9bea927d23f6a91524fcf5c06000b..62110d2eb7460b9ab04e1bf7296cf4c6258f6c88 100644 (file)
 
 typedef void QemuLockUnlockFunc(void *);
 
-struct QemuLockable {
+typedef struct QemuLockable {
     void *object;
     QemuLockUnlockFunc *lock;
     QemuLockUnlockFunc *unlock;
-};
+} QemuLockable;
 
 static inline __attribute__((__always_inline__)) QemuLockable *
 qemu_make_lockable(void *x, QemuLockable *lockable)
index 090e219248a9ab04e37e266f11e6013f26c4fbea..ab24ca2876ca8044934be77fc59f7dce0f28e0e5 100644 (file)
@@ -105,7 +105,6 @@ typedef struct QEMUBH QEMUBH;
 typedef struct QemuConsole QemuConsole;
 typedef struct QEMUCursor QEMUCursor;
 typedef struct QEMUFile QEMUFile;
-typedef struct QemuLockable QemuLockable;
 typedef struct QemuMutex QemuMutex;
 typedef struct QemuOpts QemuOpts;
 typedef struct QemuOptsList QemuOptsList;