1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #include <linux/compiler_types.h>
4 #ifndef __always_inline
5 #define __always_inline inline
9 * __struct_group() - Create a mirrored named and anonyomous struct
11 * @TAG: The tag name for the named sub-struct (usually empty)
12 * @NAME: The identifier name of the mirrored sub-struct
13 * @ATTRS: Any struct attributes (usually empty)
14 * @MEMBERS: The member declarations for the mirrored structs
16 * Used to create an anonymous union of two structs with identical layout
17 * and size: one anonymous and one named. The former's members can be used
18 * normally without sub-struct naming, and the latter can be used to
19 * reason about the start, end, and size of the group of struct members.
20 * The named struct can also be explicitly tagged for layer reuse, as well
21 * as both having struct attributes appended.
23 #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
25 struct { MEMBERS } ATTRS; \
26 struct TAG { MEMBERS } ATTRS NAME; \
30 * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
32 * @TYPE: The type of each flexible array element
33 * @NAME: The name of the flexible array member
35 * In order to have a flexible array member in a union or alone in a
36 * struct, it needs to be wrapped in an anonymous struct with at least 1
37 * named member, but that member can be empty.
39 #define __DECLARE_FLEX_ARRAY(TYPE, NAME) \
41 struct { } __empty_ ## NAME; \