[PATCH v2 5/5] bulk: Replace __attribute__((noreturn)) -> G_NORETURN

Philippe Mathieu-Daudé posted 5 patches 2 years, 8 months ago
Maintainers: Warner Losh <imp@bsdimp.com>, Kyle Evans <kevans@freebsd.org>, "Daniel P. Berrangé" <berrange@redhat.com>, Stefano Stabellini <sstabellini@kernel.org>, Anthony Perard <anthony.perard@citrix.com>, Paul Durrant <paul@xen.org>, "Cédric Le Goater" <clg@kaod.org>, Peter Maydell <peter.maydell@linaro.org>, Andrew Jeffery <andrew@aj.id.au>, Joel Stanley <joel@jms.id.au>, Tyrone Ting <kfting@nuvoton.com>, Hao Wu <wuhaotsh@google.com>, Paolo Bonzini <pbonzini@redhat.com>, Eduardo Habkost <eduardo@habkost.net>, Richard Henderson <richard.henderson@linaro.org>, Stefan Weil <sw@weilnetz.de>, Riku Voipio <riku.voipio@iki.fi>, Marcelo Tosatti <mtosatti@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Aurelien Jarno <aurelien@aurel32.net>, Jiaxun Yang <jiaxun.yang@flygoat.com>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Juan Quintela <quintela@redhat.com>, Peter Xu <peterx@redhat.com>, Leonardo Bras <leobras@redhat.com>
[PATCH v2 5/5] bulk: Replace __attribute__((noreturn)) -> G_NORETURN
Posted by Philippe Mathieu-Daudé 2 years, 8 months ago
Under MSYS2, G_NORETURN is expanded to '[[noreturn]]'.
Simpler to use the same definition everywhere, unifying
the code style.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
---
 include/sysemu/os-win32.h | 2 +-
 tests/migration/stress.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/sysemu/os-win32.h b/include/sysemu/os-win32.h
index f8e300d302..fb076a6eb9 100644
--- a/include/sysemu/os-win32.h
+++ b/include/sysemu/os-win32.h
@@ -67,7 +67,7 @@ extern "C" {
  * which gets linked automatically.
  */
 int __mingw_setjmp(jmp_buf);
-void __attribute__((noreturn)) __mingw_longjmp(jmp_buf, int);
+G_NORETURN void __mingw_longjmp(jmp_buf, int);
 #define setjmp(env) __mingw_setjmp(env)
 #define longjmp(env, val) __mingw_longjmp(env, val)
 #elif defined(_WIN64)
diff --git a/tests/migration/stress.c b/tests/migration/stress.c
index 88acf8dc25..54a95c07f1 100644
--- a/tests/migration/stress.c
+++ b/tests/migration/stress.c
@@ -36,7 +36,7 @@ static int gettid(void)
 }
 #endif
 
-static __attribute__((noreturn)) void exit_failure(void)
+static G_NORETURN void exit_failure(void)
 {
     if (getpid() == 1) {
         sync();
-- 
2.38.1


Re: [PATCH v2 5/5] bulk: Replace __attribute__((noreturn)) -> G_NORETURN
Posted by Richard Henderson 2 years, 8 months ago
On 6/5/23 10:56, Philippe Mathieu-Daudé wrote:
> -static __attribute__((noreturn)) void exit_failure(void)
> +static G_NORETURN void exit_failure(void)

I think attr-spec-seq ('[[noreturn]]') has to come before specifiers-and-qualifiers (i.e. 
'static').

To me this means that G_NORETURN being redefined from __attribute__((noreturn)) to 
[[noreturn]] was a glib bug, since it has a different syntax.

Therefore we should simply avoid G_NORETURN entirely.  At some point we should be able to 
update -to --std=c23, at which point we use [[noreturn]] directly and not G_NORETURN anyway.


r~