Skip to content

Commit d6e23e1

Browse files
committed
btrfs-progs: kerncompat: define __DECLARE_FLEX_ARRAY if missing
The macro is not available on LTS distros, copy definition from kernel. Signed-off-by: David Sterba <[email protected]>
1 parent ed1f7ac commit d6e23e1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

include/kerncompat.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,26 @@
103103
#define BUILD_ASSERT(x)
104104
#endif
105105

106+
#ifndef __DECLARE_FLEX_ARRAY
107+
/*
108+
* Copied from linux.git/include/uapi/stddef.h
109+
*
110+
* __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
111+
*
112+
* @TYPE: The type of each flexible array element
113+
* @NAME: The name of the flexible array member
114+
*
115+
* In order to have a flexible array member in a union or alone in a struct, it
116+
* needs to be wrapped in an anonymous struct with at least 1 named member, but
117+
* that member can be empty.
118+
*/
119+
#define __DECLARE_FLEX_ARRAY(TYPE, NAME) \
120+
struct { \
121+
struct { } __empty_ ## NAME; \
122+
TYPE NAME[]; \
123+
}
124+
#endif
125+
106126
static inline void print_trace(void)
107127
{
108128
#ifndef BTRFS_DISABLE_BACKTRACE

0 commit comments

Comments
 (0)