aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnup Patel <apatel@ventanamicro.com>2023-07-12 22:04:53 +0530
committerWill Deacon <will@kernel.org>2023-07-20 15:59:29 +0100
commitd8343698df72d03986efc4b985b2ee18df514200 (patch)
tree5c8cba8ebf345597018f5ca381786dd7a34b404a
parent15757e8e6441d83757c39046a6cdd3e4d74200ce (diff)
downloadkvmtool-d8343698df72d03986efc4b985b2ee18df514200.tar.gz
kvm tools: Add __DECLARE_FLEX_ARRAY() in include/linux/stddef.h
Latest x86 UAPI headers uses __DECLARE_FLEX_ARRAY() macro so let us take this macro from Linux UAPI header and add it to include/linux/stddef.h. Signed-off-by: Anup Patel <apatel@ventanamicro.com> Link: https://lore.kernel.org/r/20230712163501.1769737-2-apatel@ventanamicro.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--include/linux/stddef.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index 39da8088..d94e900f 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -7,4 +7,20 @@
#undef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+/**
+ * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
+ *
+ * @TYPE: The type of each flexible array element
+ * @NAME: The name of the flexible array member
+ *
+ * In order to have a flexible array member in a union or alone in a
+ * struct, it needs to be wrapped in an anonymous struct with at least 1
+ * named member, but that member can be empty.
+ */
+#define __DECLARE_FLEX_ARRAY(TYPE, NAME) \
+ struct { \
+ struct { } __empty_ ## NAME; \
+ TYPE NAME[]; \
+ }
+
#endif