16f52b16cSGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2*55037ed7STadeusz Struk #ifndef _UAPI_LINUX_STDDEF_H 3*55037ed7STadeusz Struk #define _UAPI_LINUX_STDDEF_H 4*55037ed7STadeusz Struk 5d1515582SWill Deacon #include <linux/compiler_types.h> 6283d7573SDenys Vlasenko 7283d7573SDenys Vlasenko #ifndef __always_inline 8283d7573SDenys Vlasenko #define __always_inline inline 9283d7573SDenys Vlasenko #endif 1050d7bd38SKees Cook 1150d7bd38SKees Cook /** 1250d7bd38SKees Cook * __struct_group() - Create a mirrored named and anonyomous struct 1350d7bd38SKees Cook * 1450d7bd38SKees Cook * @TAG: The tag name for the named sub-struct (usually empty) 1550d7bd38SKees Cook * @NAME: The identifier name of the mirrored sub-struct 1650d7bd38SKees Cook * @ATTRS: Any struct attributes (usually empty) 1750d7bd38SKees Cook * @MEMBERS: The member declarations for the mirrored structs 1850d7bd38SKees Cook * 1950d7bd38SKees Cook * Used to create an anonymous union of two structs with identical layout 2050d7bd38SKees Cook * and size: one anonymous and one named. The former's members can be used 2150d7bd38SKees Cook * normally without sub-struct naming, and the latter can be used to 2250d7bd38SKees Cook * reason about the start, end, and size of the group of struct members. 2350d7bd38SKees Cook * The named struct can also be explicitly tagged for layer reuse, as well 2450d7bd38SKees Cook * as both having struct attributes appended. 2550d7bd38SKees Cook */ 2650d7bd38SKees Cook #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \ 2750d7bd38SKees Cook union { \ 2850d7bd38SKees Cook struct { MEMBERS } ATTRS; \ 2950d7bd38SKees Cook struct TAG { MEMBERS } ATTRS NAME; \ 3050d7bd38SKees Cook } 313080ea55SKees Cook 323080ea55SKees Cook /** 333080ea55SKees Cook * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union 343080ea55SKees Cook * 353080ea55SKees Cook * @TYPE: The type of each flexible array element 363080ea55SKees Cook * @NAME: The name of the flexible array member 373080ea55SKees Cook * 383080ea55SKees Cook * In order to have a flexible array member in a union or alone in a 393080ea55SKees Cook * struct, it needs to be wrapped in an anonymous struct with at least 1 403080ea55SKees Cook * named member, but that member can be empty. 413080ea55SKees Cook */ 423080ea55SKees Cook #define __DECLARE_FLEX_ARRAY(TYPE, NAME) \ 433080ea55SKees Cook struct { \ 443080ea55SKees Cook struct { } __empty_ ## NAME; \ 453080ea55SKees Cook TYPE NAME[]; \ 463080ea55SKees Cook } 47*55037ed7STadeusz Struk #endif 48