diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-19 16:17:20 +0100 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2021-11-20 13:21:59 +0100 |
commit | e1e1588fd8920211a7ca1c62108138dfc9ba9342 (patch) | |
tree | 9b5ba67e8a72576ca46343129041e2526e703e5c | |
parent | a28e1db7c17afd5e6fccc7aa97e8da4a96919805 (diff) |
linux/stddef.h, linux/sizeof_field.h: Split sizeof_field() into a separate header
Include <linux/sizeof_field.h> from <linux/stddef.h> for compatibility.
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
-rw-r--r-- | include/linux/sizeof_field.h | 15 | ||||
-rw-r--r-- | include/linux/stddef.h | 9 |
2 files changed, 16 insertions, 8 deletions
diff --git a/include/linux/sizeof_field.h b/include/linux/sizeof_field.h new file mode 100644 index 000000000000..15dc10fce8f3 --- /dev/null +++ b/include/linux/sizeof_field.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_SIZEOF_FIELD_H +#define _LINUX_SIZEOF_FIELD_H + + +/** + * sizeof_field() - Report the size of a struct field in bytes + * + * @T: The structure containing the field of interest + * @m: The field (member) to return the size of + */ +#define sizeof_field(T, m) sizeof((((T *)0)->m)) + + +#endif /* _LINUX_SIZEOF_FIELD_H */ diff --git a/include/linux/stddef.h b/include/linux/stddef.h index 41217710788e..1be2c71c1e85 100644 --- a/include/linux/stddef.h +++ b/include/linux/stddef.h @@ -6,6 +6,7 @@ #include <uapi/linux/stddef.h> #include <linux/offsetof.h> +#include <linux/sizeof_field.h> #undef NULL @@ -17,14 +18,6 @@ enum { }; /** - * sizeof_field() - Report the size of a struct field in bytes - * - * @TYPE: The structure containing the field of interest - * @MEMBER: The field to return the size of - */ -#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER)) - -/** * offsetofend() - Report the offset of a struct field within the struct * * @TYPE: The type of the structure |