qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v5 07/15] block: introduce QEMU_IN_COROUTINE macro


From: Emanuele Giuseppe Esposito
Subject: [PATCH v5 07/15] block: introduce QEMU_IN_COROUTINE macro
Date: Wed, 23 Nov 2022 06:42:19 -0500

This macro will be used to mark all coroutine_fn functions.
Right now, it will be used for the newly introduced coroutine_fn, since
we know the callers.

As a TODO, in the future we might want to add this macro to all
corotuine_fn functions, to be sure that they are only called in
coroutines context.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 include/block/block-common.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/block/block-common.h b/include/block/block-common.h
index 297704c1e9..24de1d63fd 100644
--- a/include/block/block-common.h
+++ b/include/block/block-common.h
@@ -34,6 +34,17 @@
 #include "qemu/hbitmap.h"
 #include "qemu/transactions.h"
 
+/*
+ * QEMU_IN_COROUTINE
+ *
+ * To be used in all coroutine_fn functions, to make sure that the caller
+ * is always a coroutine.
+ */
+#define QEMU_IN_COROUTINE()                                         \
+    do {                                                            \
+        assert(qemu_in_coroutine());                                \
+    } while (0)
+
 /*
  * generated_co_wrapper
  *
-- 
2.31.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]