Debian Codegraph @

include/uapi/linux/stddef.h

raw
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _LINUX_STDDEF_H
3 #define _LINUX_STDDEF_H
4
5 #ifdef __KERNEL__
6
7 #endif
8
9 #ifndef __always_inline
10 #define __always_inline inline
11 #endif
12
13 /* Not all C++ standards support type declarations inside an anonymous union */
14 #ifndef __cplusplus
15 #define __struct_group_tag(TAG) TAG
16 #else
17 #define __struct_group_tag(TAG)
18 #endif
19
20 /**
21 * __struct_group() - Create a mirrored named and anonyomous struct
22 *
23 * @TAG: The tag name for the named sub-struct (usually empty)
24 * @NAME: The identifier name of the mirrored sub-struct
25 * @ATTRS: Any struct attributes (usually empty)
26 * @MEMBERS: The member declarations for the mirrored structs
27 *
28 * Used to create an anonymous union of two structs with identical layout
29 * and size: one anonymous and one named. The former's members can be used
30 * normally without sub-struct naming, and the latter can be used to
31 * reason about the start, end, and size of the group of struct members.
32 * The named struct can also be explicitly tagged for layer reuse (C only),
33 * as well as both having struct attributes appended.
34 */
35 #define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
36 union { \
37 struct { MEMBERS } ATTRS; \
38 struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \
39 } ATTRS
40
41 #ifdef __cplusplus
42 /* sizeof(struct{}) is 1 in C++, not 0, can't use C version of the macro. */
43 #define __DECLARE_FLEX_ARRAY(T, member) \
44 T member[0]
45 #else
46 /**
47 * __DECLARE_FLEX_ARRAY() - Declare a flexible array usable in a union
48 *
49 * @TYPE: The type of each flexible array element
50 * @NAME: The name of the flexible array member
51 *
52 * In order to have a flexible array member in a union or alone in a
53 * struct, it needs to be wrapped in an anonymous struct with at least 1
54 * named member, but that member can be empty.
55 */
56 #define __DECLARE_FLEX_ARRAY(TYPE, NAME) \
57 struct { \
58 struct { } __empty_ ## NAME; \
59 TYPE NAME[]; \
60 }
61 #endif
62
63 #ifndef __counted_by
64 #define __counted_by(m)
65 #endif
66
67 #ifndef __counted_by_le
68 #define __counted_by_le(m)
69 #endif
70
71 #ifndef __counted_by_be
72 #define __counted_by_be(m)
73 #endif
74
75 #ifndef __counted_by_ptr
76 #define __counted_by_ptr(m)
77 #endif
78
79 #ifdef __KERNEL__
80 #define __kernel_nonstring __nonstring
81 #else
82 #define __kernel_nonstring
83 #endif
84
85 #endif /* _LINUX_STDDEF_H */