qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	qemu-block@nongnu.org, "Gerd Hoffmann" <kraxel@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Eric Auger" <eric.auger@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Song Gao" <gaosong@loongson.cn>,
	"Xiaojuan Yang" <yangxiaojuan@loongson.cn>,
	"Richard Henderson" <richard.henderson@linaro.org>
Subject: Re: [RFC PATCH 01/78] include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough
Date: Fri, 13 Oct 2023 15:37:23 +0300	[thread overview]
Message-ID: <2gwxg.2pv9ux2894z@linaro.org> (raw)
In-Reply-To: <874jiuiu4w.fsf@pond.sub.org>

Hello Markus,

On Fri, 13 Oct 2023 15:28, Markus Armbruster <armbru@redhat.com> wrote:
>The commit message needs to explain why.

Certainly.

>This is wrong.  docs/devel/style.rst:
>
>    Include directives
>    ------------------
>
>    Order include directives as follows:
>
>    .. code-block:: c
>
>        #include "qemu/osdep.h"  /* Always first... */
>        #include <...>           /* then system headers... */
>        #include "..."           /* and finally QEMU headers. */
>
>Separate patch, please.

I know. spa headers use the `fallthrough` attribute and qemu/compiler.h 
defines it as a macro, so it breaks compilation. If the spa headers go 
after, we'd need to undef fallthrough before including them and 
re-define or re-include qemu/compiler.h after. What do you think would 
be best?

>
>> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
>> index 1109482a00..959982805d 100644
>> --- a/include/qemu/compiler.h
>> +++ b/include/qemu/compiler.h
>> @@ -1,215 +1,231 @@
>
>[...]
>
>>  #define QEMU_ALWAYS_INLINE
>>  #endif
>>  
>> -/**
>> - * In most cases, normal "fallthrough" comments are good enough for
>> - * switch-case statements, but sometimes the compiler has problems
>> - * with those. In that case you can use QEMU_FALLTHROUGH instead.
>> +/*
>> + * Add the pseudo keyword 'fallthrough' so case statement blocks
>
>Pseudo-keyword?  It's a macro.

C calls reserved words that you cannot redefine 'keywords'. Like 
'break', 'continue', 'return'. Hence it's a pseudo-keyword. It's also a 
macro. They are not mutually exclusive.

I did not write this, it was taken verbatim from the linux kernel 
source, see: /include/linux/compiler_attributes.h

>
>> + * must end with any of these keywords:
>> + *   break;
>> + *   fallthrough;
>> + *   continue;
>> + *   goto <label>;
>> + *   return [expression];
>
>These are statements, not keywords.

I'm pretty sure it refers to {break, fallthrough, continue, goto, 
return} by themselves.

>
>> + *
>> + *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
>
>Not sure we need to point to the docs here.  We have hundreds of
>__attribute__ uses in the tree.

Again, copied from /include/linux/compiler_attributes.h

>
>>   */
>> -#if __has_attribute(fallthrough)
>> -# define QEMU_FALLTHROUGH __attribute__((fallthrough))
>> +
>> +/*
>> + * glib_macros.h contains its own definition of fallthrough, so if we define
>> + * the pseudokeyword here it will expand when the glib header checks for the
>> + * attribute. glib headers must be #included after this header.
>> + */
>> +#ifdef fallthrough
>> +#undef fallthrough
>> +#endif
>
>Why do we need to roll our own macro then?

Glib uses a different name. The problem is when it checks for the 
compiler attribute, which expands into our macro.


--
Manos 


  reply	other threads:[~2023-10-13 12:50 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-13  7:47 [RFC PATCH 00/78] Strict disable implicit fallthrough Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 01/78] include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough Emmanouil Pitsidianakis
