1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _LINUX_STDDEF_H
3 #define _LINUX_STDDEF_H
7 #ifndef __always_inline
8 #define __always_inline __inline__
11 /* Not all C++ standards support type declarations inside an anonymous union */
13 #define __struct_group_tag(TAG) TAG
15 #define __struct_group_tag(TAG)
19 * __struct_group() - Create a mirrored named and anonyomous struct
21 * @TAG: The tag name for the named sub-struct (usually empty)
22 * @NAME: The identifier name of the mirrored sub-struct
23 * @ATTRS: Any struct attributes (usually empty)
24 * @MEMBERS: The member declarations for the mirrored structs
26 * Used to create an anonymous union of two structs with identical layout
27 * and size: one anonymous and one named. The former's members can be used
28 * normally without sub-struct naming, and the latter can be used to
29 * reason about the start, end, and size of the group of struct members.
30 * The named struct can also be explicitly tagged for layer reuse (C only),
31 * as well as both having struct attributes appended.
33 #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
35 struct { MEMBERS } ATTRS; \
36 struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \
40 * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
42 * @TYPE: The type of each flexible array element
43 * @NAME: The name of the flexible array member
45 * In order to have a flexible array member in a union or alone in a
46 * struct, it needs to be wrapped in an anonymous struct with at least 1
47 * named member, but that member can be empty.
49 #define __DECLARE_FLEX_ARRAY(TYPE, NAME) \
51 struct { } __empty_ ## NAME; \