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