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