.. | .. |
---|
36 | 36 | #define offsetofend(TYPE, MEMBER) \ |
---|
37 | 37 | (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER)) |
---|
38 | 38 | |
---|
| 39 | +/** |
---|
| 40 | + * struct_group() - Wrap a set of declarations in a mirrored struct |
---|
| 41 | + * |
---|
| 42 | + * @NAME: The identifier name of the mirrored sub-struct |
---|
| 43 | + * @MEMBERS: The member declarations for the mirrored structs |
---|
| 44 | + * |
---|
| 45 | + * Used to create an anonymous union of two structs with identical |
---|
| 46 | + * layout and size: one anonymous and one named. The former can be |
---|
| 47 | + * used normally without sub-struct naming, and the latter can be |
---|
| 48 | + * used to reason about the start, end, and size of the group of |
---|
| 49 | + * struct members. |
---|
| 50 | + */ |
---|
| 51 | +#define struct_group(NAME, MEMBERS...) \ |
---|
| 52 | + __struct_group(/* no tag */, NAME, /* no attrs */, MEMBERS) |
---|
| 53 | + |
---|
| 54 | +/** |
---|
| 55 | + * struct_group_attr() - Create a struct_group() with trailing attributes |
---|
| 56 | + * |
---|
| 57 | + * @NAME: The identifier name of the mirrored sub-struct |
---|
| 58 | + * @ATTRS: Any struct attributes to apply |
---|
| 59 | + * @MEMBERS: The member declarations for the mirrored structs |
---|
| 60 | + * |
---|
| 61 | + * Used to create an anonymous union of two structs with identical |
---|
| 62 | + * layout and size: one anonymous and one named. The former can be |
---|
| 63 | + * used normally without sub-struct naming, and the latter can be |
---|
| 64 | + * used to reason about the start, end, and size of the group of |
---|
| 65 | + * struct members. Includes structure attributes argument. |
---|
| 66 | + */ |
---|
| 67 | +#define struct_group_attr(NAME, ATTRS, MEMBERS...) \ |
---|
| 68 | + __struct_group(/* no tag */, NAME, ATTRS, MEMBERS) |
---|
| 69 | + |
---|
| 70 | +/** |
---|
| 71 | + * struct_group_tagged() - Create a struct_group with a reusable tag |
---|
| 72 | + * |
---|
| 73 | + * @TAG: The tag name for the named sub-struct |
---|
| 74 | + * @NAME: The identifier name of the mirrored sub-struct |
---|
| 75 | + * @MEMBERS: The member declarations for the mirrored structs |
---|
| 76 | + * |
---|
| 77 | + * Used to create an anonymous union of two structs with identical |
---|
| 78 | + * layout and size: one anonymous and one named. The former can be |
---|
| 79 | + * used normally without sub-struct naming, and the latter can be |
---|
| 80 | + * used to reason about the start, end, and size of the group of |
---|
| 81 | + * struct members. Includes struct tag argument for the named copy, |
---|
| 82 | + * so the specified layout can be reused later. |
---|
| 83 | + */ |
---|
| 84 | +#define struct_group_tagged(TAG, NAME, MEMBERS...) \ |
---|
| 85 | + __struct_group(TAG, NAME, /* no attrs */, MEMBERS) |
---|
| 86 | + |
---|
39 | 87 | #endif |
---|