[PATCH 03/12] osdep.h: move qemu_build_not_reached()

marcandre.lureau@redhat.com posted 12 patches 3 years, 6 months ago
There is a newer version of this series
[PATCH 03/12] osdep.h: move qemu_build_not_reached()
Posted by marcandre.lureau@redhat.com 3 years, 6 months ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Move the macro and declaration so it can use glib in the following
patch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/qemu/compiler.h | 16 ----------------
 include/qemu/osdep.h    | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 0a5e67fb970e..a2d2d48dcf34 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -151,22 +151,6 @@
 #define QEMU_ALWAYS_INLINE
 #endif
 
-/**
- * qemu_build_not_reached()
- *
- * The compiler, during optimization, is expected to prove that a call
- * to this function cannot be reached and remove it.  If the compiler
- * supports QEMU_ERROR, this will be reported at compile time; otherwise
- * this will be reported at link time due to the missing symbol.
- */
-extern void QEMU_NORETURN QEMU_ERROR("code path is reachable")
-    qemu_build_not_reached_always(void);
-#if defined(__OPTIMIZE__) && !defined(__NO_INLINE__)
-#define qemu_build_not_reached()  qemu_build_not_reached_always()
-#else
-#define qemu_build_not_reached()  g_assert_not_reached()
-#endif
-
 /**
  * In most cases, normal "fallthrough" comments are good enough for
  * switch-case statements, but sometimes the compiler has problems
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 7bcce3bceb0f..fb72b0006d5c 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -157,6 +157,22 @@ extern "C" {
 #define assert(x)  g_assert(x)
 #endif
 
+/**
+ * qemu_build_not_reached()
+ *
+ * The compiler, during optimization, is expected to prove that a call
+ * to this function cannot be reached and remove it.  If the compiler
+ * supports QEMU_ERROR, this will be reported at compile time; otherwise
+ * this will be reported at link time due to the missing symbol.
+ */
+extern void QEMU_NORETURN QEMU_ERROR("code path is reachable")
+    qemu_build_not_reached_always(void);
+#if defined(__OPTIMIZE__) && !defined(__NO_INLINE__)
+#define qemu_build_not_reached()  qemu_build_not_reached_always()
+#else
+#define qemu_build_not_reached()  g_assert_not_reached()
+#endif
+
 /*
  * According to waitpid man page:
  * WCOREDUMP
-- 
2.35.1.273.ge6ebfd0e8cbb


Re: [PATCH 03/12] osdep.h: move qemu_build_not_reached()
Posted by Richard Henderson 3 years, 6 months ago
On 2/24/22 08:36, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau<marcandre.lureau@redhat.com>
> 
> Move the macro and declaration so it can use glib in the following
> patch.
> 
> Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> ---
>   include/qemu/compiler.h | 16 ----------------
>   include/qemu/osdep.h    | 16 ++++++++++++++++
>   2 files changed, 16 insertions(+), 16 deletions(-)

Would this be obviated by a change to _Noreturn?


r~

Re: [PATCH 03/12] osdep.h: move qemu_build_not_reached()
Posted by Marc-André Lureau 3 years, 6 months ago
Hi

On Thu, Feb 24, 2022 at 11:43 PM Richard Henderson <
richard.henderson@linaro.org> wrote:

> On 2/24/22 08:36, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau<marcandre.lureau@redhat.com>
> >
> > Move the macro and declaration so it can use glib in the following
> > patch.
> >
> > Signed-off-by: Marc-André Lureau<marcandre.lureau@redhat.com>
> > ---
> >   include/qemu/compiler.h | 16 ----------------
> >   include/qemu/osdep.h    | 16 ++++++++++++++++
> >   2 files changed, 16 insertions(+), 16 deletions(-)
>
> Would this be obviated by a change to _Noreturn?
>

Yes. Or we could just switch this one to _Noreturn if we decide to use
G_NORETURN elsewhere.

-- 
Marc-André Lureau