summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Durrant <pdurrant@amazon.com>2020-11-25 14:06:27 +0100
committerJan Beulich <jbeulich@suse.com>2020-11-25 14:06:27 +0100
commit758fae24d7b90fcfa7dffbffb5a5cab274caf3fc (patch)
tree4871ed40ce3e1730ef7f4268115963aa5ab42e8b
parent1e6d7bd585232c2526590a348871c40d5b384ac7 (diff)
xen/include: import sizeof_field() macro from Linux stddef.h
Co-locate it with the definition of offsetof() (since this is also in stddef.h in the Linux kernel source). This macro will be needed in a subsequent patch. Signed-off-by: Paul Durrant <pdurrant@amazon.com> Acked-by: Jan Beulich <jbeulich@suse.com>
-rw-r--r--xen/include/xen/compiler.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h
index c0e0ee9f27..676c6ea1b0 100644
--- a/xen/include/xen/compiler.h
+++ b/xen/include/xen/compiler.h
@@ -76,6 +76,14 @@
#define offsetof(a,b) __builtin_offsetof(a,b)
+/**
+ * sizeof_field(TYPE, MEMBER)
+ *
+ * @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))
+
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L
#define alignof __alignof__
#endif