[PATCH 02/18] stddef: add sizeof_field()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 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





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux