X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=include%2Flinux%2Fcompiler.h;h=cd97693822d7d8f0df3f0aa6f9d03b47ae747bce;hb=455aaa1537c1bc0f9bc7e2ffa6802c8e4872738a;hp=e40d8aec3c45f5ab284e03156bdcab93f31e97b5;hpb=a1f8f8c3924cff7ffbe15236c18e393f046ad755;p=carl9170fw.git diff --git a/include/linux/compiler.h b/include/linux/compiler.h index e40d8ae..cd97693 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -111,4 +111,20 @@ static inline unsigned int hweight8(unsigned int w) return (res + (res >> 4)) & 0x0F; } +/** + * 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 /* __SHARED_COMPILER_H */