![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 #ifndef _LINUX_STDDEF_H 0003 #define _LINUX_STDDEF_H 0004 0005 #include <uapi/linux/stddef.h> 0006 0007 #undef NULL 0008 #define NULL ((void *)0) 0009 0010 enum { 0011 false = 0, 0012 true = 1 0013 }; 0014 0015 #undef offsetof 0016 #define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER) 0017 0018 /** 0019 * sizeof_field() - Report the size of a struct field in bytes 0020 * 0021 * @TYPE: The structure containing the field of interest 0022 * @MEMBER: The field to return the size of 0023 */ 0024 #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) 0025 0026 /** 0027 * offsetofend() - Report the offset of a struct field within the struct 0028 * 0029 * @TYPE: The type of the structure 0030 * @MEMBER: The member within the structure to get the end offset of 0031 */ 0032 #define offsetofend(TYPE, MEMBER) \ 0033 (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER)) 0034 0035 /** 0036 * struct_group() - Wrap a set of declarations in a mirrored struct 0037 * 0038 * @NAME: The identifier name of the mirrored sub-struct 0039 * @MEMBERS: The member declarations for the mirrored structs 0040 * 0041 * Used to create an anonymous union of two structs with identical 0042 * layout and size: one anonymous and one named. The former can be 0043 * used normally without sub-struct naming, and the latter can be 0044 * used to reason about the start, end, and size of the group of 0045 * struct members. 0046 */ 0047 #define struct_group(NAME, MEMBERS...) \ 0048 __struct_group(/* no tag */, NAME, /* no attrs */, MEMBERS) 0049 0050 /** 0051 * struct_group_attr() - Create a struct_group() with trailing attributes 0052 * 0053 * @NAME: The identifier name of the mirrored sub-struct 0054 * @ATTRS: Any struct attributes to apply 0055 * @MEMBERS: The member declarations for the mirrored structs 0056 * 0057 * Used to create an anonymous union of two structs with identical 0058 * layout and size: one anonymous and one named. The former can be 0059 * used normally without sub-struct naming, and the latter can be 0060 * used to reason about the start, end, and size of the group of 0061 * struct members. Includes structure attributes argument. 0062 */ 0063 #define struct_group_attr(NAME, ATTRS, MEMBERS...) \ 0064 __struct_group(/* no tag */, NAME, ATTRS, MEMBERS) 0065 0066 /** 0067 * struct_group_tagged() - Create a struct_group with a reusable tag 0068 * 0069 * @TAG: The tag name for the named sub-struct 0070 * @NAME: The identifier name of the mirrored sub-struct 0071 * @MEMBERS: The member declarations for the mirrored structs 0072 * 0073 * Used to create an anonymous union of two structs with identical 0074 * layout and size: one anonymous and one named. The former can be 0075 * used normally without sub-struct naming, and the latter can be 0076 * used to reason about the start, end, and size of the group of 0077 * struct members. Includes struct tag argument for the named copy, 0078 * so the specified layout can be reused later. 0079 */ 0080 #define struct_group_tagged(TAG, NAME, MEMBERS...) \ 0081 __struct_group(TAG, NAME, /* no attrs */, MEMBERS) 0082 0083 /** 0084 * DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union 0085 * 0086 * @TYPE: The type of each flexible array element 0087 * @NAME: The name of the flexible array member 0088 * 0089 * In order to have a flexible array member in a union or alone in a 0090 * struct, it needs to be wrapped in an anonymous struct with at least 1 0091 * named member, but that member can be empty. 0092 */ 0093 #define DECLARE_FLEX_ARRAY(TYPE, NAME) \ 0094 __DECLARE_FLEX_ARRAY(TYPE, NAME) 0095 0096 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |