stddef.h (e7f18c22e6bea258ffd65185fdab66d1e63dd5bd) stddef.h (50d7bd38c3aafc4749e05e8d7fcb616979143602)
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)

--- 22 unchanged lines hidden (view full) ---

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
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)

--- 22 unchanged lines hidden (view full) ---

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
39#endif
87#endif