diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-02-05 21:15:52 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-02-06 12:04:16 +0100 |
commit | da8587b24e64e566a68e547ff42cf44e22714bda (patch) | |
tree | f2fafa005868de3f794de3abba431412fdb7f567 /src/fundamental | |
parent | c8b960af14f94a490ba569e7d193c73373375a58 (diff) | |
download | systemd-da8587b24e64e566a68e547ff42cf44e22714bda.tar.gz |
sd-journal: avoid use of fake flex arrays
I tried to use DECLARE_FLEX_ARRAY like the kernel does, but it does not work
for anonymous structs (they cannot be declared inline), so an open-coded
version is used.
Diffstat (limited to 'src/fundamental')
-rw-r--r-- | src/fundamental/macro-fundamental.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/fundamental/macro-fundamental.h b/src/fundamental/macro-fundamental.h index b939ee1a7e..c4ad957588 100644 --- a/src/fundamental/macro-fundamental.h +++ b/src/fundamental/macro-fundamental.h @@ -376,3 +376,15 @@ static inline size_t ALIGN_TO(size_t l, size_t ali) { (v) = UPDATE_FLAG(v, flag, b) #define FLAGS_SET(v, flags) \ ((~(v) & (flags)) == 0) + +/* Declare a flexible array usable in a union. + * This is essentially a work-around for a pointless constraint in C99 + * and might go away in some future version of the standard. + * + * See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=3080ea5553cc909b000d1f1d964a9041962f2c5b + */ +#define DECLARE_FLEX_ARRAY(type, name) \ + struct { \ + dummy_t __empty__ ## name; \ + type name[]; \ + } |