From: "Pedro Falcato" <pedro.falcato@gmail.com>
To: devel@edk2.groups.io, yeoreum.yun@arm.com
Cc: "Kinney, Michael D" <michael.d.kinney@intel.com>, nd <nd@arm.com>,
Sami Mujawar <Sami.Mujawar@arm.com>
Subject: Re: [edk2-devel] [Question] using Flexible Array Member in Structure.
Date: Fri, 5 Apr 2024 08:29:21 +0100 [thread overview]
Message-ID: <CAKbZUD364Peq+RWhhOePrb2LxVXkoVcBzrSgFXt3WuG7icdxLw@mail.gmail.com> (raw)
In-Reply-To: <AM0PR08MB4289DDCE0B3C16B47742E11EFB032@AM0PR08MB4289.eurprd08.prod.outlook.com>
On Fri, Apr 5, 2024 at 7:43 AM levi.yun <yeoreum.yun@arm.com> wrote:
>
> Hi Michael! Thanks for answer.
>
> > Converting these to a flexible array member would not be
> a backwards compatible change.
>
> That's the point. But at least when I see the compiler used in tool_def.txt,
> there's no compiler which doesn't support to flexible array member.
>
> Do we still need to consider the case building edk2 with lower version of comipler
> which isn't manifested in tool_def.txt?
That's not in question. What Mike is referring to here is, e.g:
typedef struct {
BOOLEAN Supported;
UINT64 KeyCount;
UINT64 CapabilityCount;
EFI_BLOCK_IO_CRYPTO_CAPABILITY Capabilities [1];
} EFI_BLOCK_IO_CRYPTO_CAPABILITIES1;
typedef struct {
BOOLEAN Supported;
UINT64 KeyCount;
UINT64 CapabilityCount;
EFI_BLOCK_IO_CRYPTO_CAPABILITY Capabilities [];
} EFI_BLOCK_IO_CRYPTO_CAPABILITIES2;
sizeof(EFI_BLOCK_IO_CRYPTO_CAPABILITIES1) !=
sizeof(EFI_BLOCK_IO_CRYPTO_CAPABILITIES2), so it's an ABI break.
And unfortunately many of these structs need to be ABI-stable (I took
this one off the spec, you can find many such cases by ctrl+F'ing
[1]).
Basically, it comes down to the ABI. If it breaks the ABI, you need to
figure out *if* it matters (e.g is it part of a protocol, or is it an
internal lib struct that does not need to be stable, is it ABI to some
external component).
Also, worth noting that the "[1]" pattern is UB, and only works
because GCC (et al) don't want to break a bunch of code. If you're
defining a new struct, there's no reason to use [1] as a flexible
array.
--
Pedro
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117454): https://edk2.groups.io/g/devel/message/117454
Mute This Topic: https://groups.io/mt/105305209/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-04-05 7:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 9:27 [edk2-devel] [Question] using Flexible Array Member in Structure levi.yun
2024-04-03 16:17 ` Michael D Kinney
2024-04-05 6:43 ` levi.yun
2024-04-05 7:29 ` Pedro Falcato [this message]
2024-04-05 7:34 ` Pedro Falcato
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-list 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=CAKbZUD364Peq+RWhhOePrb2LxVXkoVcBzrSgFXt3WuG7icdxLw@mail.gmail.com \
--to=devel@edk2.groups.io \
/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