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; \
30efb91426SDaniel Henrique Barboza 	} ATTRS
31c5c0fdbeSDavid 'Digit' Turner 
32efb91426SDaniel Henrique Barboza #ifdef __cplusplus
33efb91426SDaniel Henrique Barboza /* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */
34efb91426SDaniel Henrique Barboza #define __DECLARE_FLEX_ARRAY(T, member)	\
35efb91426SDaniel Henrique Barboza 	T member[0]
36efb91426SDaniel Henrique Barboza #else
37c5c0fdbeSDavid 'Digit' Turner /**
38c5c0fdbeSDavid 'Digit' Turner  * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
39c5c0fdbeSDavid 'Digit' Turner  *
40c5c0fdbeSDavid 'Digit' Turner  * @TYPE: The type of each flexible array element
41c5c0fdbeSDavid 'Digit' Turner  * @NAME: The name of the flexible array member
42c5c0fdbeSDavid 'Digit' Turner  *
43c5c0fdbeSDavid 'Digit' Turner  * In order to have a flexible array member in a union or alone in a
44c5c0fdbeSDavid 'Digit' Turner  * struct, it needs to be wrapped in an anonymous struct with at least 1
45c5c0fdbeSDavid 'Digit' Turner  * named member, but that member can be empty.
46c5c0fdbeSDavid 'Digit' Turner  */
47c5c0fdbeSDavid 'Digit' Turner #define __DECLARE_FLEX_ARRAY(TYPE, NAME)	\
48c5c0fdbeSDavid 'Digit' Turner 	struct { \
49c5c0fdbeSDavid 'Digit' Turner 		struct { } __empty_ ## NAME; \
50c5c0fdbeSDavid 'Digit' Turner 		TYPE NAME[]; \
51c5c0fdbeSDavid 'Digit' Turner 	}
52c5c0fdbeSDavid 'Digit' Turner #endif
53da3c22c7SThomas Huth 
54da3c22c7SThomas Huth #ifndef __counted_by
55da3c22c7SThomas Huth #define __counted_by(m)
56da3c22c7SThomas Huth #endif
57efb91426SDaniel Henrique Barboza 
58*c5614ee3SThomas Weißschuh #ifndef __counted_by_le
59*c5614ee3SThomas Weißschuh #define __counted_by_le(m)
60*c5614ee3SThomas Weißschuh #endif
61*c5614ee3SThomas Weißschuh 
62*c5614ee3SThomas Weißschuh #ifndef __counted_by_be
63*c5614ee3SThomas Weißschuh #define __counted_by_be(m)
64*c5614ee3SThomas Weißschuh #endif
65*c5614ee3SThomas Weißschuh 
66efb91426SDaniel Henrique Barboza #endif /* _LINUX_STDDEF_H */
67