From 7b5a01c90b240d126efc86f9f99100db918d452e Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Fri, 18 Nov 2022 09:48:08 -0800 Subject: Introduce ACPI_FLEX_ARRAY Add helper to work around the pointless C99 requirement that flex array members not be allowed in unions (nor alone in structs), which is not actually a real-world problem. --- source/include/platform/acenv.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/include/platform/acenv.h b/source/include/platform/acenv.h index 674c4c7d0..1cae95fd6 100644 --- a/source/include/platform/acenv.h +++ b/source/include/platform/acenv.h @@ -418,6 +418,17 @@ #define ACPI_STRUCT_INIT(field, value) value #endif +/* + * Flexible array members are not allowed to be part of a union under + * C99, but this is not for any technical reason. Work around the + * limitation. + */ +#define ACPI_FLEX_ARRAY(TYPE, NAME) \ + struct { \ + struct { } __Empty_ ## NAME; \ + TYPE NAME[]; \ + } + /* * Configurable calling conventions: * -- cgit v1.2.1