From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>, qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Mahmoud Mandour" <ma.mandourr@gmail.com>,
"Alexandre Iooss" <erdnaxe@crans.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Stefano Garzarella" <sgarzare@redhat.com>
Subject: Re: [PATCH v3 2/3] docs/devel/style: add a section about bitfield, and disallow them for packed structures
Date: Mon, 9 Dec 2024 21:33:13 +0100 [thread overview]
Message-ID: <73cdfb51-aef9-4731-914a-7687f988997e@linaro.org> (raw)
In-Reply-To: <20241128201510.869974-3-pierrick.bouvier@linaro.org>
On 28/11/24 21:15, Pierrick Bouvier wrote:
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> docs/devel/style.rst | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
> diff --git a/docs/devel/style.rst b/docs/devel/style.rst
> index 2f68b500798..2d73e6a8f7a 100644
> --- a/docs/devel/style.rst
> +++ b/docs/devel/style.rst
> @@ -416,6 +416,26 @@ definitions instead of typedefs in headers and function prototypes; this
> avoids problems with duplicated typedefs and reduces the need to include
> headers from other headers.
>
> +Bitfields
> +---------
> +
> +C bitfields can be a cause of non-portability issues, especially under windows
> +where `MSVC has a different way to lay them out than gcc
"GCC" (as MSVC).
> +<https://gcc.gnu.org/onlinedocs/gcc/x86-Type-Attributes.html>`_, and on big and
"and on" sounds odd to me. Maybe ", or where endianness matters."?
> +little endian hosts.
> +
> +For this reason, we disallow usage of bitfields in packed structures and in any
> +structures which are supposed to exactly match a specific layout in guest
> +memory. Some existing code may use it, and we carefully ensured the layout was
> +the one expected.
> +
> +We also suggest avoiding bitfields even in structures where the exact
> +layout does not matter, unless you can show that they provide a significant
> +memory usage or usability benefit.
I don't think we should mention "significant memory usage benefit".
Anyhow,
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> +
> +We encourage the usage of ``include/hw/registerfields.h`` as a safe replacement
> +for bitfields.
> +
> Reserved namespaces in C and POSIX
> ----------------------------------
>
next prev parent reply other threads:[~2024-12-09 20:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 20:15 [PATCH v3 0/3] Enable clang build on Windows Pierrick Bouvier
2024-11-28 20:15 ` [PATCH v3 1/3] win32: remove usage of attribute gcc_struct Pierrick Bouvier
2024-11-28 21:01 ` Richard Henderson
2024-11-28 20:15 ` [PATCH v3 2/3] docs/devel/style: add a section about bitfield, and disallow them for packed structures Pierrick Bouvier
2024-11-28 21:02 ` Richard Henderson
2024-12-09 20:33 ` Philippe Mathieu-Daudé [this message]
2024-12-09 22:15 ` Pierrick Bouvier
2024-12-10 7:52 ` Thomas Huth
2024-12-10 10:10 ` Philippe Mathieu-Daudé
2024-12-10 18:45 ` Pierrick Bouvier
2024-11-28 20:15 ` [PATCH v3 3/3] plugins: enable linking with clang/lld Pierrick Bouvier
2025-01-10 8:03 ` Philippe Mathieu-Daudé
2024-12-09 18:34 ` [PATCH v3 0/3] Enable clang build on Windows Pierrick Bouvier
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=73cdfb51-aef9-4731-914a-7687f988997e@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=erdnaxe@crans.org \
--cc=ma.mandourr@gmail.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=thuth@redhat.com \
/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).