XenevaOS
Loading...
Searching...
No Matches
stddef.h
Go to the documentation of this file.
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/*
11 * mainline spells these as an enum. Under this tree <stdbool.h> has usually
12 * been pulled in already (linux/atomic.h includes it) and defines true/false
13 * as macros, so the enum body expands to `false = 0` -- an enumerator named
14 * `0`, hence "expected identifier". Guarded: with the macros present they
15 * already mean 1 and 0, which is all the enum is saying, and without them the
16 * enum is mainline's.
17 */
18#ifndef true
19enum {
20 false = 0,
21 true = 1
22};
23#endif
24
25#undef offsetof
26#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
27
34#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
35
42#define offsetofend(TYPE, MEMBER) \
43 (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
44
57#define struct_group(NAME, MEMBERS...) \
58 __struct_group(/* no tag */, NAME, /* no attrs */, MEMBERS)
59
73#define struct_group_attr(NAME, ATTRS, MEMBERS...) \
74 __struct_group(/* no tag */, NAME, ATTRS, MEMBERS)
75
90#define struct_group_tagged(TAG, NAME, MEMBERS...) \
91 __struct_group(TAG, NAME, /* no attrs */, MEMBERS)
92
103#define DECLARE_FLEX_ARRAY(TYPE, NAME) \
104 __DECLARE_FLEX_ARRAY(TYPE, NAME)
105
184#define __TRAILING_OVERLAP(TYPE, NAME, FAM, ATTRS, MEMBERS) \
185 union { \
186 TYPE NAME; \
187 struct { \
188 unsigned char __offset_to_FAM[offsetof(TYPE, FAM)]; \
189 MEMBERS \
190 } ATTRS; \
191 }
192
204#define TRAILING_OVERLAP(TYPE, NAME, FAM, MEMBERS) \
205 __TRAILING_OVERLAP(TYPE, NAME, FAM, /* no attrs */, MEMBERS)
206
207#endif