diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-19 15:54:10 +0100 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-20 13:20:37 +0100 |
commit | a28e1db7c17afd5e6fccc7aa97e8da4a96919805 (patch) | |
tree | 2c95d0a69f05fef2b90e90636559b7d5546327ec | |
parent | fa55b7dcdc43c1aa1ba12bca9d2dd4318c2a0dbf (diff) |
linux/stddef.h, linux/offsetof.h: Split offsetof() into a separate header
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
-rw-r--r-- | include/linux/offsetof.h | 17 | ||||
-rw-r--r-- | include/linux/stddef.h | 11 |
2 files changed, 21 insertions, 7 deletions
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 * |