2023-10-13  8:16   ` Daniel P. Berrangé
2023-10-13  8:31     ` Manos Pitsidianakis
2023-10-13 12:28   ` Markus Armbruster
2023-10-13 12:37     ` Manos Pitsidianakis [this message]
2023-10-13  7:47 ` [RFC PATCH 02/78] block: add fallthrough pseudo-keyword Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 03/78] fpu/softfloat: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 04/78] qapi/opts-visitor: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 05/78] qobject/json: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 06/78] tcg: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 07/78] hw/virtio/virtio-balloon.c: " Emmanouil Pitsidianakis
2023-10-13  7:56   ` David Hildenbrand
2023-10-13  7:47 ` [RFC PATCH 08/78] hw/block: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 09/78] hw/acpi/aml-build.c: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 10/78] hw/ide/atapi.c: " Emmanouil Pitsidianakis
2023-10-13 22:27   ` John Snow
2023-10-13  7:47 ` [RFC PATCH 11/78] hw/timer: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 12/78] hw/usb: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 13/78] hw/adc: " Emmanouil Pitsidianakis
2023-10-13  8:13   ` Cédric Le Goater
2023-10-13  7:47 ` [RFC PATCH 14/78] util/error-report.c: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 15/78] accel/tcg: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 16/78] audio: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 17/78] ui/sdl2.c: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 18/78] ui/win32-kbd-hook.c: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 19/78] target/hppa: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 20/78] target/mips: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 21/78] target/sparc: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 22/78] target/ppc: " Emmanouil Pitsidianakis
2023-10-13  8:12   ` Cédric Le Goater
2023-10-13  7:47 ` [RFC PATCH 23/78] target/arm: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 24/78] target/alpha: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 25/78] target/i386: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 26/78] target/s390x: " Emmanouil Pitsidianakis
2023-10-13  7:57   ` David Hildenbrand
2023-10-13  7:47 ` [RFC PATCH 27/78] target/riscv: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 28/78] target/avr: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 29/78] target/cris: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 30/78] target/nios2: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 31/78] target/xtensa: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 32/78] target/m68k: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 33/78] target/rx: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 34/78] target/tricore: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 35/78] target/sh4: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 36/78] target/openrisc: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 37/78] target/hexagon: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 38/78] system/rtc.c: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 39/78] hw/scsi: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 40/78] hw/sd/sdhci.c: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 41/78] linux-user: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 42/78] hw/i386: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 43/78] hw/misc: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 44/78] hw/m68k/mcf_intc.c: " Emmanouil Pitsidianakis
2023-10-13  7:47 ` [RFC PATCH 45/78] hw/dma: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 46/78] disas: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 47/78] contrib/rdmacm-mux: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 48/78] contrib/vhost-user-scsi: " Emmanouil Pitsidianakis
2023-10-23  9:31   ` Raphael Norwitz
2023-10-13  7:48 ` [RFC PATCH 49/78] hw/arm: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 50/78] hw/audio: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 51/78] chardev: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 52/78] hw/char: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 53/78] nbd: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 54/78] hw/core: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 55/78] hw/display: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 56/78] hw/input: " Emmanouil Pitsidianakis
2023-10-13  7:48 ` [RFC PATCH 57/78] hw/net: " Emmanouil Pitsidianakis
2023-10-13  8:14 ` [RFC PATCH 00/78] Strict disable implicit fallthrough Daniel P. Berrangé
2023-10-13 12:51   ` Manos Pitsidianakis
2023-10-13 13:08     ` Daniel P. Berrangé
2023-10-13 12:15 ` BALATON Zoltan
2023-10-13 12:41 ` Markus Armbruster
2023-10-16 14:13   ` Peter Maydell
2023-10-16 14:58     ` Manos Pitsidianakis
2023-10-16 15:03       ` Peter Maydell
2023-10-16 18:15         ` Manos Pitsidianakis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2gwxg.2pv9ux2894z@linaro.org \
    --to=manos.pitsidianakis@linaro.org \
    --cc=armbru@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=gaosong@loongson.cn \
    --cc=kraxel@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=yangxiaojuan@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).