KVM: Don't actually set a request when evicting vCPUs for GFN cache invd
[linux-2.6-microblaze.git] / include / linux / stddef.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_STDDEF_H
3 #define _LINUX_STDDEF_H
4
5 #include <uapi/linux/stddef.h>
6
7 #undef NULL
8 #define NULL ((void *)0)
9
10 enum {
11         false   = 0,
12         true    = 1
13 };
14
15 #undef offsetof
16 #ifdef __compiler_offsetof
17 #define offsetof(TYPE, MEMBER)  __compiler_offsetof(TYPE, MEMBER)
18 #else
19 #define offsetof(TYPE, MEMBER)  ((size_t)&((TYPE *)0)->MEMBER)
20 #endif
21
22 /**
23  * sizeof_field() - Report the size of a struct field in bytes
24  *
25  * @TYPE: The structure containing the field of interest
26  * @MEMBER: The field to return the size of
27  */
28 #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
29
30 /**
31  * offsetofend() - Report the offset of a struct field within the struct
32  *
33  * @TYPE: The type of the structure
34  * @MEMBER: The member within the structure to get the end offset of
35  */
36 #define offsetofend(TYPE, MEMBER) \
37         (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
38
39 /**
40  * struct_group() - Wrap a set of declarations in a mirrored struct
41  *
42  * @NAME: The identifier name of the mirrored sub-struct
43  * @MEMBERS: The member declarations for the mirrored structs
44  *
45  * Used to create an anonymous union of two structs with identical
46  * layout and size: one anonymous and one named. The former can be
47  * used normally without sub-struct naming, and the latter can be
48  * used to reason about the start, end, and size of the group of
49  * struct members.
50  */
51 #define struct_group(NAME, MEMBERS...)  \
52         __struct_group(/* no tag */, NAME, /* no attrs */, MEMBERS)
53
54 /**
55  * struct_group_attr() - Create a struct_group() with trailing attributes
56  *
57  * @NAME: The identifier name of the mirrored sub-struct
58  * @ATTRS: Any struct attributes to apply
59  * @MEMBERS: The member declarations for the mirrored structs
60  *
61  * Used to create an anonymous union of two structs with identical
62  * layout and size: one anonymous and one named. The former can be
63  * used normally without sub-struct naming, and the latter can be
64  * used to reason about the start, end, and size of the group of
65  * struct members. Includes structure attributes argument.
66  */
67 #define struct_group_attr(NAME, ATTRS, MEMBERS...) \
68         __struct_group(/* no tag */, NAME, ATTRS, MEMBERS)
69
70 /**
71  * struct_group_tagged() - Create a struct_group with a reusable tag
72  *
73  * @TAG: The tag name for the named sub-struct
74  * @NAME: The identifier name of the mirrored sub-struct
75  * @MEMBERS: The member declarations for the mirrored structs
76  *
77  * Used to create an anonymous union of two structs with identical
78  * layout and size: one anonymous and one named. The former can be
79  * used normally without sub-struct naming, and the latter can be
80  * used to reason about the start, end, and size of the group of
81  * struct members. Includes struct tag argument for the named copy,
82  * so the specified layout can be reused later.
83  */
84 #define struct_group_tagged(TAG, NAME, MEMBERS...) \
85         __struct_group(TAG, NAME, /* no attrs */, MEMBERS)
86
87 /**
88  * DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
89  *
90  * @TYPE: The type of each flexible array element
91  * @NAME: The name of the flexible array member
92  *
93  * In order to have a flexible array member in a union or alone in a
94  * struct, it needs to be wrapped in an anonymous struct with at least 1
95  * named member, but that member can be empty.
96  */
97 #define DECLARE_FLEX_ARRAY(TYPE, NAME) \
98         __DECLARE_FLEX_ARRAY(TYPE, NAME)
99
100 #endif