|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] tools: add sizeof_field and endof_field macros
commit 17e66ca9188b423eee35e6b4bf878e62d3879a04
Author: Petr Beneš <w1benny@xxxxxxxxx>
AuthorDate: Wed Aug 27 10:28:44 2025 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Aug 27 11:26:33 2025 +0200
tools: add sizeof_field and endof_field macros
* `sizeof_field` returns the size of a specific struct member
* `endof_field` returns the offset to the end of the member within the
struct
It will be useful in upcoming layout checks of SMBIOS structs.
Signed-off-by: Petr Beneš <w1benny@xxxxxxxxx>
Acked-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
tools/include/xen-tools/common-macros.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/include/xen-tools/common-macros.h
b/tools/include/xen-tools/common-macros.h
index 0088208c2e..9838a108aa 100644
--- a/tools/include/xen-tools/common-macros.h
+++ b/tools/include/xen-tools/common-macros.h
@@ -83,6 +83,11 @@
#define __packed __attribute__((__packed__))
#endif
+#define sizeof_field(type, member) sizeof(((type *)NULL)->member)
+
+#define endof_field(type, member) \
+ (offsetof(type, member) + sizeof_field(type, member))
+
#define container_of(ptr, type, member) ({ \
typeof(((type *)0)->member) *mptr__ = (ptr); \
(type *)((char *)mptr__ - offsetof(type, member)); \
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |