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