diff options
author | Kees Cook <kees@outflux.net> | 2023-04-05 15:52:23 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2023-04-06 20:29:12 +0200 |
commit | 11132ad0176e9a6a847a9bfca77c39c2857cf85b (patch) | |
tree | 24f9cb335de4fe5bf19bbd1a4addc6a91d9b3c56 /include/acpi/actypes.h | |
parent | 2a5ab99847bd41ad5f0461f519d0825f163874a6 (diff) |
ACPICA: Introduce ACPI_FLEX_ARRAY
ACPICA commit e73b227e8e475c20cc394f237ea35d592fdf9ec3
In order to enable using -fstrict-flex-arrays with GCC and Clang in the
Linux kernel, each trailing dynamically sized array must be defined as
proper C99 "flexible array members" (FAM). Unfortunately, ACPICA has a
bunch of technical debt, dating back to before even the GNU extension of
0-length arrays, meaning the code base has many 1-element and 0-length
arrays defined at the end of structures that should actually be FAMs.
One limitation of the C99 FAM specification is the accidental requirement
that they cannot be in unions or alone in structs. There is no real-world
reason for this, though, and, actually, the existing GNU extension
permits this for 0-length arrays (which get treated as FAMs).
Add the ACPI_FLEX_ARRAY() helper macro to work around this requirement
so that FAMs can be defined in unions or alone in structs. Since this
behavior still depends on GNU extensions, keep the macro specific to GCC
(and Clang) builds. In this way, MSVC will continue to use 0-length
arrays (since it does not support the union work-around). When MSVC
grows support for this in the future, the macro can be updated.
Link: https://github.com/acpica/acpica/commit/e73b227e
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'include/acpi/actypes.h')
-rw-r--r-- | include/acpi/actypes.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h index ce1db1c2e9d3..cf6ee2cb0eb9 100644 --- a/include/acpi/actypes.h +++ b/include/acpi/actypes.h @@ -1323,4 +1323,8 @@ typedef enum { #define ACPI_FALLTHROUGH do {} while(0) #endif +#ifndef ACPI_FLEX_ARRAY +#define ACPI_FLEX_ARRAY(TYPE, NAME) TYPE NAME[0] +#endif + #endif /* __ACTYPES_H__ */ |