[PATCH 02/18] stddef: add sizeof_field()
Sascha Hauer
s.hauer at pengutronix.de
Thu May 4 01:17:29 PDT 2023
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
include/linux/stddef.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/include/linux/stddef.h b/include/linux/stddef.h
index 5429a7b582..1044571c3f 100644
--- a/include/linux/stddef.h
+++ b/include/linux/stddef.h
@@ -24,4 +24,12 @@ typedef unsigned short wchar_t;
#undef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+/**
+ * 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))
+
#endif
--
2.39.2
More information about the barebox
mailing list