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 <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-06-24 19:24:54 +02:00
parent ed1f7ac5ed
commit d6e23e1d5f

View File

@ -103,6 +103,26 @@
#define BUILD_ASSERT(x)
#endif
#ifndef __DECLARE_FLEX_ARRAY
/*
* Copied from linux.git/include/uapi/stddef.h
*
* __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
static inline void print_trace(void)
{
#ifndef BTRFS_DISABLE_BACKTRACE