| From | Alejandro Colomar <> | Subject | [PATCH v2 01/20] linux/stddef.h, linux/offsetof.h: Split offsetof() into a separate header | Date | Sat, 20 Nov 2021 14:00:44 +0100 |
| |
Include <linux/offsetof.h> from <linux/stddef.h> for compatibility.
From <linux/offsetof.h>: Include the same exact deps that <linux/stddef.h> had. Changing that in any way broke my compilation.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
f --- include/linux/offsetof.h | 17 +++++++++++++++++ include/linux/stddef.h | 11 ++++------- 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 include/linux/offsetof.h
diff --git a/include/linux/offsetof.h b/include/linux/offsetof.h new file mode 100644 index 000000000000..3db431197687 --- /dev/null +++ b/include/linux/offsetof.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_OFFSETOF_H +#define _LINUX_OFFSETOF_H + + +#include <uapi/linux/stddef.h> + + +#undef offsetof +#ifdef __compiler_offsetof +#define offsetof(T, m) __compiler_offsetof(T, m) +#else +#define offsetof(T, m) ((size_t)&((T *)0)->m) +#endif + + +#endif /* _LINUX_OFFSETOF_H */ diff --git a/include/linux/stddef.h b/include/linux/stddef.h index ca507bd5f808..41217710788e 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -2,8 +2,12 @@ #ifndef _LINUX_STDDEF_H #define _LINUX_STDDEF_H + #include <uapi/linux/stddef.h> +#include <linux/offsetof.h> + + #undef NULL #define NULL ((void *)0) @@ -12,13 +16,6 @@ enum { true = 1 }; -#undef offsetof -#ifdef __compiler_offsetof -#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER) -#else -#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER) -#endif - /** * sizeof_field() - Report the size of a struct field in bytes * -- 2.33.1
|