xref: /qemu/subprojects/libvduse/linux-headers/linux/stddef.h (revision 7be29f2f1a3f5b037d27eedbd5df9f441e8c8c16)
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 
11421ee1ecSDaniel Henrique Barboza /* Not all C++ standards support type declarations inside an anonymous union */
12421ee1ecSDaniel Henrique Barboza #ifndef __cplusplus
13421ee1ecSDaniel Henrique Barboza #define __struct_group_tag(TAG)		TAG
14421ee1ecSDaniel Henrique Barboza #else
15421ee1ecSDaniel Henrique Barboza #define __struct_group_tag(TAG)
16421ee1ecSDaniel Henrique Barboza #endif
17421ee1ecSDaniel Henrique Barboza 
18c5c0fdbeSDavid 'Digit' Turner /**
19c5c0fdbeSDavid 'Digit' Turner  * __struct_group() - Create a mirrored named and anonyomous struct
20c5c0fdbeSDavid 'Digit' Turner  *
21c5c0fdbeSDavid 'Digit' Turner  * @TAG: The tag name for the named sub-struct (usually empty)
22c5c0fdbeSDavid 'Digit' Turner  * @NAME: The identifier name of the mirrored sub-struct
23c5c0fdbeSDavid 'Digit' Turner  * @ATTRS: Any struct attributes (usually empty)
24c5c0fdbeSDavid 'Digit' Turner  * @MEMBERS: The member declarations for the mirrored structs
25c5c0fdbeSDavid 'Digit' Turner  *
26c5c0fdbeSDavid 'Digit' Turner  * Used to create an anonymous union of two structs with identical layout
27c5c0fdbeSDavid 'Digit' Turner  * and size: one anonymous and one named. The former's members can be used
28c5c0fdbeSDavid 'Digit' Turner  * normally without sub-struct naming, and the latter can be used to
29c5c0fdbeSDavid 'Digit' Turner  * reason about the start, end, and size of the group of struct members.
30421ee1ecSDaniel Henrique Barboza  * The named struct can also be explicitly tagged for layer reuse (C only),
31421ee1ecSDaniel Henrique Barboza  * as well as both having struct attributes appended.
32c5c0fdbeSDavid 'Digit' Turner  */
33c5c0fdbeSDavid 'Digit' Turner #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
34c5c0fdbeSDavid 'Digit' Turner 	union { \
35c5c0fdbeSDavid 'Digit' Turner 		struct { MEMBERS } ATTRS; \
36421ee1ecSDaniel Henrique Barboza 		struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \
37efb91426SDaniel Henrique Barboza 	} ATTRS
38c5c0fdbeSDavid 'Digit' Turner 
39efb91426SDaniel Henrique Barboza #ifdef __cplusplus
40efb91426SDaniel Henrique Barboza /* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */
41efb91426SDaniel Henrique Barboza #define __DECLARE_FLEX_ARRAY(T, member)	\
42efb91426SDaniel Henrique Barboza 	T member[0]
43efb91426SDaniel Henrique Barboza #else
44c5c0fdbeSDavid 'Digit' Turner /**
45c5c0fdbeSDavid 'Digit' Turner  * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
46c5c0fdbeSDavid 'Digit' Turner  *
47c5c0fdbeSDavid 'Digit' Turner  * @TYPE: The type of each flexible array element
48c5c0fdbeSDavid 'Digit' Turner  * @NAME: The name of the flexible array member
49c5c0fdbeSDavid 'Digit' Turner  *
50c5c0fdbeSDavid 'Digit' Turner  * In order to have a flexible array member in a union or alone in a
51c5c0fdbeSDavid 'Digit' Turner  * struct, it needs to be wrapped in an anonymous struct with at least 1
52c5c0fdbeSDavid 'Digit' Turner  * named member, but that member can be empty.
53c5c0fdbeSDavid 'Digit' Turner  */
54c5c0fdbeSDavid 'Digit' Turner #define __DECLARE_FLEX_ARRAY(TYPE, NAME)	\
55c5c0fdbeSDavid 'Digit' Turner 	struct { \
56c5c0fdbeSDavid 'Digit' Turner 		struct { } __empty_ ## NAME; \
57c5c0fdbeSDavid 'Digit' Turner 		TYPE NAME[]; \
58c5c0fdbeSDavid 'Digit' Turner 	}
59c5c0fdbeSDavid 'Digit' Turner #endif
60da3c22c7SThomas Huth 
61da3c22c7SThomas Huth #ifndef __counted_by
62da3c22c7SThomas Huth #define __counted_by(m)
63da3c22c7SThomas Huth #endif
64efb91426SDaniel Henrique Barboza 
65c5614ee3SThomas Weißschuh #ifndef __counted_by_le
66c5614ee3SThomas Weißschuh #define __counted_by_le(m)
67c5614ee3SThomas Weißschuh #endif
68c5614ee3SThomas Weißschuh 
69c5614ee3SThomas Weißschuh #ifndef __counted_by_be
70c5614ee3SThomas Weißschuh #define __counted_by_be(m)
71c5614ee3SThomas Weißschuh #endif
72c5614ee3SThomas Weißschuh 
73*1cab5a02SRorie Reyes #define __kernel_nonstring
74*1cab5a02SRorie Reyes 
75efb91426SDaniel Henrique Barboza #endif /* _LINUX_STDDEF_H */
76