xref: /linux-6.15/include/uapi/linux/stddef.h (revision be58f710)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #include <linux/compiler_types.h>
3 
4 #ifndef __always_inline
5 #define __always_inline inline
6 #endif
7 
8 /**
9  * __struct_group() - Create a mirrored named and anonyomous struct
10  *
11  * @TAG: The tag name for the named sub-struct (usually empty)
12  * @NAME: The identifier name of the mirrored sub-struct
13  * @ATTRS: Any struct attributes (usually empty)
14  * @MEMBERS: The member declarations for the mirrored structs
15  *
16  * Used to create an anonymous union of two structs with identical layout
17  * and size: one anonymous and one named. The former's members can be used
18  * normally without sub-struct naming, and the latter can be used to
19  * reason about the start, end, and size of the group of struct members.
20  * The named struct can also be explicitly tagged for layer reuse, as well
21  * as both having struct attributes appended.
22  */
23 #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
24 	union { \
25 		struct { MEMBERS } ATTRS; \
26 		struct TAG { MEMBERS } ATTRS NAME; \
27 	}
28