All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Luca Fancellu <luca.fancellu@arm.com>
Cc: consulting@bugseng.com, nicola.vetrini@bugseng.com,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	George Dunlap <george.dunlap@citrix.com>,
	Julien Grall <julien@xen.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org
Subject: Re: [PATCH 1/2] xen/kernel.h: Import __struct_group from Linux
Date: Tue, 30 Apr 2024 13:43:00 +0200	[thread overview]
Message-ID: <cd2352aa-e94b-43ef-b3fc-359cc1f43fb0@suse.com> (raw)
In-Reply-To: <20240430110922.15052-2-luca.fancellu@arm.com>

On 30.04.2024 13:09, Luca Fancellu wrote:
> --- a/xen/include/xen/kernel.h
> +++ b/xen/include/xen/kernel.h
> @@ -54,6 +54,27 @@
>          typeof_field(type, member) *__mptr = (ptr);             \
>          (type *)( (char *)__mptr - offsetof(type,member) );})
>  
> +/**
> + * __struct_group() - Create a mirrored named and anonyomous struct
> + *
> + * @TAG: The tag name for the named sub-struct (usually empty)
> + * @NAME: The identifier name of the mirrored sub-struct
> + * @ATTRS: Any struct attributes (usually empty)
> + * @MEMBERS: The member declarations for the mirrored structs
> + *
> + * Used to create an anonymous union of two structs with identical layout
> + * and size: one anonymous and one named. The former's members can be used
> + * normally without sub-struct naming, and the latter can be used to
> + * reason about the start, end, and size of the group of struct members.
> + * The named struct can also be explicitly tagged for layer reuse, as well
> + * as both having struct attributes appended.
> + */
> +#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
> +    union { \
> +        struct { MEMBERS } ATTRS; \
> +        struct TAG { MEMBERS } ATTRS NAME; \
> +    } ATTRS

Besides my hesitance towards having this construct, can you explain why
ATTR needs using 3 times, i.e. also on the wrapping union?

Jan


  reply	other threads:[~2024-04-30 11:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 11:09 [PATCH 0/2] Fix MISRA regression about flexible array member not at the end Luca Fancellu
2024-04-30 11:09 ` [PATCH 1/2] xen/kernel.h: Import __struct_group from Linux Luca Fancellu
2024-04-30 11:43   ` Jan Beulich [this message]
2024-05-01  6:54     ` Luca Fancellu
2024-05-02  6:09       ` Jan Beulich
2024-05-02  6:23         ` Luca Fancellu
2024-05-02  6:38           ` Jan Beulich
2024-05-02 18:23   ` Stefano Stabellini
2024-04-30 11:09 ` [PATCH 2/2] xen/arm: Fix MISRA regression on R1.1, flexible array member not at the end Luca Fancellu
2024-04-30 11:37   ` Jan Beulich
2024-05-01  6:57     ` Luca Fancellu
2024-05-02  6:14       ` Jan Beulich
2024-05-02  6:33         ` Luca Fancellu
2024-05-02  6:43           ` Jan Beulich
2024-05-02  8:13             ` Luca Fancellu
2024-05-02  9:53               ` Jan Beulich
2024-05-02 10:12                 ` Luca Fancellu
2024-05-02 10:30                   ` Jan Beulich
2024-05-02 10:42                     ` Luca Fancellu
2024-04-30 12:55   ` Nicola Vetrini
2024-05-02 18:35   ` Stefano Stabellini
2024-05-08 16:18     ` Luca Fancellu

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=cd2352aa-e94b-43ef-b3fc-359cc1f43fb0@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=consulting@bugseng.com \
    --cc=george.dunlap@citrix.com \
    --cc=julien@xen.org \
    --cc=luca.fancellu@arm.com \
    --cc=nicola.vetrini@bugseng.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.