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