1*c5c0fdbeSDavid 'Digit' Turner /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2*c5c0fdbeSDavid 'Digit' Turner #ifndef _LINUX_STDDEF_H 3*c5c0fdbeSDavid 'Digit' Turner #define _LINUX_STDDEF_H 4*c5c0fdbeSDavid 'Digit' Turner 5*c5c0fdbeSDavid 'Digit' Turner 6*c5c0fdbeSDavid 'Digit' Turner 7*c5c0fdbeSDavid 'Digit' Turner #ifndef __always_inline 8*c5c0fdbeSDavid 'Digit' Turner #define __always_inline __inline__ 9*c5c0fdbeSDavid 'Digit' Turner #endif 10*c5c0fdbeSDavid 'Digit' Turner 11*c5c0fdbeSDavid 'Digit' Turner /** 12*c5c0fdbeSDavid 'Digit' Turner * __struct_group() - Create a mirrored named and anonyomous struct 13*c5c0fdbeSDavid 'Digit' Turner * 14*c5c0fdbeSDavid 'Digit' Turner * @TAG: The tag name for the named sub-struct (usually empty) 15*c5c0fdbeSDavid 'Digit' Turner * @NAME: The identifier name of the mirrored sub-struct 16*c5c0fdbeSDavid 'Digit' Turner * @ATTRS: Any struct attributes (usually empty) 17*c5c0fdbeSDavid 'Digit' Turner * @MEMBERS: The member declarations for the mirrored structs 18*c5c0fdbeSDavid 'Digit' Turner * 19*c5c0fdbeSDavid 'Digit' Turner * Used to create an anonymous union of two structs with identical layout 20*c5c0fdbeSDavid 'Digit' Turner * and size: one anonymous and one named. The former's members can be used 21*c5c0fdbeSDavid 'Digit' Turner * normally without sub-struct naming, and the latter can be used to 22*c5c0fdbeSDavid 'Digit' Turner * reason about the start, end, and size of the group of struct members. 23*c5c0fdbeSDavid 'Digit' Turner * The named struct can also be explicitly tagged for layer reuse, as well 24*c5c0fdbeSDavid 'Digit' Turner * as both having struct attributes appended. 25*c5c0fdbeSDavid 'Digit' Turner */ 26*c5c0fdbeSDavid 'Digit' Turner #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \ 27*c5c0fdbeSDavid 'Digit' Turner union { \ 28*c5c0fdbeSDavid 'Digit' Turner struct { MEMBERS } ATTRS; \ 29*c5c0fdbeSDavid 'Digit' Turner struct TAG { MEMBERS } ATTRS NAME; \ 30*c5c0fdbeSDavid 'Digit' Turner } 31*c5c0fdbeSDavid 'Digit' Turner 32*c5c0fdbeSDavid 'Digit' Turner /** 33*c5c0fdbeSDavid 'Digit' Turner * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union 34*c5c0fdbeSDavid 'Digit' Turner * 35*c5c0fdbeSDavid 'Digit' Turner * @TYPE: The type of each flexible array element 36*c5c0fdbeSDavid 'Digit' Turner * @NAME: The name of the flexible array member 37*c5c0fdbeSDavid 'Digit' Turner * 38*c5c0fdbeSDavid 'Digit' Turner * In order to have a flexible array member in a union or alone in a 39*c5c0fdbeSDavid 'Digit' Turner * struct, it needs to be wrapped in an anonymous struct with at least 1 40*c5c0fdbeSDavid 'Digit' Turner * named member, but that member can be empty. 41*c5c0fdbeSDavid 'Digit' Turner */ 42*c5c0fdbeSDavid 'Digit' Turner #define __DECLARE_FLEX_ARRAY(TYPE, NAME) \ 43*c5c0fdbeSDavid 'Digit' Turner struct { \ 44*c5c0fdbeSDavid 'Digit' Turner struct { } __empty_ ## NAME; \ 45*c5c0fdbeSDavid 'Digit' Turner TYPE NAME[]; \ 46*c5c0fdbeSDavid 'Digit' Turner } 47*c5c0fdbeSDavid 'Digit' Turner #endif 48