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>
This commit is contained in:
Paul Durrant authored and Jan Beulich committed 2020-11-25 14:06:27 +01:00
1 parent 1e6d7bd585
commit 758fae24d7
1 file changed
+8
+8
View File
@@ -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
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.